Search in sources :

Example 6 with SeatDTO

use of com.management.dto.SeatDTO in project Internet-Software-Architectures by zivko11.

the class SeatManager method ReadAll.

public ArrayList<SeatDTO> ReadAll() {
    ModelMapper mapper = new ModelMapper();
    ArrayList<Seat> listEntities = (ArrayList<Seat>) seatRepository.findAll();
    ArrayList<SeatDTO> listDTO = new ArrayList<SeatDTO>();
    for (Seat tmp : listEntities) {
        try {
            SeatDTO dto = mapper.map(tmp, SeatDTO.class);
            listDTO.add(dto);
        } catch (Exception exc) {
            exc.printStackTrace();
            return null;
        }
    }
    return listDTO;
}
Also used : SeatDTO(com.management.dto.SeatDTO) Seat(com.management.entities.Seat) ArrayList(java.util.ArrayList) ModelMapper(org.modelmapper.ModelMapper)

Example 7 with SeatDTO

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

Example 8 with SeatDTO

use of com.management.dto.SeatDTO 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)

Example 9 with SeatDTO

use of com.management.dto.SeatDTO 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));
}
Also used : SeatDTO(com.management.dto.SeatDTO) SeatRepositoryFake(com.management.fake.SeatRepositoryFake) Date(java.util.Date) SeatManager(com.management.managers.SeatManager) Test(org.junit.Test)

Aggregations

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