Search in sources :

Example 6 with ActorPerformancesDTO

use of com.management.dto.ActorPerformancesDTO in project Internet-Software-Architectures by zivko11.

the class ActorPerformancesManager method ReadAll.

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

Example 7 with ActorPerformancesDTO

use of com.management.dto.ActorPerformancesDTO in project Internet-Software-Architectures by zivko11.

the class ActorPerformancesManager method Read.

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

Example 8 with ActorPerformancesDTO

use of com.management.dto.ActorPerformancesDTO in project Internet-Software-Architectures by zivko11.

the class ActorPerformancesControllerTests method ReadActorPerformances_ReturnsOK.

@Test
public void ReadActorPerformances_ReturnsOK() {
    // Arrange
    Mockery mock = new Mockery();
    actorReprformancesRepository = mock.mock(ActorPerformancesRepository.class);
    final Actorperformances ap = new Actorperformances();
    mock.checking(new Expectations() {

        {
            oneOf(actorReprformancesRepository).findOne(1);
            will(returnValue(ap));
        }
    });
    ActorPerformancesManager manager = new ActorPerformancesManager(actorReprformancesRepository);
    ActorPerformancesController controller = new ActorPerformancesController(manager);
    // Act
    ResponseEntity<ActorPerformancesDTO> response = controller.getActorPerformances(1);
    ActorPerformancesDTO dto = response.getBody();
    // Assert
    Assert.assertNotNull(controller);
    Assert.assertEquals(response, new ResponseEntity<ActorPerformancesDTO>(dto, HttpStatus.OK));
    mock.assertIsSatisfied();
}
Also used : Actorperformances(com.management.entities.Actorperformances) Expectations(org.jmock.Expectations) ActorPerformancesManager(com.management.managers.ActorPerformancesManager) ActorPerformancesRepository(com.management.repositories.ActorPerformancesRepository) Mockery(org.jmock.Mockery) ActorPerformancesDTO(com.management.dto.ActorPerformancesDTO) Test(org.junit.Test)

Example 9 with ActorPerformancesDTO

use of com.management.dto.ActorPerformancesDTO in project Internet-Software-Architectures by zivko11.

the class ActorPerformancesControllerTests method ReadAllActorPerformances_ReturnsOK.

@Test
public void ReadAllActorPerformances_ReturnsOK() {
    // Arrange
    Mockery mock = new Mockery();
    actorReprformancesRepository = mock.mock(ActorPerformancesRepository.class);
    final ArrayList<Actorperformances> list = new ArrayList<Actorperformances>();
    Actorperformances ap1 = new Actorperformances();
    Actorperformances ap2 = new Actorperformances();
    list.add(ap1);
    list.add(ap2);
    mock.checking(new Expectations() {

        {
            oneOf(actorReprformancesRepository).findAll();
            will(returnValue(list));
        }
    });
    ActorPerformancesManager manager = new ActorPerformancesManager(actorReprformancesRepository);
    ActorPerformancesController controller = new ActorPerformancesController(manager);
    // Act
    ResponseEntity<List<ActorPerformancesDTO>> response = controller.getActorPerformances();
    ArrayList<ActorPerformancesDTO> listDTO = (ArrayList<ActorPerformancesDTO>) response.getBody();
    // Assert
    Assert.assertNotNull(controller);
    Assert.assertEquals(response, new ResponseEntity<List<ActorPerformancesDTO>>(listDTO, HttpStatus.OK));
    mock.assertIsSatisfied();
}
Also used : Actorperformances(com.management.entities.Actorperformances) Expectations(org.jmock.Expectations) ActorPerformancesManager(com.management.managers.ActorPerformancesManager) ActorPerformancesRepository(com.management.repositories.ActorPerformancesRepository) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Mockery(org.jmock.Mockery) ActorPerformancesDTO(com.management.dto.ActorPerformancesDTO) Test(org.junit.Test)

Aggregations

ActorPerformancesDTO (com.management.dto.ActorPerformancesDTO)9 Actorperformances (com.management.entities.Actorperformances)7 Test (org.junit.Test)7 ActorPerformancesRepository (com.management.repositories.ActorPerformancesRepository)5 Expectations (org.jmock.Expectations)5 Mockery (org.jmock.Mockery)5 ActorPerformancesManager (com.management.managers.ActorPerformancesManager)4 ArrayList (java.util.ArrayList)3 ActorPerformancesRepositoryFake (com.management.fake.ActorPerformancesRepositoryFake)2 ModelMapper (org.modelmapper.ModelMapper)2 List (java.util.List)1