Search in sources :

Example 1 with ActorPerformancesManager

use of com.management.managers.ActorPerformancesManager in project Internet-Software-Architectures by zivko11.

the class ActorPerformancesControllerTests method DeletingActorPerformances_ReturnsOK.

@Test
public void DeletingActorPerformances_ReturnsOK() {
    // Arrange
    Mockery mock = new Mockery();
    actorReprformancesRepository = mock.mock(ActorPerformancesRepository.class);
    // expectations
    mock.checking(new Expectations() {

        {
            oneOf(actorReprformancesRepository).delete(1);
        }
    });
    // Act and assert
    ActorPerformancesManager manager = new ActorPerformancesManager(actorReprformancesRepository);
    ActorPerformancesController controller = new ActorPerformancesController(manager);
    Assert.assertNotNull(controller);
    Assert.assertEquals(controller.deleteActorPerformances(1), new ResponseEntity<ActorPerformancesDTO>(HttpStatus.OK));
    mock.assertIsSatisfied();
}
Also used : 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 2 with ActorPerformancesManager

use of com.management.managers.ActorPerformancesManager in project Internet-Software-Architectures by zivko11.

the class ActorPerformancesControllerTests method AddingNewActorPerformances_ReturnsOK.

@Test
public void AddingNewActorPerformances_ReturnsOK() {
    // Arrange
    actorReprformancesRepository = new ActorPerformancesRepositoryFake();
    ActorPerformancesDTO dto = new ActorPerformancesDTO();
    ActorPerformancesManager manager = new ActorPerformancesManager(actorReprformancesRepository);
    ActorPerformancesController controller = new ActorPerformancesController(manager);
    // Act and assert
    Assert.assertNotNull(controller);
    Assert.assertEquals(controller.addActorPerformances(dto), new ResponseEntity<ActorPerformancesDTO>(dto, HttpStatus.OK));
}
Also used : ActorPerformancesRepositoryFake(com.management.fake.ActorPerformancesRepositoryFake) ActorPerformancesManager(com.management.managers.ActorPerformancesManager) ActorPerformancesDTO(com.management.dto.ActorPerformancesDTO) Test(org.junit.Test)

Example 3 with ActorPerformancesManager

use of com.management.managers.ActorPerformancesManager 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 4 with ActorPerformancesManager

use of com.management.managers.ActorPerformancesManager 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)4 ActorPerformancesManager (com.management.managers.ActorPerformancesManager)4 Test (org.junit.Test)4 ActorPerformancesRepository (com.management.repositories.ActorPerformancesRepository)3 Expectations (org.jmock.Expectations)3 Mockery (org.jmock.Mockery)3 Actorperformances (com.management.entities.Actorperformances)2 ActorPerformancesRepositoryFake (com.management.fake.ActorPerformancesRepositoryFake)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1