Search in sources :

Example 6 with CinemaTheatre

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

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

the class CinemaTheatreManager method Create.

public boolean Create(CinemaTheatreDTO dto) {
    ModelMapper mapper = new ModelMapper();
    CinemaTheatre cinemaTheatre;
    try {
        cinemaTheatre = mapper.map(dto, CinemaTheatre.class);
    } catch (Exception exc) {
        exc.printStackTrace();
        return false;
    }
    cinemaTheatreRepository.save(cinemaTheatre);
    return true;
}
Also used : CinemaTheatre(com.management.entities.CinemaTheatre) ModelMapper(org.modelmapper.ModelMapper)

Example 8 with CinemaTheatre

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

the class CinemaTheatreManager method Update.

public boolean Update(CinemaTheatreDTO dto) {
    ModelMapper mapper = new ModelMapper();
    CinemaTheatre tmp;
    try {
        tmp = mapper.map(dto, CinemaTheatre.class);
    } catch (Exception exc) {
        exc.printStackTrace();
        return false;
    }
    cinemaTheatreRepository.save(tmp);
    return true;
}
Also used : CinemaTheatre(com.management.entities.CinemaTheatre) ModelMapper(org.modelmapper.ModelMapper)

Example 9 with CinemaTheatre

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

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