use of com.management.managers.SeatManager in project Internet-Software-Architectures by zivko11.
the class SeatControllerTests method ReadAllSeats_ReturnsOK.
@Test
public void ReadAllSeats_ReturnsOK() {
// Arrange
Mockery mock = new Mockery();
seatRepository = mock.mock(SeatRepository.class);
final ArrayList<Seat> list = new ArrayList<Seat>();
Seat seat1 = new Seat();
seat1.setSeatModified(new Date());
seat1.setSeatTaken(true);
Seat seat2 = new Seat();
seat2.setSeatModified(new Date());
seat2.setSeatTaken(false);
list.add(seat1);
list.add(seat2);
mock.checking(new Expectations() {
{
oneOf(seatRepository).findAll();
will(returnValue(list));
}
});
SeatManager manager = new SeatManager(seatRepository);
SeatController controller = new SeatController(manager);
// Act
ResponseEntity<List<SeatDTO>> response = controller.getSeats();
ArrayList<SeatDTO> listDTO = (ArrayList<SeatDTO>) response.getBody();
// Assert
Assert.assertNotNull(controller);
Assert.assertEquals(response, new ResponseEntity<List<SeatDTO>>(listDTO, HttpStatus.OK));
mock.assertIsSatisfied();
}
use of com.management.managers.SeatManager in project Internet-Software-Architectures by zivko11.
the class SeatControllerTests method DeletingSeat_ReturnsOK.
@Test
public void DeletingSeat_ReturnsOK() {
// Arrange
Mockery mock = new Mockery();
seatRepository = mock.mock(SeatRepository.class);
// expectations
mock.checking(new Expectations() {
{
oneOf(seatRepository).delete(1);
}
});
// Act and assert
SeatManager manager = new SeatManager(seatRepository);
SeatController controller = new SeatController(manager);
Assert.assertNotNull(controller);
Assert.assertEquals(controller.deleteSeat(1), new ResponseEntity<SeatDTO>(HttpStatus.OK));
mock.assertIsSatisfied();
}
use of com.management.managers.SeatManager in project Internet-Software-Architectures by zivko11.
the class SeatControllerTests method ReadSeat_ReturnsOK.
@Test
public void ReadSeat_ReturnsOK() {
// Arrange
Mockery mock = new Mockery();
seatRepository = mock.mock(SeatRepository.class);
final Seat seat = new Seat();
seat.setSeatModified(new Date());
seat.setSeatTaken(true);
mock.checking(new Expectations() {
{
oneOf(seatRepository).findOne(1);
will(returnValue(seat));
}
});
SeatManager manager = new SeatManager(seatRepository);
SeatController controller = new SeatController(manager);
// Act
ResponseEntity<SeatDTO> response = controller.getSeat(1);
SeatDTO dto = response.getBody();
// Assert
Assert.assertNotNull(controller);
Assert.assertEquals(response, new ResponseEntity<SeatDTO>(dto, HttpStatus.OK));
mock.assertIsSatisfied();
}
use of com.management.managers.SeatManager in project Internet-Software-Architectures by zivko11.
the class SeatControllerTests method AddingNewSeat_ReturnsOK.
@Test
public void AddingNewSeat_ReturnsOK() {
// Arrange
seatRepository = new SeatRepositoryFake();
SeatDTO dto = new SeatDTO();
dto.setSeatModified(new Date());
dto.setSeatTaken(true);
SeatManager manager = new SeatManager(seatRepository);
SeatController controller = new SeatController(manager);
// Act and assert
Assert.assertNotNull(controller);
Assert.assertEquals(controller.addSeat(dto), new ResponseEntity<SeatDTO>(dto, HttpStatus.OK));
}
Aggregations