use of com.management.entities.CinemaTheatre in project Internet-Software-Architectures by zivko11.
the class CinemaTheatreManagerTests method ReadAllCinemaTheatres_ReturnsAllCinemaTheatres.
@Test
public void ReadAllCinemaTheatres_ReturnsAllCinemaTheatres() {
// Arrange
Mockery mock = new Mockery();
cinemaTheatreRepository = mock.mock(CinemaTheatreRepository.class);
final ArrayList<CinemaTheatre> list = new ArrayList<CinemaTheatre>();
CinemaTheatre cinemaTheatre1 = new CinemaTheatre();
cinemaTheatre1.setCtAdress("Bulevar oslobodjenja 11");
cinemaTheatre1.setCtDescription("Ovo je opis.");
cinemaTheatre1.setCtName("Bioskop");
cinemaTheatre1.setCtPhone(1234567890);
cinemaTheatre1.setCtStateid("381");
CinemaTheatre cinemaTheatre2 = new CinemaTheatre();
cinemaTheatre2.setCtAdress("Bulevar oslobodjenja 9");
cinemaTheatre2.setCtDescription("Takodje opis.");
cinemaTheatre2.setCtName("Kazaliste");
cinemaTheatre2.setCtPhone(987654321);
cinemaTheatre2.setCtStateid("386");
list.add(cinemaTheatre1);
list.add(cinemaTheatre2);
mock.checking(new Expectations() {
{
oneOf(cinemaTheatreRepository).findAll();
will(returnValue(list));
}
});
CinemaTheatreManager manager = new CinemaTheatreManager(cinemaTheatreRepository);
// Act
ArrayList<CinemaTheatreDTO> listDTO = manager.ReadAll();
// Assert
Assert.assertNotNull(listDTO);
Assert.assertEquals(list.get(0).getCtAdress(), listDTO.get(0).getCtAdress());
Assert.assertEquals(list.get(0).getCtDescription(), listDTO.get(0).getCtDescription());
Assert.assertEquals(list.get(0).getCtName(), listDTO.get(0).getCtName());
Assert.assertEquals(list.get(0).getCtPhone(), listDTO.get(0).getCtPhone());
Assert.assertEquals(list.get(1).getCtAdress(), listDTO.get(1).getCtAdress());
Assert.assertEquals(list.get(1).getCtDescription(), listDTO.get(1).getCtDescription());
Assert.assertEquals(list.get(1).getCtName(), listDTO.get(1).getCtName());
Assert.assertEquals(list.get(1).getCtPhone(), listDTO.get(1).getCtPhone());
mock.assertIsSatisfied();
}
use of com.management.entities.CinemaTheatre in project Internet-Software-Architectures by zivko11.
the class CinemaTheatreManager method Create.
public boolean Create(CinemaTheatreDTO dto) {
ModelMapper mapper = new ModelMapper();
CinemaTheatre cinemaTheatre;
try {
cinemaTheatre = mapper.map(dto, CinemaTheatre.class);
} catch (Exception exc) {
exc.printStackTrace();
return false;
}
cinemaTheatreRepository.save(cinemaTheatre);
return true;
}
use of com.management.entities.CinemaTheatre in project Internet-Software-Architectures by zivko11.
the class CinemaTheatreManager method Update.
public boolean Update(CinemaTheatreDTO dto) {
ModelMapper mapper = new ModelMapper();
CinemaTheatre tmp;
try {
tmp = mapper.map(dto, CinemaTheatre.class);
} catch (Exception exc) {
exc.printStackTrace();
return false;
}
cinemaTheatreRepository.save(tmp);
return true;
}
use of com.management.entities.CinemaTheatre in project Internet-Software-Architectures by zivko11.
the class CinemaTheatreControllerTests method ReadAllCinemaTheatres_ReturnsOK.
@Test
public void ReadAllCinemaTheatres_ReturnsOK() {
// Arrange
Mockery mock = new Mockery();
cinemaTheatreRepository = mock.mock(CinemaTheatreRepository.class);
final ArrayList<CinemaTheatre> list = new ArrayList<CinemaTheatre>();
CinemaTheatre cinemaTheatre1 = new CinemaTheatre();
cinemaTheatre1.setCtAdress("Bulevar oslobodjenja 11");
cinemaTheatre1.setCtDescription("Ovo je opis.");
cinemaTheatre1.setCtName("Bioskop");
cinemaTheatre1.setCtPhone(1234567890);
cinemaTheatre1.setCtStateid("381");
CinemaTheatre cinemaTheatre2 = new CinemaTheatre();
cinemaTheatre2.setCtAdress("Bulevar oslobodjenja 9");
cinemaTheatre2.setCtDescription("Takodje opis.");
cinemaTheatre2.setCtName("Kazaliste");
cinemaTheatre2.setCtPhone(987654321);
cinemaTheatre2.setCtStateid("386");
list.add(cinemaTheatre1);
list.add(cinemaTheatre2);
mock.checking(new Expectations() {
{
oneOf(cinemaTheatreRepository).findAll();
will(returnValue(list));
}
});
CinemaTheatreManager manager = new CinemaTheatreManager(cinemaTheatreRepository);
CinemaTheatreController controller = new CinemaTheatreController(manager);
// Act
ResponseEntity<List<CinemaTheatreDTO>> response = controller.getCinemaTheatres();
ArrayList<CinemaTheatreDTO> listDTO = (ArrayList<CinemaTheatreDTO>) response.getBody();
// Assert
Assert.assertNotNull(controller);
Assert.assertEquals(response, new ResponseEntity<List<CinemaTheatreDTO>>(listDTO, HttpStatus.OK));
mock.assertIsSatisfied();
}
Aggregations