use of com.management.repositories.CinemaTheatreRepository 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