Search in sources :

Example 1 with CinemaTheatreManager

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

Example 2 with CinemaTheatreManager

use of com.management.managers.CinemaTheatreManager in project Internet-Software-Architectures by zivko11.

the class CinemaTheatreControllerTests method AddingNewCinemaTheatre_ReturnsOK.

@Test
public void AddingNewCinemaTheatre_ReturnsOK() {
    // 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);
    CinemaTheatreController controller = new CinemaTheatreController(manager);
    // Act and assert
    Assert.assertNotNull(controller);
    Assert.assertEquals(controller.addCinemaTheatre(dto), new ResponseEntity<CinemaTheatreDTO>(dto, HttpStatus.OK));
}
Also used : CinemaTheatreManager(com.management.managers.CinemaTheatreManager) CinemaTheatreRepositoryFake(com.management.fake.CinemaTheatreRepositoryFake) CinemaTheatreDTO(com.management.dto.CinemaTheatreDTO) Test(org.junit.Test)

Example 3 with CinemaTheatreManager

use of com.management.managers.CinemaTheatreManager in project Internet-Software-Architectures by zivko11.

the class CinemaTheatreControllerTests method DeletingCinemaTheatre_ReturnsOK.

@Test
public void DeletingCinemaTheatre_ReturnsOK() {
    // Arrange
    Mockery mock = new Mockery();
    cinemaTheatreRepository = mock.mock(CinemaTheatreRepository.class);
    // expectations
    mock.checking(new Expectations() {

        {
            oneOf(cinemaTheatreRepository).delete(1);
        }
    });
    // Act and assert
    CinemaTheatreManager manager = new CinemaTheatreManager(cinemaTheatreRepository);
    CinemaTheatreController controller = new CinemaTheatreController(manager);
    Assert.assertNotNull(controller);
    Assert.assertEquals(controller.deleteCinemaTheatre(1), new ResponseEntity<CinemaTheatreDTO>(HttpStatus.OK));
    mock.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) CinemaTheatreManager(com.management.managers.CinemaTheatreManager) CinemaTheatreRepository(com.management.repositories.CinemaTheatreRepository) CinemaTheatreDTO(com.management.dto.CinemaTheatreDTO) Mockery(org.jmock.Mockery) Test(org.junit.Test)

Example 4 with CinemaTheatreManager

use of com.management.managers.CinemaTheatreManager 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

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