use of com.management.dto.CinemaTheatreDTO in project Internet-Software-Architectures by zivko11.
the class CinemaTheatreControllerTests method ReadCinemaTheatre_ReturnsOK.
@Test
public void ReadCinemaTheatre_ReturnsOK() {
// Arrange
Mockery mock = new Mockery();
cinemaTheatreRepository = mock.mock(CinemaTheatreRepository.class);
final CinemaTheatre cinemaTheatre = new CinemaTheatre();
cinemaTheatre.setCtAdress("Bulevar oslobodjenja 11");
cinemaTheatre.setCtDescription("Ovo je opis.");
cinemaTheatre.setCtName("Bioskop");
cinemaTheatre.setCtPhone(1234567890);
cinemaTheatre.setCtStateid("381");
mock.checking(new Expectations() {
{
oneOf(cinemaTheatreRepository).findOne(1);
will(returnValue(cinemaTheatre));
}
});
CinemaTheatreManager manager = new CinemaTheatreManager(cinemaTheatreRepository);
CinemaTheatreController controller = new CinemaTheatreController(manager);
// Act
ResponseEntity<CinemaTheatreDTO> response = controller.getCinemaTheatre(1);
CinemaTheatreDTO dto = response.getBody();
// Assert
Assert.assertNotNull(controller);
Assert.assertEquals(response, new ResponseEntity<CinemaTheatreDTO>(dto, HttpStatus.OK));
mock.assertIsSatisfied();
}
use of com.management.dto.CinemaTheatreDTO in project Internet-Software-Architectures by zivko11.
the class CinemaTheatreManagerTests method ReadCinemaTheatre_ReturnsUser.
@Test
public void ReadCinemaTheatre_ReturnsUser() {
// Arrange
Mockery mock = new Mockery();
cinemaTheatreRepository = mock.mock(CinemaTheatreRepository.class);
final CinemaTheatre cinemaTheatre = new CinemaTheatre();
cinemaTheatre.setCtAdress("Bulevar oslobodjenja 11");
cinemaTheatre.setCtDescription("Ovo je opis.");
cinemaTheatre.setCtName("Bioskop");
cinemaTheatre.setCtPhone(1234567890);
cinemaTheatre.setCtStateid("381");
mock.checking(new Expectations() {
{
oneOf(cinemaTheatreRepository).findOne(1);
will(returnValue(cinemaTheatre));
}
});
CinemaTheatreManager manager = new CinemaTheatreManager(cinemaTheatreRepository);
// Act
CinemaTheatreDTO dto = manager.Read(1);
// Assert
Assert.assertNotNull(dto);
Assert.assertEquals(dto.getCtAdress(), cinemaTheatre.getCtAdress());
Assert.assertEquals(dto.getCtDescription(), cinemaTheatre.getCtDescription());
Assert.assertEquals(dto.getCtName(), cinemaTheatre.getCtName());
Assert.assertEquals(dto.getCtPhone(), cinemaTheatre.getCtPhone());
mock.assertIsSatisfied();
}
use of com.management.dto.CinemaTheatreDTO in project Internet-Software-Architectures by zivko11.
the class CinemaTheatreManager method ReadAll.
public ArrayList<CinemaTheatreDTO> ReadAll() {
ModelMapper mapper = new ModelMapper();
ArrayList<CinemaTheatre> listEntities = (ArrayList<CinemaTheatre>) cinemaTheatreRepository.findAll();
ArrayList<CinemaTheatreDTO> listDTO = new ArrayList<CinemaTheatreDTO>();
for (CinemaTheatre tmp : listEntities) {
try {
CinemaTheatreDTO dto = mapper.map(tmp, CinemaTheatreDTO.class);
listDTO.add(dto);
} catch (Exception exc) {
exc.printStackTrace();
return null;
}
}
return listDTO;
}
use of com.management.dto.CinemaTheatreDTO in project Internet-Software-Architectures by zivko11.
the class CinemaTheatreManager method Read.
public CinemaTheatreDTO Read(int id) {
ModelMapper mapper = new ModelMapper();
CinemaTheatreDTO dto;
try {
CinemaTheatre cinemaTheatre = cinemaTheatreRepository.findOne(id);
dto = mapper.map(cinemaTheatre, CinemaTheatreDTO.class);
} catch (Exception exc) {
exc.printStackTrace();
return null;
}
return dto;
}
use of com.management.dto.CinemaTheatreDTO in project Internet-Software-Architectures by zivko11.
the class CinemaTheatreManagerTests method AddingNewCinemaTheatre_ReturnsBoolean.
@Test
public void AddingNewCinemaTheatre_ReturnsBoolean() {
// Arrange
cinemaTheatreRepository = new CinemaTheatreRepositoryFake();
CinemaTheatreDTO dto = new CinemaTheatreDTO();
dto.setCtAdress("Bulevar oslobodjenja 11");
dto.setCtDescription("Ovo je opis.");
dto.setCtName("Bioskop");
dto.setCtPhone(1234567890);
CinemaTheatreManager manager = new CinemaTheatreManager(cinemaTheatreRepository);
// Act and assert
Assert.assertNotNull(manager);
Assert.assertTrue(manager.Create(dto));
CinemaTheatre cinemaTheatre = cinemaTheatreRepository.findOne(0);
Assert.assertEquals(dto.getCtAdress(), cinemaTheatre.getCtAdress());
Assert.assertEquals(dto.getCtDescription(), cinemaTheatre.getCtDescription());
Assert.assertEquals(dto.getCtName(), cinemaTheatre.getCtName());
Assert.assertEquals(dto.getCtPhone(), cinemaTheatre.getCtPhone());
}
Aggregations