Upgrade to Spring Boot + Spring Data.
Update this repository to use modern Spring practices including: * Spring Boot * Spring Data JPA * Spring Framework's Java configuration
This commit is contained in:
@@ -16,56 +16,58 @@
|
||||
|
||||
package com.mycompany.hr.ws;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.Calendar;
|
||||
|
||||
import com.mycompany.hr.service.HumanResourceService;
|
||||
import org.jdom2.Document;
|
||||
import org.jdom2.input.SAXBuilder;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.easymock.EasyMock.*;
|
||||
import com.mycompany.hr.service.HumanResourceService;
|
||||
|
||||
public class HolidayEndpointTest {
|
||||
|
||||
private Document holidayRequest;
|
||||
private Document holidayRequest;
|
||||
|
||||
private HolidayEndpoint endpoint;
|
||||
private HolidayEndpoint endpoint;
|
||||
|
||||
private HumanResourceService serviceMock;
|
||||
private HumanResourceService serviceMock;
|
||||
|
||||
private Calendar startCalendar;
|
||||
private Calendar startCalendar;
|
||||
|
||||
private Calendar endCalendar;
|
||||
private Calendar endCalendar;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
serviceMock = createMock(HumanResourceService.class);
|
||||
SAXBuilder builder = new SAXBuilder();
|
||||
InputStream is = getClass().getResourceAsStream("holidayRequest.xml");
|
||||
try {
|
||||
holidayRequest = builder.build(is);
|
||||
}
|
||||
finally {
|
||||
is.close();
|
||||
}
|
||||
endpoint = new HolidayEndpoint(serviceMock);
|
||||
startCalendar = Calendar.getInstance();
|
||||
startCalendar.clear();
|
||||
startCalendar.set(2006, Calendar.JULY, 3);
|
||||
endCalendar = Calendar.getInstance();
|
||||
endCalendar.clear();
|
||||
endCalendar.set(2006, Calendar.JULY, 7);
|
||||
}
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
|
||||
@Test
|
||||
public void handleHolidayRequest() throws Exception {
|
||||
serviceMock.bookHoliday(startCalendar.getTime(), endCalendar.getTime(), "John Doe");
|
||||
replay(serviceMock);
|
||||
endpoint.handleHolidayRequest(holidayRequest.getRootElement());
|
||||
verify(serviceMock);
|
||||
}
|
||||
serviceMock = mock(HumanResourceService.class);
|
||||
SAXBuilder builder = new SAXBuilder();
|
||||
InputStream is = getClass().getResourceAsStream("holidayRequest.xml");
|
||||
try {
|
||||
holidayRequest = builder.build(is);
|
||||
} finally {
|
||||
is.close();
|
||||
}
|
||||
endpoint = new HolidayEndpoint(serviceMock);
|
||||
startCalendar = Calendar.getInstance();
|
||||
startCalendar.clear();
|
||||
startCalendar.set(2006, Calendar.JULY, 3);
|
||||
endCalendar = Calendar.getInstance();
|
||||
endCalendar.clear();
|
||||
endCalendar.set(2006, Calendar.JULY, 7);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleHolidayRequest() throws Exception {
|
||||
|
||||
serviceMock.bookHoliday(startCalendar.getTime(), endCalendar.getTime(), "John Doe");
|
||||
|
||||
endpoint.handleHolidayRequest(holidayRequest.getRootElement());
|
||||
|
||||
verify(serviceMock);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user