Search in sources :

Example 1 with CinemaTheatreRepository

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

use of com.management.repositories.CinemaTheatreRepository in project Internet-Software-Architectures by zivko11.

the class CinemaTheatreManagerTests method DeletingCinemaTheatre_ReturnsBoolean.

@Test
public void DeletingCinemaTheatre_ReturnsBoolean() {
    // 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);
    Assert.assertNotNull(manager);
    Assert.assertTrue(manager.Delete(1));
    mock.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) CinemaTheatreRepository(com.management.repositories.CinemaTheatreRepository) Mockery(org.jmock.Mockery) Test(org.junit.Test)

Example 3 with CinemaTheatreRepository

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

Example 4 with CinemaTheatreRepository

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

Example 5 with CinemaTheatreRepository

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

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