Search in sources :

Example 1 with CinemaTheatre

use of com.management.entities.CinemaTheatre 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 CinemaTheatre

use of com.management.entities.CinemaTheatre 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 3 with CinemaTheatre

use of com.management.entities.CinemaTheatre in project Internet-Software-Architectures by zivko11.

the class CinemaTheatreManager method ReadAll.

public ArrayList<CinemaTheatreDTO> ReadAll() {
    ModelMapper mapper = new ModelMapper();
    ArrayList<CinemaTheatre> listEntities = (ArrayList<CinemaTheatre>) cinemaTheatreRepository.findAll();
    ArrayList<CinemaTheatreDTO> listDTO = new ArrayList<CinemaTheatreDTO>();
    for (CinemaTheatre tmp : listEntities) {
        try {
            CinemaTheatreDTO dto = mapper.map(tmp, CinemaTheatreDTO.class);
            listDTO.add(dto);
        } catch (Exception exc) {
            exc.printStackTrace();
            return null;
        }
    }
    return listDTO;
}
Also used : ArrayList(java.util.ArrayList) CinemaTheatreDTO(com.management.dto.CinemaTheatreDTO) CinemaTheatre(com.management.entities.CinemaTheatre) ModelMapper(org.modelmapper.ModelMapper)

Example 4 with CinemaTheatre

use of com.management.entities.CinemaTheatre in project Internet-Software-Architectures by zivko11.

the class CinemaTheatreManager method Read.

public CinemaTheatreDTO Read(int id) {
    ModelMapper mapper = new ModelMapper();
    CinemaTheatreDTO dto;
    try {
        CinemaTheatre cinemaTheatre = cinemaTheatreRepository.findOne(id);
        dto = mapper.map(cinemaTheatre, CinemaTheatreDTO.class);
    } catch (Exception exc) {
        exc.printStackTrace();
        return null;
    }
    return dto;
}
Also used : CinemaTheatreDTO(com.management.dto.CinemaTheatreDTO) CinemaTheatre(com.management.entities.CinemaTheatre) ModelMapper(org.modelmapper.ModelMapper)

Example 5 with CinemaTheatre

use of com.management.entities.CinemaTheatre in project Internet-Software-Architectures by zivko11.

the class CinemaTheatreManagerTests method AddingNewCinemaTheatre_ReturnsBoolean.

@Test
public void AddingNewCinemaTheatre_ReturnsBoolean() {
    // 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);
    // Act and assert
    Assert.assertNotNull(manager);
    Assert.assertTrue(manager.Create(dto));
    CinemaTheatre cinemaTheatre = cinemaTheatreRepository.findOne(0);
    Assert.assertEquals(dto.getCtAdress(), cinemaTheatre.getCtAdress());
    Assert.assertEquals(dto.getCtDescription(), cinemaTheatre.getCtDescription());
    Assert.assertEquals(dto.getCtName(), cinemaTheatre.getCtName());
    Assert.assertEquals(dto.getCtPhone(), cinemaTheatre.getCtPhone());
}
Also used : CinemaTheatreRepositoryFake(com.management.fake.CinemaTheatreRepositoryFake) CinemaTheatreDTO(com.management.dto.CinemaTheatreDTO) CinemaTheatre(com.management.entities.CinemaTheatre) Test(org.junit.Test)

Aggregations

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