Search in sources :

Example 6 with SeatRepository

use of com.management.repositories.SeatRepository 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();
}
Also used : Expectations(org.jmock.Expectations) SeatDTO(com.management.dto.SeatDTO) Seat(com.management.entities.Seat) SeatRepository(com.management.repositories.SeatRepository) Mockery(org.jmock.Mockery) Date(java.util.Date) SeatManager(com.management.managers.SeatManager) Test(org.junit.Test)

Aggregations

SeatRepository (com.management.repositories.SeatRepository)6 Expectations (org.jmock.Expectations)6 Mockery (org.jmock.Mockery)6 Test (org.junit.Test)6 SeatDTO (com.management.dto.SeatDTO)5 Seat (com.management.entities.Seat)4 Date (java.util.Date)4 SeatManager (com.management.managers.SeatManager)3 ArrayList (java.util.ArrayList)2 List (java.util.List)1