Skip to content

Fix: Added Assert to Chigazo's Lesson 15; #521

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 45 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
887b8f0
Merge pull request #1 from code-differently/main
A1-4U2T1NN Sep 26, 2024
05ad627
Merge branch 'code-differently:main' into main
A1-4U2T1NN Sep 27, 2024
5715b6a
Merge branch 'code-differently:main' into main
A1-4U2T1NN Sep 30, 2024
6c909b0
Merge branch 'code-differently:main' into main
A1-4U2T1NN Sep 30, 2024
4c1a3f2
Merge branch 'code-differently:main' into main
A1-4U2T1NN Sep 30, 2024
de19403
Merge branch 'code-differently:main' into main
A1-4U2T1NN Sep 30, 2024
56aa83d
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 1, 2024
8529105
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 2, 2024
4f76813
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 3, 2024
48bf962
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 5, 2024
1da88b9
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 7, 2024
3068765
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 9, 2024
712efd6
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 11, 2024
5db7413
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 11, 2024
5096f8e
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 12, 2024
09341aa
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 14, 2024
a8f634e
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 15, 2024
b643a4c
feat: created chigazograham.json file
Oct 16, 2024
cae2152
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 16, 2024
68ccb5f
fix: deleted lesson_09 content from main;
Oct 16, 2024
7d4f86f
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 16, 2024
473eb98
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 17, 2024
1d19106
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 17, 2024
bba5af5
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 18, 2024
a51c852
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 19, 2024
8a39fcc
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 21, 2024
ac98745
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 22, 2024
eade00f
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 23, 2024
bf252ad
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 23, 2024
955b86f
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 25, 2024
b6f63bd
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 28, 2024
22db65b
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 28, 2024
d5eff9e
Merge branch 'code-differently:main' into main
A1-4U2T1NN Oct 28, 2024
28ebc46
feat: added test framework for EmployeeTest and EmployeeManagerTest
Oct 29, 2024
845074e
Merge branch 'code-differently:main' into lesson_15
A1-4U2T1NN Oct 29, 2024
9b45e84
feat: added Arrange, Act, and Assert methods for all 'textGet...' fun…
Oct 29, 2024
863a8da
feat: added Arrange, Act, and Assert methods for testSetDepartment an…
Oct 29, 2024
2442d62
feat: added getDetails method to Employee.java; created corresponding…
Oct 29, 2024
c1c218b
fix: Ran './gradlew :tdd_app:spotlessApply' to correct formatting;
Oct 29, 2024
3cfbfff
fix: removed duplicate EmployeeManagerTest;
Oct 29, 2024
ce9042d
feat: added assertion for testAddEmployee;
Nov 1, 2024
a37620c
Merge branch 'code-differently:main' into lesson_15
A1-4U2T1NN Nov 1, 2024
1a3fb39
fix: ran ./gradlew :objects_app:spotlessApply to correct formating mi…
Nov 1, 2024
a3f22c3
gMerge branch 'lesson_15' of https://github.com/A1-4U2T1NN/code-diffe…
Nov 1, 2024
39328d7
fix: removed duplicate EmployeeMangerTest file
Nov 1, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,8 @@ public double getSalary() {
public void setSalary(double salary) {
this.salary = salary;
}

public String getDetails() {
return "id: " + id + "name: " + name + "department: " + department + "salary: " + salary;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package com.codedifferently.lesson15;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertEquals;

import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class EmployeeManagerTest {

EmployeeManager employeeManager;
List<Employee> employees;

// Set up
@BeforeEach
void setUp() {
employeeManager = new EmployeeManager();
Employee employee = new Employee(0, "Nitsua", "Sales", 65000.00);
employeeManager.addEmployee(employee);
employees = new ArrayList();
employees.add(employee);
}

@Test
public void testAddEmployee() {
// Arrange
Employee employee1 = new Employee(1, "Penny", "Sales", 65000.00);
// Act & Assert
employeeManager.addEmployee(employee1);
assertEquals(employee1, employeeManager.getEmployee(1));
}

@Test
public void testGetEmployee() {
// Arrange
Employee employee = new Employee(0, "Nitsua", "Sales", 65000.00);
Employee expectedEmployee = employeeManager.getEmployee(employee.getId());
// Act
Employee actualEmployee = employeeManager.getEmployee(0);
// Assert
assertEquals(expectedEmployee, actualEmployee);
}

@Test
public void testUpdateEmployee() {
// Arrange
Employee expectedEmployeeUpdate = new Employee(0, "Nitsua", "Tech", 100000.00);
// Act
employeeManager.updateEmployee(expectedEmployeeUpdate);
// Act
assertEquals(expectedEmployeeUpdate, employeeManager.getEmployee(0));
}

@Test
public void testRemoveEmployee() {
// Arange
Employee employee = new Employee(0, "Nitsua", "Sales", 65000.00);
employeeManager.addEmployee(employee);
// Act
employeeManager.removeEmployee(0);
// Assert
assertThatThrownBy(() -> employeeManager.removeEmployee(0))
.isInstanceOf(IllegalArgumentException.class)
.hasMessage("Employee does not in collection with id " + employee.getId());
}

@Test
public void testGetEmployeeCount() {
// Act
int actualEmployeeCount = employeeManager.getEmployeeCount();
// Assert(recieved help from Vicente on employees array)
assertEquals(employees.size(), actualEmployeeCount);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
package com.codedifferently.lesson15;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class EmployeeTest {

Employee employee;

// Set up
@BeforeEach
void setUp() {
employee = new Employee(19, "Chigazo", "Finance", 50000.00);
}

@Test
// Method being tested
public void testGetId() {
// Execersise
int actualId = employee.getId();

int expectedId = 19;
// Assert(Checking the value)
assertEquals(expectedId, actualId);
}

@Test
public void testSetID() {
// Arrange
int expectedSetId = 91;
// Act
employee.setId(expectedSetId);
// Assert
assertEquals(expectedSetId, employee.getId());
}

@Test
public void testGetName() {
// Arrange
String expectedName = "Chigazo";
// Act
String actualName = employee.getName();
// Assert
assertEquals(expectedName, actualName);
}

@Test
public void testSetName() {
// Arrange
String expectedSetName = "Austin";
// Act
employee.setName(expectedSetName);
// Assert
assertEquals(expectedSetName, employee.getName());
}

@Test
public void testGetDepartment() {
// Arrange
String actualDepartment = "Finance";
// Act
String expectedDepartment = employee.getDepartment();
// Assert
assertEquals(expectedDepartment, actualDepartment);
}

@Test
public void testSetDepartment() {
// Arrange
String expectedSetDepartment = "Tech";
// Act
employee.setDepartment(expectedSetDepartment);
// Assert
assertEquals(expectedSetDepartment, employee.getDepartment());
}

@Test
public void testGetSalary() {
// Arrange
double actualSalary = 50000.00;
// Act
double expectedSalary = employee.getSalary();
// Assert
assertEquals(expectedSalary, actualSalary);
}

@Test
public void testSetSalary() {
// Arrange
double expectedSetSalary = 100000.00;
// Act
employee.setSalary(expectedSetSalary);
// Assert
assertEquals(expectedSetSalary, employee.getSalary());
}

@Test
public void testGetDetails() {
// Arrange
String actualDetails =
"id: "
+ employee.getId()
+ "name: "
+ employee.getName()
+ "department: "
+ employee.getDepartment()
+ "salary: "
+ employee.getSalary();
// Act
String expectedDetails = employee.getDetails();
// Assert
assertEquals(expectedDetails, actualDetails);
}
}
Loading