use of com.management.repositories.FanZoneRepository 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();
}
use of com.management.repositories.FanZoneRepository in project Internet-Software-Architectures by zivko11.
the class FanZoneManagerTests method ReadAllFanZones_ReturnsAllFanZones.
@Test
public void ReadAllFanZones_ReturnsAllFanZones() {
// 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 Amurica fan zone");
list.add(fz1);
list.add(fz2);
mock.checking(new Expectations() {
{
oneOf(fanZoneRepository).findAll();
will(returnValue(list));
}
});
FanZoneManager manager = new FanZoneManager(fanZoneRepository);
// Act
ArrayList<FanZoneDTO> dtoList = manager.ReadAll();
// Assert
Assert.assertNotNull(dtoList);
Assert.assertEquals(dtoList.get(0).getFanZoneId(), list.get(0).getFanZoneId());
Assert.assertEquals(dtoList.get(0).getFanZoneName(), list.get(0).getFanZoneName());
Assert.assertEquals(dtoList.get(1).getFanZoneId(), list.get(1).getFanZoneId());
Assert.assertEquals(dtoList.get(1).getFanZoneName(), list.get(1).getFanZoneName());
mock.assertIsSatisfied();
}
use of com.management.repositories.FanZoneRepository in project Internet-Software-Architectures by zivko11.
the class FanZoneManagerTests method ReadFanZone_ReturnsFanZone.
@Test
public void ReadFanZone_ReturnsFanZone() {
// 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);
// Act
FanZoneDTO dto = manager.Read(1);
// Assert
Assert.assertNotNull(dto);
Assert.assertEquals(dto.getFanZoneName(), fz.getFanZoneName());
}
use of com.management.repositories.FanZoneRepository in project Internet-Software-Architectures by zivko11.
the class FanZoneManagerTests method DeleteFanZone_ReturnsBoolean.
@Test
public void DeleteFanZone_ReturnsBoolean() {
// Arrange
Mockery mock = new Mockery();
fanZoneRepository = mock.mock(FanZoneRepository.class);
// Expectations
mock.checking(new Expectations() {
{
oneOf(fanZoneRepository).delete(1);
}
});
// Act and assert
FanZoneManager manager = new FanZoneManager(fanZoneRepository);
Assert.assertNotNull(manager);
Assert.assertTrue(manager.Delete(1));
mock.assertIsSatisfied();
}
use of com.management.repositories.FanZoneRepository 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();
}
Aggregations