Search in sources :

Example 1 with Actorperformances

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

the class ActorPerformancesManagerTests method ReadAllActorPerformances_ReturnsAllActorPerformances.

@Test
public void ReadAllActorPerformances_ReturnsAllActorPerformances() {
    // 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);
    // Act
    ArrayList<ActorPerformancesDTO> listDTO = manager.ReadAll();
    // Assert
    Assert.assertNotNull(listDTO);
    Assert.assertEquals(listDTO.get(0).getApId(), list.get(0).getApId());
    Assert.assertEquals(listDTO.get(1).getApId(), list.get(1).getApId());
    mock.assertIsSatisfied();
}
Also used : Actorperformances(com.management.entities.Actorperformances) Expectations(org.jmock.Expectations) ActorPerformancesRepository(com.management.repositories.ActorPerformancesRepository) ArrayList(java.util.ArrayList) Mockery(org.jmock.Mockery) ActorPerformancesDTO(com.management.dto.ActorPerformancesDTO) Test(org.junit.Test)

Example 2 with Actorperformances

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

the class ActorPerformancesManagerTests method ReadActorPerformances_ReturnsActorPerformances.

@Test
public void ReadActorPerformances_ReturnsActorPerformances() {
    // 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);
    // Act
    ActorPerformancesDTO dto = manager.Read(1);
    // Assert
    Assert.assertNotNull(dto);
    Assert.assertEquals(dto.getApId(), ap.getApId());
    mock.assertIsSatisfied();
}
Also used : Actorperformances(com.management.entities.Actorperformances) Expectations(org.jmock.Expectations) ActorPerformancesRepository(com.management.repositories.ActorPerformancesRepository) Mockery(org.jmock.Mockery) ActorPerformancesDTO(com.management.dto.ActorPerformancesDTO) Test(org.junit.Test)

Example 3 with Actorperformances

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

the class ActorPerformancesManager method Create.

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

Example 4 with Actorperformances

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

the class ActorPerformancesManagerTests method AddingNewActorPerformances_ReturnsBoolean.

@Test
public void AddingNewActorPerformances_ReturnsBoolean() {
    // Arrange
    actorReprformancesRepository = new ActorPerformancesRepositoryFake();
    ActorPerformancesDTO dto = new ActorPerformancesDTO();
    ActorPerformancesManager manager = new ActorPerformancesManager(actorReprformancesRepository);
    // Act and assert
    Assert.assertNotNull(manager);
    Assert.assertTrue(manager.Create(dto));
    Actorperformances ap = actorReprformancesRepository.findOne(0);
    Assert.assertEquals(dto.getApId(), ap.getApId());
}
Also used : ActorPerformancesRepositoryFake(com.management.fake.ActorPerformancesRepositoryFake) Actorperformances(com.management.entities.Actorperformances) ActorPerformancesDTO(com.management.dto.ActorPerformancesDTO) Test(org.junit.Test)

Example 5 with Actorperformances

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

Aggregations

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