use of com.management.repositories.EventRepository in project Internet-Software-Architectures by zivko11.
the class EventControllerTests method ReadAllEvents_ReturnsOK.
@Test
public void ReadAllEvents_ReturnsOK() {
// Arrange
Mockery mock = new Mockery();
eventRepository = mock.mock(EventRepository.class);
final ArrayList<Event> list = new ArrayList<Event>();
Event event1 = new Event();
event1.setEventDate(new Date());
Event event2 = new Event();
event2.setEventDate(new Date());
list.add(event1);
list.add(event2);
mock.checking(new Expectations() {
{
oneOf(eventRepository).findAll();
will(returnValue(list));
}
});
EventManager manager = new EventManager(eventRepository);
EventController controller = new EventController(manager);
// Act
ResponseEntity<List<EventDTO>> response = controller.getEvents();
ArrayList<EventDTO> listDTO = (ArrayList<EventDTO>) response.getBody();
// Assert
Assert.assertNotNull(controller);
Assert.assertEquals(response, new ResponseEntity<List<EventDTO>>(listDTO, HttpStatus.OK));
mock.assertIsSatisfied();
}
Aggregations