Question: 7 8 9 10 E 11 } 12 13 14 15 16 17 } 18 19 + 1 72 3 4 5 55 6



7 8 9 10 E 11 } 12 13 14 15 16 17 } 18 19 + 1 72 3 4 5 55 6 Employee.java EmployeeTest.java public class Employee { 3 usages private String name; 3 usages private int salary; 3 usages private String position; public Employee() { public Employee(String name, int salary, String position) { this.name = name; this.salary = salary; position; this.position = public String getName() { return name; 22 23 + public void setName(String name) { this.name = name; } 26 27 + public int getSalary() { return salary; } 30 31 + public void setSalary(int salary) { this.salary = salary; } 34 35 + public String getPosition() { return position; } 38 39 + public void setPosition(String position) { this.position = position; } 42 43 44 45 46 47 H 48 49 50 H 51 52 A } 53 54 public String salaryGradeType(int x){ if (x >= 10000 && x < 20000){ return "C"; } if (x >= 20000 && x < 40000) { return "B"; } if (x > 40000) { return "A"; return "Error"; 55 56 } 57 58 59 60 61 } 62 Employee.java EmployeeTest.java x 1 import org.junit.jupiter.api.*; 2 3 public class EmployeeTest { 4 5 6 7 8 11 12 13 14 System.out.println(" 15 16 private Employee emp; @BeforeEach public void create New Emp() { this.emp = new Employee("Jm", 10000,"Manager"); } @Before All public static void setUp() { System.out.println("Connecting to DataBase"); System.out.println("- "); 17 18 } 19 20 21 24 25 @AfterEach public void clean Employee() { this.emp = new Employee(); } @AfterAll public static void tearDown() { System.out.println(" "); System.out.println("Disconnecting from DataBase"); System.out.println(" "); 26 27 28 29 30 31 } 32 33 34 35 36 37 + 40 41 42 43 + 46 47 48 49 + 52 53 54 A 55 58 59 } 60 @Test @DisplayName("Salary Grade A") public void test1() { System.out.println(this.emp.getName()); } @Test @DisplayName("Salary Grade B") public void test2() { System.out.println(emp.getPosition()); } @Test @DisplayName("Salary Grade C") public void test3() { System.out.println(emp.getPosition()); } @Test @DisplayName("Salary Grade Error") public void test4() { System.out.println(emp.getPosition()); } Create a new Employee class with the following attributes and behaviors. 1. Name 2. Salary 3. Position 4. get salary grade For the salary grade behavior it will return a string/char of A, B, or C. If the salary is greater than or equal to 10,000 and less than 20,000 then return C, for salary greater than or equal to 20,000 and less than 40,000 then return B. For a salary Greater than or equal to 40,000 return A. After creating the employee class create a new test class and create tests with the following expected results. 1. Salary grade will be A 2. Salary Grade will be B 3. Salary Grade will be C 4. Salary Grade will return an error. Use a BeforeEach annotation to create your new Employee object and the BeforeAll and AfterAll annotations to Simulate connecting to the database.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
