-
Notifications
You must be signed in to change notification settings - Fork 25
feat: adds amiyah jones' lesson 15 emplyeeManager and Employee test files #484
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
Closed
Changes from all commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
8cc92d0
Create README.md
AmiyahJo 50b1861
Delete lesson_00/amiyahjones/README.md
AmiyahJo 27d57c0
Merge branch 'code-differently:main' into main
AmiyahJo fa3c700
Merge branch 'code-differently:main' into main
AmiyahJo 7c2d053
Merge branch 'code-differently:main' into main
AmiyahJo faedd1b
Merge branch 'code-differently:main' into main
AmiyahJo 19a4187
Merge branch 'code-differently:main' into main
AmiyahJo 7711266
Merge branch 'code-differently:main' into main
AmiyahJo 9a10c4c
Merge branch 'code-differently:main' into main
AmiyahJo 3ea50c4
Merge branch 'code-differently:main' into main
AmiyahJo d7b772d
Merge branch 'code-differently:main' into main
AmiyahJo de46b67
Merge branch 'code-differently:main' into main
AmiyahJo b891561
Merge branch 'code-differently:main' into main
AmiyahJo 7c9f2db
Merge branch 'code-differently:main' into main
AmiyahJo ff3ba35
Merge branch 'code-differently:main' into main
AmiyahJo 457feea
Merge branch 'code-differently:main' into main
AmiyahJo 5868f9d
Merge branch 'code-differently:main' into main
AmiyahJo 28eacd4
Merge branch 'code-differently:main' into main
AmiyahJo bca4933
Merge branch 'code-differently:main' into main
AmiyahJo 9ff0f9e
Merge branch 'code-differently:main' into main
AmiyahJo 8d02849
Merge branch 'code-differently:main' into main
AmiyahJo 6dd3a43
Merge branch 'code-differently:main' into main
AmiyahJo 95f56a5
Merge branch 'code-differently:main' into main
AmiyahJo 0f4dbac
Merge branch 'code-differently:main' into main
AmiyahJo a3b9984
Merge branch 'code-differently:main' into main
AmiyahJo 54cd199
Merge branch 'code-differently:main' into main
AmiyahJo edbe7c0
Merge branch 'code-differently:main' into main
AmiyahJo 7f0a084
Merge branch 'code-differently:main' into main
AmiyahJo a905b74
Merge branch 'code-differently:main' into main
AmiyahJo 2d69531
Merge branch 'code-differently:main' into main
AmiyahJo df48fbd
Merge branch 'code-differently:main' into main
AmiyahJo c972d14
Merge branch 'code-differently:main' into main
AmiyahJo bc3907c
Merge branch 'code-differently:main' into main
AmiyahJo c3eabbb
Merge branch 'code-differently:main' into main
AmiyahJo 9fff7d0
Merge branch 'code-differently:main' into main
AmiyahJo 4c57926
Merge branch 'code-differently:main' into main
AmiyahJo 8dd5d42
Merge branch 'code-differently:main' into main
AmiyahJo 18f65ee
Merge branch 'code-differently:main' into main
AmiyahJo 2dd1645
Merge branch 'code-differently:main' into main
AmiyahJo 0de8601
Merge branch 'code-differently:main' into main
AmiyahJo 85dd364
Merge branch 'code-differently:main' into main
AmiyahJo 0afda26
Merge branch 'code-differently:main' into main
AmiyahJo f31e8d9
Merge branch 'code-differently:main' into main
AmiyahJo 3e24069
Merge branch 'code-differently:main' into main
AmiyahJo 8600f6c
Merge branch 'code-differently:main' into main
AmiyahJo 563b076
Merge branch 'code-differently:main' into main
AmiyahJo b01a324
Merge branch 'code-differently:main' into main
AmiyahJo 697a72d
Merge branch 'code-differently:main' into main
AmiyahJo 92891f6
Merge branch 'code-differently:main' into main
AmiyahJo 17fdee5
Merge branch 'code-differently:main' into main
AmiyahJo cf7e6f2
Merge branch 'code-differently:main' into main
AmiyahJo a131bdc
Merge branch 'code-differently:main' into main
AmiyahJo c46d32f
Merge branch 'code-differently:main' into main
AmiyahJo 651fa01
Merge branch 'code-differently:main' into main
AmiyahJo e075fb7
Merge branch 'code-differently:main' into main
AmiyahJo ec7c3d1
Merge branch 'code-differently:main' into main
AmiyahJo 5abb36a
feat: adds employee manager test page
e7b8f6a
Merge branch 'code-differently:main' into feature/lesson_15
AmiyahJo 0b9908f
feat: adds employee feature , work in progress
6a59629
feat: new getDetails added
f96daa2
chore: spelling change 'id' to 'ID'
f281ac0
rm: removes method 'details'
2ef91ac
feat: adds test
ad5881a
chore: whitespacce adjustment for testGetDetails()
f609dba
feat: adds AAA comments for reference in both .java tests
1bea0f7
chore: whitespace adjustment in tests
e35a659
feat: testGetID test added
07ada74
feat: adds testGetName()
bde73a9
feat: adds testGetSalary
35d6387
feat: adds variables to store expected and actual department name
fc49eb5
feat: adds all set tests
efbbe3b
feat: testAddEmployee test is added.
6a5424e
feat: adds testAddEmployee code
51304ea
feat: adds employee manager (to settle tasks) , testUpdateEmployee test
5831a17
feat: adds add and remove employee , employee count , and assertion(s…
d388be2
rm: throw exception extra(s)
a7c20d1
fix: gradlew spotless apply
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
lesson_15/tdd/tdd_app/src/test/java/com/codedifferently/lesson15/EmployeeManagerTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
package com.codedifferently.lesson15; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class EmployeeManagerTest { | ||
private EmployeeManager employeeManager; | ||
|
||
@BeforeEach | ||
public void setUp() { | ||
employeeManager = new EmployeeManager(); | ||
} | ||
|
||
@Test | ||
void testAddEmployee() { | ||
// Arrange | ||
Employee employee = new Employee(1, "John Doe", null, 0); | ||
|
||
// Act | ||
employeeManager.addEmployee(employee); | ||
|
||
// Assert | ||
assertEquals(1, employeeManager.getEmployeeCount()); | ||
} | ||
|
||
@Test | ||
void testUpdateEmployee() { | ||
// Arrange | ||
Employee employee = new Employee(1, "John Doe", null, 0); | ||
Employee updatedEmployee = new Employee(1, "Jane Doe", null, 0); | ||
|
||
// Act | ||
employeeManager.addEmployee(employee); | ||
employeeManager.updateEmployee(updatedEmployee); | ||
|
||
// Assert | ||
Employee retrievedEmployee = employeeManager.getEmployee(1); | ||
assertEquals(updatedEmployee.getName(), retrievedEmployee.getName()); | ||
} | ||
|
||
@Test | ||
void testGetEmployee() { | ||
// Arrange | ||
Employee employee = new Employee(1, "John Doe", null, 0); | ||
|
||
// Act | ||
employeeManager.addEmployee(employee); | ||
Employee retrievedEmployee = employeeManager.getEmployee(1); | ||
|
||
// Assert | ||
assertEquals(employee.getId(), retrievedEmployee.getId()); | ||
assertEquals(employee.getName(), retrievedEmployee.getName()); | ||
} | ||
|
||
@Test | ||
void testRemoveEmployee() { | ||
|
||
Employee employee = new Employee(1, "John Doe", null, 0); | ||
|
||
employeeManager.addEmployee(employee); | ||
assertEquals(1, employeeManager.getEmployeeCount()); | ||
|
||
employeeManager.removeEmployee(1); | ||
assertEquals(0, employeeManager.getEmployeeCount()); | ||
} | ||
|
||
@Test | ||
void testGetEmployeeCount() { | ||
|
||
assertEquals(0, employeeManager.getEmployeeCount()); | ||
|
||
employeeManager.addEmployee(new Employee(1, "John Doe", null, 0)); | ||
employeeManager.addEmployee(new Employee(2, "Jane Doe", null, 0)); | ||
|
||
assertEquals(2, employeeManager.getEmployeeCount()); | ||
} | ||
|
||
@Test | ||
void testGetEmployeeThrowsExceptionForNonExistentId() { | ||
AmiyahJo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
assertThrows( | ||
IllegalArgumentException.class, | ||
() -> { | ||
employeeManager.getEmployee(999); | ||
}); | ||
} | ||
} |
120 changes: 120 additions & 0 deletions
120
lesson_15/tdd/tdd_app/src/test/java/com/codedifferently/lesson15/EmployeeTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
package com.codedifferently.lesson15; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class EmployeeTest { | ||
@Test | ||
void testGetDepartment() { | ||
// Arrange | ||
Employee employee = new Employee(12345, "John Doe", "Engineering", 75000); | ||
|
||
// Act | ||
String actualDepartment = employee.getDepartment(); | ||
|
||
// Assert | ||
String expectedDepartment = "Engineering"; | ||
assertEquals(expectedDepartment, actualDepartment); | ||
} | ||
|
||
@Test | ||
void testGetDetails() { | ||
// Arrange | ||
Employee employee = new Employee(12345, "John Doe", "Engineering", 75000); | ||
|
||
// Act | ||
String actualDetails = employee.getDetails(); | ||
|
||
// Assert | ||
String expectedDetails = | ||
"Employee: John Doe, Department: Engineering , ID: 12345 , Salary: 75000"; | ||
assertEquals(expectedDetails, actualDetails); | ||
} | ||
|
||
@Test | ||
void testGetId() { | ||
// Arrange | ||
Employee employee = new Employee(12345, "John Doe", "Engineering", 75000); | ||
|
||
// Act | ||
int actualEmployeeID = employee.getId(); | ||
|
||
// Assert | ||
int expectedEmployeeID = 12345; | ||
assertEquals(expectedEmployeeID, actualEmployeeID); | ||
} | ||
|
||
@Test | ||
void testGetName() { | ||
// Arrange | ||
Employee employee = new Employee(12345, "John Doe", "Engineering", 75000); | ||
|
||
// Act | ||
employee.getName(); | ||
|
||
// Assert | ||
assertEquals("John Doe", employee.getName()); | ||
} | ||
|
||
@Test | ||
void testGetSalary() { | ||
// Arrange | ||
Employee employee = new Employee(12345, "John Doe", "Engineering", 75000); | ||
|
||
// Act | ||
double expectedSalary = employee.getSalary(); | ||
|
||
// Assert | ||
double actualSalary = 75000; | ||
assertEquals(expectedSalary, actualSalary); | ||
} | ||
|
||
@Test | ||
void testSetDepartment() { | ||
// Arrange | ||
Employee employee = new Employee(12345, "John Doe", "", 75000); | ||
|
||
// Act | ||
employee.setDepartment("Engineering"); | ||
|
||
// Assert | ||
assertEquals("Engineering", employee.getDepartment()); | ||
} | ||
|
||
@Test | ||
void testSetId() { | ||
// Arrange | ||
Employee employee = new Employee(0, "John Doe", "", 75000); | ||
|
||
// Act | ||
employee.setId(12345); | ||
|
||
// Assert | ||
assertEquals(12345, employee.getId()); | ||
} | ||
|
||
@Test | ||
void testSetName() { | ||
// Arrange | ||
Employee employee = new Employee(12345, "", "Engineering", 75000); | ||
|
||
// Act | ||
employee.setName("Alice Johnson"); | ||
|
||
// Assert | ||
assertEquals("Alice Johnson", employee.getName()); | ||
} | ||
|
||
@Test | ||
void testSetSalary() { | ||
// Arrange | ||
Employee employee = new Employee(12345, "", "Engineering", 0); | ||
|
||
// Act | ||
employee.setSalary(75000); | ||
|
||
// Assert | ||
assertEquals(75000, employee.getSalary()); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.