|
1 | 1 | package com.baeldung.jaxws; |
2 | 2 |
|
3 | | -import com.baeldung.jaxws.exception.EmployeeAlreadyExists; |
4 | | -import com.baeldung.jaxws.exception.EmployeeNotFound; |
5 | | -import com.baeldung.jaxws.model.Employee; |
6 | | -import com.baeldung.jaxws.repository.EmployeeRepository; |
| 3 | +import static org.junit.Assert.assertEquals; |
| 4 | + |
| 5 | +import java.net.MalformedURLException; |
| 6 | +import java.net.URL; |
| 7 | +import java.util.List; |
| 8 | + |
| 9 | +import javax.xml.namespace.QName; |
| 10 | +import javax.xml.ws.Service; |
| 11 | + |
7 | 12 | import org.jboss.arquillian.container.test.api.Deployment; |
8 | 13 | import org.jboss.arquillian.junit.Arquillian; |
9 | 14 | import org.jboss.arquillian.test.api.ArquillianResource; |
|
14 | 19 | import org.junit.Test; |
15 | 20 | import org.junit.runner.RunWith; |
16 | 21 |
|
17 | | -import javax.xml.namespace.QName; |
18 | | -import javax.xml.ws.Service; |
19 | | -import java.net.MalformedURLException; |
20 | | -import java.net.URL; |
21 | | -import java.util.List; |
22 | | - |
23 | | -import static org.junit.Assert.assertEquals; |
| 22 | +import com.baeldung.jaxws.exception.EmployeeAlreadyExists; |
| 23 | +import com.baeldung.jaxws.exception.EmployeeNotFound; |
| 24 | +import com.baeldung.jaxws.model.Employee; |
| 25 | +import com.baeldung.jaxws.repository.EmployeeRepository; |
24 | 26 |
|
25 | 27 | @RunWith(Arquillian.class) |
26 | 28 | public class EmployeeServiceLiveTest { |
@@ -54,54 +56,54 @@ public void setUp() { |
54 | 56 | } |
55 | 57 |
|
56 | 58 | @Test |
57 | | - public void givenGetAllEmployees_thenCorrectNumberOfEmployeesReturned() { |
| 59 | + public void givenEmployees_whenGetCount_thenCorrectNumberOfEmployeesReturned() { |
58 | 60 | int employeeCount = employeeServiceProxy.countEmployees(); |
59 | 61 | List<Employee> employeeList = employeeServiceProxy.getAllEmployees(); |
60 | 62 | assertEquals(employeeList.size(), employeeCount); |
61 | 63 | } |
62 | 64 |
|
63 | 65 | @Test |
64 | | - public void givenEmployeeId_whenEmployeeExists_thenCorrectEmployeeReturned() throws EmployeeNotFound { |
| 66 | + public void givenEmployees_whenGetAvailableEmployee_thenCorrectEmployeeReturned() throws EmployeeNotFound { |
65 | 67 | Employee employee = employeeServiceProxy.getEmployee(2); |
66 | 68 | assertEquals(employee.getFirstName(), "Jack"); |
67 | 69 | } |
68 | 70 |
|
69 | 71 | @Test(expected = EmployeeNotFound.class) |
70 | | - public void givenEmployeeId_whenEmployeeNotExists_thenEmployeeNotFoundExceptionReturned() throws EmployeeNotFound { |
| 72 | + public void givenEmployees_whenGetNonAvailableEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound { |
71 | 73 | employeeServiceProxy.getEmployee(20); |
72 | 74 | } |
73 | 75 |
|
74 | 76 | @Test |
75 | | - public void givenAddEmployee_whenEmployeeDoesntAlreadyExist_thenEmployeeCountIncreased() throws EmployeeAlreadyExists { |
| 77 | + public void givenEmployees_whenAddNewEmployee_thenEmployeeCountIncreased() throws EmployeeAlreadyExists { |
76 | 78 | int employeeCount = employeeServiceProxy.countEmployees(); |
77 | 79 | employeeServiceProxy.addEmployee(4, "Anna"); |
78 | 80 | assertEquals(employeeServiceProxy.countEmployees(), employeeCount + 1); |
79 | 81 | } |
80 | 82 |
|
81 | 83 | @Test(expected = EmployeeAlreadyExists.class) |
82 | | - public void givenAddEmployee_whenEmployeeAlreadyExist_thenEmployeeAlreadyExistsExceptionReturned() throws EmployeeAlreadyExists { |
| 84 | + public void givenEmployees_whenAddAlreadyExistingEmployee_thenEmployeeAlreadyExistsException() throws EmployeeAlreadyExists { |
83 | 85 | employeeServiceProxy.addEmployee(1, "Anna"); |
84 | 86 | } |
85 | 87 |
|
86 | 88 | @Test |
87 | | - public void givenUpdateEmployee_whenEmployeeExists_thenUpdatedEmployeeReturned() throws EmployeeNotFound { |
| 89 | + public void givenEmployees_whenUpdateExistingEmployee_thenUpdatedEmployeeReturned() throws EmployeeNotFound { |
88 | 90 | Employee updated = employeeServiceProxy.updateEmployee(1, "Joan"); |
89 | 91 | assertEquals(updated.getFirstName(), "Joan"); |
90 | 92 | } |
91 | 93 |
|
92 | 94 | @Test(expected = EmployeeNotFound.class) |
93 | | - public void givenUpdateEmployee_whenEmployeeNotExists_thenUpdatedEmployeeReturned() throws EmployeeNotFound { |
| 95 | + public void givenEmployees_whenUpdateNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound { |
94 | 96 | employeeServiceProxy.updateEmployee(20, "Joan"); |
95 | 97 | } |
96 | 98 |
|
97 | 99 | @Test |
98 | | - public void givenDeleteEmployee_whenEmployeeExists_thenCorrectStatusReturned() throws EmployeeNotFound { |
| 100 | + public void givenEmployees_whenDeleteExistingEmployee_thenSuccessReturned() throws EmployeeNotFound { |
99 | 101 | boolean deleteEmployee = employeeServiceProxy.deleteEmployee(3); |
100 | 102 | assertEquals(deleteEmployee, true); |
101 | 103 | } |
102 | 104 |
|
103 | 105 | @Test(expected = EmployeeNotFound.class) |
104 | | - public void givenDeleteEmployee_whenEmployeeNotExists_thenEmployeeNotFoundExceptionReturned() throws EmployeeNotFound { |
| 106 | + public void givenEmployee_whenDeleteNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound { |
105 | 107 | employeeServiceProxy.deleteEmployee(20); |
106 | 108 | } |
107 | 109 |
|
|
0 commit comments