Search in sources :

Example 1 with FanZoneManager

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

the class FanZoneControllerTests method AddingNewFanZone_ReturnsOK.

@Test
public void AddingNewFanZone_ReturnsOK() {
    // Arrange
    Mockery mock = new Mockery();
    fanZoneRepository = new FanZoneRepositoryFake();
    FanZoneDTO dto = new FanZoneDTO();
    dto.setFanZoneName("Spodermna fan zone");
    FanZoneManager manager = new FanZoneManager(fanZoneRepository);
    FanZoneController controller = new FanZoneController(manager);
    // Act and assert
    Assert.assertNotNull(controller);
    Assert.assertEquals(controller.addFanZone(dto), new ResponseEntity<FanZoneDTO>(dto, HttpStatus.OK));
    mock.assertIsSatisfied();
}
Also used : FanZoneManager(com.management.managers.FanZoneManager) FanZoneRepositoryFake(com.management.fake.FanZoneRepositoryFake) FanZoneDTO(com.management.dto.FanZoneDTO) Mockery(org.jmock.Mockery) Test(org.junit.Test)

Example 2 with FanZoneManager

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

the class FanZoneControllerTests method ReadFanZone_ReturnsOK.

@Test
public void ReadFanZone_ReturnsOK() {
    // Arrange
    Mockery mock = new Mockery();
    fanZoneRepository = mock.mock(FanZoneRepository.class);
    final FanZone fz = new FanZone();
    fz.setFanZoneName("Spoderman fan zone");
    mock.checking(new Expectations() {

        {
            oneOf(fanZoneRepository).findOne(1);
            will(returnValue(fz));
        }
    });
    FanZoneManager manager = new FanZoneManager(fanZoneRepository);
    FanZoneController controller = new FanZoneController(manager);
    // Act
    ResponseEntity<FanZoneDTO> response = controller.getFanZone(1);
    FanZoneDTO dto = response.getBody();
    // Assert
    Assert.assertNotNull(controller);
    Assert.assertEquals(response, new ResponseEntity<FanZoneDTO>(dto, HttpStatus.OK));
    mock.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) FanZoneManager(com.management.managers.FanZoneManager) FanZoneRepository(com.management.repositories.FanZoneRepository) FanZoneDTO(com.management.dto.FanZoneDTO) Mockery(org.jmock.Mockery) FanZone(com.management.entities.FanZone) Test(org.junit.Test)

Example 3 with FanZoneManager

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

the class FanZoneControllerTests method ReadAllFanZones_ReturnsOK.

@Test
public void ReadAllFanZones_ReturnsOK() {
    // Arrange
    Mockery mock = new Mockery();
    fanZoneRepository = mock.mock(FanZoneRepository.class);
    final ArrayList<FanZone> list = new ArrayList<FanZone>();
    FanZone fz1 = new FanZone();
    fz1.setFanZoneName("Spoderman fan zone");
    FanZone fz2 = new FanZone();
    fz2.setFanZoneName("Captain Murica fan zone");
    list.add(fz1);
    list.add(fz2);
    mock.checking(new Expectations() {

        {
            oneOf(fanZoneRepository).findAll();
            will(returnValue(list));
        }
    });
    FanZoneManager manager = new FanZoneManager(fanZoneRepository);
    FanZoneController controller = new FanZoneController(manager);
    // Act
    ResponseEntity<List<FanZoneDTO>> response = controller.getFanZones();
    ArrayList<FanZoneDTO> dtoList = (ArrayList<FanZoneDTO>) response.getBody();
    // Assert
    Assert.assertNotNull(controller);
    Assert.assertEquals(response, new ResponseEntity<List<FanZoneDTO>>(dtoList, HttpStatus.OK));
    mock.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) FanZoneManager(com.management.managers.FanZoneManager) ArrayList(java.util.ArrayList) FanZoneRepository(com.management.repositories.FanZoneRepository) ArrayList(java.util.ArrayList) List(java.util.List) FanZoneDTO(com.management.dto.FanZoneDTO) Mockery(org.jmock.Mockery) FanZone(com.management.entities.FanZone) Test(org.junit.Test)

Example 4 with FanZoneManager

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

the class FanZoneControllerTests method DeletingFanZone_ReturnsOK.

@Test
public void DeletingFanZone_ReturnsOK() {
    Mockery mock = new Mockery();
    fanZoneRepository = mock.mock(FanZoneRepository.class);
    // Expectations
    mock.checking(new Expectations() {

        {
            oneOf(fanZoneRepository).delete(1);
        }
    });
    FanZoneManager manager = new FanZoneManager(fanZoneRepository);
    // Act and assert
    FanZoneController controller = new FanZoneController(manager);
    Assert.assertNotNull(controller);
    Assert.assertEquals(controller.deleteFanZone(1), new ResponseEntity<FanZoneDTO>(HttpStatus.OK));
    mock.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) FanZoneManager(com.management.managers.FanZoneManager) FanZoneRepository(com.management.repositories.FanZoneRepository) FanZoneDTO(com.management.dto.FanZoneDTO) Mockery(org.jmock.Mockery) Test(org.junit.Test)

Aggregations

FanZoneDTO (com.management.dto.FanZoneDTO)4 FanZoneManager (com.management.managers.FanZoneManager)4 Mockery (org.jmock.Mockery)4 Test (org.junit.Test)4 FanZoneRepository (com.management.repositories.FanZoneRepository)3 Expectations (org.jmock.Expectations)3 FanZone (com.management.entities.FanZone)2 FanZoneRepositoryFake (com.management.fake.FanZoneRepositoryFake)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1