-
Notifications
You must be signed in to change notification settings - Fork 25
Feat: Adds for Lesson15.java Files for Nile Jackson #497
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
14 commits
Select commit
Hold shift + click to select a range
b7b37d5
Feat: Adds for Lesson15
nilejack 97b4c95
Merge branch 'main' into NileJacksonLesson_15
nilejack 1472f21
Feat: Changes to Lesson15.java files
nilejack 3f223fc
Feat: spotlessApply fix
nilejack e853c63
Feat: Fix
nilejack fb48cff
Feat: Fix for Nile Jackson's Employee.java file (correction to getDet…
nilejack e66c811
Feat: spotlessApply fix
nilejack 34ce2a7
Feat: spotlessApply fix
nilejack 295237a
Feat: spotlessApply fix
nilejack 9a1747a
Fix: spotlessApply Fix
nilejack 4b88f4a
Fix: spotlessApply fix
nilejack ed7179a
Fix: spotlessApply fix
nilejack cb39e2c
Feat: fixes to EmployeeManagerTest.java
nilejack 5e56a3f
Feat: fix
nilejack 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should be no changes to this file. |
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
80 changes: 80 additions & 0 deletions
80
lesson_15/tdd/tdd_app/src/test/java/com/codedifferently/lesson15/Employee.Test.java
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File should be named |
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,80 @@ | ||
package com.codedifferently.lesson15; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class EmployeeTest { | ||
|
||
Employee employee; | ||
|
||
// Set up | ||
@BeforeEach | ||
void setUp() { | ||
employee = new Employee(7, "Nile", "SWE", 65000.00); | ||
} | ||
|
||
@Test | ||
public void testGetId() { | ||
int actualId = employee.getId(); | ||
int expectedId = 7; | ||
assertEquals(expectedId, actualId); | ||
} | ||
|
||
@Test | ||
public void testSetID() { | ||
int expectedSetId = 0; | ||
employee.setId(expectedSetId); | ||
assertEquals(expectedSetId, employee.getId()); | ||
} | ||
|
||
@Test | ||
public void testGetName() { | ||
String expectedName = "Nile"; | ||
String actualName = employee.getName(); | ||
assertEquals(expectedName, actualName); | ||
} | ||
|
||
@Test | ||
public void testSetName() { | ||
String expectedSetName = "Nile"; | ||
employee.setName(expectedSetName); | ||
assertEquals(expectedSetName, employee.getName()); | ||
} | ||
|
||
@Test | ||
public void testGetDepartment() { | ||
String expectedDepartment = "SWE"; | ||
String actualDepartment = employee.getDepartment(); | ||
assertEquals(expectedDepartment, actualDepartment); | ||
} | ||
|
||
@Test | ||
public void testSetDepartment() { | ||
String expectedSetDepartment = "Tech"; | ||
employee.setDepartment(expectedSetDepartment); | ||
assertEquals(expectedSetDepartment, employee.getDepartment()); | ||
} | ||
|
||
@Test | ||
public void testGetSalary() { | ||
double expectedSalary = 65000.00; | ||
double actualSalary = employee.getSalary(); | ||
assertEquals(expectedSalary, actualSalary); | ||
} | ||
|
||
@Test | ||
public void testSetSalary() { | ||
double expectedSetSalary = 100000.00; | ||
employee.setSalary(expectedSetSalary); | ||
assertEquals(expectedSetSalary, employee.getSalary()); | ||
} | ||
|
||
@Test | ||
public void testGetDetails() { | ||
String actualDetails = employee.getDetails(); | ||
String expectedDetails = "id: 7 name: Nile department: SWE salary: 65000.0"; | ||
assertEquals(expectedDetails, actualDetails); | ||
} | ||
} |
79 changes: 79 additions & 0 deletions
79
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,79 @@ | ||
package com.codedifferently.lesson15; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class EmployeeManagerTest { | ||
private EmployeeManager employeeManager; | ||
private Map<Integer, Employee> employees; | ||
private Employee employee1; | ||
private Employee employee2; | ||
|
||
@BeforeEach | ||
public void setup() { | ||
employees = new HashMap<>(); | ||
employee1 = new Employee(1, "Nile", "SWE", 65000.00); | ||
employee2 = new Employee(2, "Chino", "Marketing", 70000.00); | ||
|
||
employeeManager = new EmployeeManager(); | ||
employeeManager.setEmployees(employees); | ||
employeeManager.addEmployee(employee1); | ||
employeeManager.addEmployee(employee2); | ||
} | ||
|
||
@Test | ||
public void testEmployeeManagement() {} | ||
|
||
@Test | ||
public void addEmployee() { | ||
assertThat(employees).hasSize(2); | ||
} | ||
|
||
@Test | ||
public void getEmployee() { | ||
Employee retrievedEmployee = employeeManager.getEmployee(2); | ||
assertThat(retrievedEmployee.getName()).isEqualTo("Chino"); | ||
} | ||
|
||
@Test | ||
public void updateEmployee() { | ||
employee1.setSalary(70000.00); | ||
employeeManager.updateEmployee(employee1); | ||
|
||
Employee updatedEmployee = employeeManager.getEmployee(1); | ||
assertThat(updatedEmployee.getSalary()).isEqualTo(70000.00); | ||
} | ||
|
||
@Test | ||
public void getEmployeeCount() { | ||
int count = employeeManager.getEmployeeCount(); | ||
assertEquals(2, count); | ||
} | ||
|
||
@Test | ||
public void getEmployees() { | ||
Map<Integer, Employee> employeeMap = employeeManager.getEmployees(); | ||
assertThat(employeeMap.size()).isEqualTo(2); | ||
} | ||
|
||
@Test | ||
public void setEmployees() { | ||
Map<Integer, Employee> newEmployees = new HashMap<>(); | ||
newEmployees.put(3, new Employee(3, "Charlie", "HR", 75000.00)); | ||
employeeManager.setEmployees(newEmployees); | ||
|
||
assertThat(employeeManager.getEmployees().size()).isEqualTo(1); | ||
} | ||
|
||
@Test | ||
public void testGetDetails() { | ||
String actualDetails = employee1.getDetails(); | ||
String expectedDetails = "id: 1 name: Nile department: SWE salary: 65000.0"; | ||
assertEquals(expectedDetails, actualDetails); | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only needed to implement the
getDetails
method.