Search in sources :

Example 6 with CinemaTheatreRepository

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();
}
Also used : Expectations(org.jmock.Expectations) CinemaTheatreManager(com.management.managers.CinemaTheatreManager) CinemaTheatreRepository(com.management.repositories.CinemaTheatreRepository) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) CinemaTheatreDTO(com.management.dto.CinemaTheatreDTO) Mockery(org.jmock.Mockery) CinemaTheatre(com.management.entities.CinemaTheatre) Test(org.junit.Test)

Aggregations

CinemaTheatreRepository (com.management.repositories.CinemaTheatreRepository)6 Expectations (org.jmock.Expectations)6 Mockery (org.jmock.Mockery)6 Test (org.junit.Test)6 CinemaTheatreDTO (com.management.dto.CinemaTheatreDTO)5 CinemaTheatre (com.management.entities.CinemaTheatre)4 CinemaTheatreManager (com.management.managers.CinemaTheatreManager)3 ArrayList (java.util.ArrayList)2 List (java.util.List)1