Search in sources :

Example 6 with Performance

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

the class PerformanceManager method Update.

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

Example 7 with Performance

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

the class PerformanceManager method Read.

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

Example 8 with Performance

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

the class PerformanceControllerTests method ReadAllPerformances_ReturnsOK.

@Test
public void ReadAllPerformances_ReturnsOK() {
    // Arrange
    Mockery mock = new Mockery();
    performanceRepository = mock.mock(PerformanceRepository.class);
    final ArrayList<Performance> list = new ArrayList<Performance>();
    Performance per1 = new Performance();
    per1.setPerCreationDate(new Date());
    per1.setPerDescription("Neki opis.");
    per1.setPerDirector("Zivko Stanisic");
    per1.setPerDuration(11);
    per1.setPerGenre("Akcija");
    per1.setPerPoster(new byte[] { 121 });
    per1.setPerPrice(100);
    per1.setPerRank(10);
    per1.setPerType('M');
    Performance per2 = new Performance();
    per2.setPerCreationDate(new Date());
    per2.setPerDescription("Opet opis.");
    per2.setPerDirector("Nikola Stojanovic");
    per2.setPerDuration(13);
    per2.setPerGenre("Drama");
    per2.setPerPoster(new byte[] { 121 });
    per2.setPerPrice(0);
    per2.setPerRank(1);
    per2.setPerType('M');
    list.add(per1);
    list.add(per2);
    mock.checking(new Expectations() {

        {
            oneOf(performanceRepository).findAll();
            will(returnValue(list));
        }
    });
    PerformanceManager manager = new PerformanceManager(performanceRepository);
    PerformanceController controller = new PerformanceController(manager);
    // Act
    ResponseEntity<List<PerformanceDTO>> response = controller.getPerformances();
    ArrayList<PerformanceDTO> listDTO = (ArrayList<PerformanceDTO>) response.getBody();
    // Assert
    Assert.assertNotNull(controller);
    Assert.assertEquals(response, new ResponseEntity<List<PerformanceDTO>>(listDTO, HttpStatus.OK));
    mock.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) ArrayList(java.util.ArrayList) Mockery(org.jmock.Mockery) Date(java.util.Date) PerformanceDTO(com.management.dto.PerformanceDTO) PerformanceRepository(com.management.repositories.PerformanceRepository) PerformanceManager(com.management.managers.PerformanceManager) ArrayList(java.util.ArrayList) List(java.util.List) Performance(com.management.entities.Performance) Test(org.junit.Test)

Aggregations

Performance (com.management.entities.Performance)8 PerformanceDTO (com.management.dto.PerformanceDTO)6 PerformanceRepository (com.management.repositories.PerformanceRepository)4 Date (java.util.Date)4 Expectations (org.jmock.Expectations)4 Mockery (org.jmock.Mockery)4 Test (org.junit.Test)4 ModelMapper (org.modelmapper.ModelMapper)4 ArrayList (java.util.ArrayList)3 PerformanceManager (com.management.managers.PerformanceManager)2 List (java.util.List)1