Skip to content

Commit ec089be

Browse files
BAEL-611: Minor formatting changes (eugenp#1534)
* Add NDC and JBoss Logging to the demo application * NDC for Log4j, Log4j2 and JBoss Logging * Simplify NDC example by making it a single operation instead of two * Make NDC example as RestController, Use JBoss Logging only as a logging bridge * Fix merge conflicts in pull request - log-mdc pom.xml updated * BAEL-445 Update to Spring security SpEL example * BAEL-445: Change tabs to spaces in the updated code * BAEL-245: Add Enum Serialization exmaple * BAEL-245: Remove the folder jackson/src/test/java/com/baeldung/jackson/dtos/withEnum as the example is not used anymore * Add more enum serialization examples to align with previous example and prevent build fail * BAEL-611: Minor formatting changes * BAEL-611: Update Test case method names
1 parent 47dfe6b commit ec089be

9 files changed

Lines changed: 46 additions & 39 deletions

File tree

‎jee7/pom.xml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
3030
<maven-war-plugin.version>2.6</maven-war-plugin.version>
31-
<mockito.version>1.10.19</mockito.version>
3231
</properties>
3332

3433
<prerequisites>

‎jee7/src/main/java/com/baeldung/jaxws/EmployeeService.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package com.baeldung.jaxws;
22

3-
import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
4-
import com.baeldung.jaxws.exception.EmployeeNotFound;
5-
import com.baeldung.jaxws.model.Employee;
3+
import java.util.List;
64

75
import javax.jws.WebMethod;
86
import javax.jws.WebService;
9-
import java.util.List;
7+
8+
import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
9+
import com.baeldung.jaxws.exception.EmployeeNotFound;
10+
import com.baeldung.jaxws.model.Employee;
1011

1112
@WebService
1213
public interface EmployeeService {

‎jee7/src/main/java/com/baeldung/jaxws/EmployeeServiceImpl.java‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package com.baeldung.jaxws;
22

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 java.util.List;
74

85
import javax.inject.Inject;
96
import javax.jws.WebMethod;
107
import javax.jws.WebService;
11-
import java.util.List;
8+
9+
import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
10+
import com.baeldung.jaxws.exception.EmployeeNotFound;
11+
import com.baeldung.jaxws.model.Employee;
12+
import com.baeldung.jaxws.repository.EmployeeRepository;
1213

1314
@WebService(serviceName = "EmployeeService", endpointInterface = "com.baeldung.jaxws.EmployeeService")
1415
public class EmployeeServiceImpl implements EmployeeService {

‎jee7/src/main/java/com/baeldung/jaxws/config/EmployeeServicePublisher.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.baeldung.jaxws.config;
22

3-
import com.baeldung.jaxws.EmployeeServiceImpl;
4-
53
import javax.xml.ws.Endpoint;
64

5+
import com.baeldung.jaxws.EmployeeServiceImpl;
6+
77
public class EmployeeServicePublisher {
88

99
public static void main(String[] args) {

‎jee7/src/main/java/com/baeldung/jaxws/exception/EmployeeAlreadyExists.java‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
package com.baeldung.jaxws.exception;
22

3-
import javax.xml.ws.WebFault;
43
import java.io.Serializable;
54

5+
import javax.xml.ws.WebFault;
6+
67
@WebFault
78
public class EmployeeAlreadyExists extends Exception implements Serializable {
89

10+
private static final long serialVersionUID = 1L;
11+
912
public EmployeeAlreadyExists() {
10-
super("This employee already exist");
13+
super("This employee already exists");
1114
}
1215

1316
public EmployeeAlreadyExists(String str) {

‎jee7/src/main/java/com/baeldung/jaxws/model/Employee.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.Serializable;
44

55
public class Employee implements Serializable {
6+
private static final long serialVersionUID = 1L;
67
private int id;
78
private String firstName;
89

‎jee7/src/main/java/com/baeldung/jaxws/repository/EmployeeRepository.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
package com.baeldung.jaxws.repository;
22

3+
import java.util.List;
4+
35
import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
46
import com.baeldung.jaxws.exception.EmployeeNotFound;
57
import com.baeldung.jaxws.model.Employee;
68

7-
import java.util.List;
8-
99
public interface EmployeeRepository {
1010

1111
List<Employee> getAllEmployees();

‎jee7/src/main/java/com/baeldung/jaxws/repository/EmployeeRepositoryImpl.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package com.baeldung.jaxws.repository;
22

3+
import java.util.ArrayList;
4+
import java.util.List;
5+
36
import com.baeldung.jaxws.exception.EmployeeAlreadyExists;
47
import com.baeldung.jaxws.exception.EmployeeNotFound;
58
import com.baeldung.jaxws.model.Employee;
69

7-
import java.util.ArrayList;
8-
import java.util.List;
9-
1010
public class EmployeeRepositoryImpl implements EmployeeRepository {
1111
private List<Employee> employeeList;
1212

‎jee7/src/test/java/com/baeldung/jaxws/EmployeeServiceLiveTest.java‎

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
package com.baeldung.jaxws;
22

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+
712
import org.jboss.arquillian.container.test.api.Deployment;
813
import org.jboss.arquillian.junit.Arquillian;
914
import org.jboss.arquillian.test.api.ArquillianResource;
@@ -14,13 +19,10 @@
1419
import org.junit.Test;
1520
import org.junit.runner.RunWith;
1621

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;
2426

2527
@RunWith(Arquillian.class)
2628
public class EmployeeServiceLiveTest {
@@ -54,54 +56,54 @@ public void setUp() {
5456
}
5557

5658
@Test
57-
public void givenGetAllEmployees_thenCorrectNumberOfEmployeesReturned() {
59+
public void givenEmployees_whenGetCount_thenCorrectNumberOfEmployeesReturned() {
5860
int employeeCount = employeeServiceProxy.countEmployees();
5961
List<Employee> employeeList = employeeServiceProxy.getAllEmployees();
6062
assertEquals(employeeList.size(), employeeCount);
6163
}
6264

6365
@Test
64-
public void givenEmployeeId_whenEmployeeExists_thenCorrectEmployeeReturned() throws EmployeeNotFound {
66+
public void givenEmployees_whenGetAvailableEmployee_thenCorrectEmployeeReturned() throws EmployeeNotFound {
6567
Employee employee = employeeServiceProxy.getEmployee(2);
6668
assertEquals(employee.getFirstName(), "Jack");
6769
}
6870

6971
@Test(expected = EmployeeNotFound.class)
70-
public void givenEmployeeId_whenEmployeeNotExists_thenEmployeeNotFoundExceptionReturned() throws EmployeeNotFound {
72+
public void givenEmployees_whenGetNonAvailableEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound {
7173
employeeServiceProxy.getEmployee(20);
7274
}
7375

7476
@Test
75-
public void givenAddEmployee_whenEmployeeDoesntAlreadyExist_thenEmployeeCountIncreased() throws EmployeeAlreadyExists {
77+
public void givenEmployees_whenAddNewEmployee_thenEmployeeCountIncreased() throws EmployeeAlreadyExists {
7678
int employeeCount = employeeServiceProxy.countEmployees();
7779
employeeServiceProxy.addEmployee(4, "Anna");
7880
assertEquals(employeeServiceProxy.countEmployees(), employeeCount + 1);
7981
}
8082

8183
@Test(expected = EmployeeAlreadyExists.class)
82-
public void givenAddEmployee_whenEmployeeAlreadyExist_thenEmployeeAlreadyExistsExceptionReturned() throws EmployeeAlreadyExists {
84+
public void givenEmployees_whenAddAlreadyExistingEmployee_thenEmployeeAlreadyExistsException() throws EmployeeAlreadyExists {
8385
employeeServiceProxy.addEmployee(1, "Anna");
8486
}
8587

8688
@Test
87-
public void givenUpdateEmployee_whenEmployeeExists_thenUpdatedEmployeeReturned() throws EmployeeNotFound {
89+
public void givenEmployees_whenUpdateExistingEmployee_thenUpdatedEmployeeReturned() throws EmployeeNotFound {
8890
Employee updated = employeeServiceProxy.updateEmployee(1, "Joan");
8991
assertEquals(updated.getFirstName(), "Joan");
9092
}
9193

9294
@Test(expected = EmployeeNotFound.class)
93-
public void givenUpdateEmployee_whenEmployeeNotExists_thenUpdatedEmployeeReturned() throws EmployeeNotFound {
95+
public void givenEmployees_whenUpdateNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound {
9496
employeeServiceProxy.updateEmployee(20, "Joan");
9597
}
9698

9799
@Test
98-
public void givenDeleteEmployee_whenEmployeeExists_thenCorrectStatusReturned() throws EmployeeNotFound {
100+
public void givenEmployees_whenDeleteExistingEmployee_thenSuccessReturned() throws EmployeeNotFound {
99101
boolean deleteEmployee = employeeServiceProxy.deleteEmployee(3);
100102
assertEquals(deleteEmployee, true);
101103
}
102104

103105
@Test(expected = EmployeeNotFound.class)
104-
public void givenDeleteEmployee_whenEmployeeNotExists_thenEmployeeNotFoundExceptionReturned() throws EmployeeNotFound {
106+
public void givenEmployee_whenDeleteNonExistingEmployee_thenEmployeeNotFoundException() throws EmployeeNotFound {
105107
employeeServiceProxy.deleteEmployee(20);
106108
}
107109

0 commit comments

Comments
 (0)