use of com.management.repositories.HallRepository in project Internet-Software-Architectures by zivko11.
the class HallControllerTests method DeletingHall_ReturnsOK.
@Test
public void DeletingHall_ReturnsOK() {
// Arrange
Mockery mock = new Mockery();
hallRepository = mock.mock(HallRepository.class);
// expectations
mock.checking(new Expectations() {
{
oneOf(hallRepository).delete(1);
}
});
// Act and assert
HallManager manager = new HallManager(hallRepository);
HallController controller = new HallController(manager);
Assert.assertNotNull(controller);
Assert.assertEquals(controller.deleteHall(1), new ResponseEntity<HallDTO>(HttpStatus.OK));
mock.assertIsSatisfied();
}
use of com.management.repositories.HallRepository in project Internet-Software-Architectures by zivko11.
the class HallControllerTests method ReadHall_ReturnsOK.
@Test
public void ReadHall_ReturnsOK() {
// Arrange
Mockery mock = new Mockery();
hallRepository = mock.mock(HallRepository.class);
final Hall hall = new Hall();
hall.setHallName("A1");
mock.checking(new Expectations() {
{
oneOf(hallRepository).findOne(1);
will(returnValue(hall));
}
});
HallManager manager = new HallManager(hallRepository);
HallController controller = new HallController(manager);
// Act
ResponseEntity<HallDTO> response = controller.getHall(1);
HallDTO dto = response.getBody();
// Assert
Assert.assertNotNull(controller);
Assert.assertEquals(response, new ResponseEntity<HallDTO>(dto, HttpStatus.OK));
mock.assertIsSatisfied();
}
use of com.management.repositories.HallRepository in project Internet-Software-Architectures by zivko11.
the class HallControllerTests method ReadAllHalls_ReturnsOK.
@Test
public void ReadAllHalls_ReturnsOK() {
// Arrange
Mockery mock = new Mockery();
hallRepository = mock.mock(HallRepository.class);
final ArrayList<Hall> list = new ArrayList<Hall>();
Hall hall1 = new Hall();
hall1.setHallName("A1");
Hall hall2 = new Hall();
hall2.setHallName("A2");
list.add(hall1);
list.add(hall2);
mock.checking(new Expectations() {
{
oneOf(hallRepository).findAll();
will(returnValue(list));
}
});
HallManager manager = new HallManager(hallRepository);
HallController controller = new HallController(manager);
// Act
ResponseEntity<List<HallDTO>> response = controller.getHalls();
ArrayList<HallDTO> listDTO = (ArrayList<HallDTO>) response.getBody();
// Assert
Assert.assertNotNull(controller);
Assert.assertEquals(response, new ResponseEntity<List<HallDTO>>(listDTO, HttpStatus.OK));
mock.assertIsSatisfied();
}
use of com.management.repositories.HallRepository in project Internet-Software-Architectures by zivko11.
the class HallManagerTests method DeletingHall_ReturnsBoolean.
@Test
public void DeletingHall_ReturnsBoolean() {
// Arrange
Mockery mock = new Mockery();
hallRepository = mock.mock(HallRepository.class);
// expectations
mock.checking(new Expectations() {
{
oneOf(hallRepository).delete(1);
}
});
// Act and assert
HallManager manager = new HallManager(hallRepository);
Assert.assertNotNull(manager);
Assert.assertTrue(manager.Delete(1));
mock.assertIsSatisfied();
}
use of com.management.repositories.HallRepository in project Internet-Software-Architectures by zivko11.
the class HallManagerTests method ReadAllHalls_ReturnsAllHalls.
@Test
public void ReadAllHalls_ReturnsAllHalls() {
// Arrange
Mockery mock = new Mockery();
hallRepository = mock.mock(HallRepository.class);
final ArrayList<Hall> list = new ArrayList<Hall>();
Hall hall1 = new Hall();
hall1.setHallName("A1");
Hall hall2 = new Hall();
hall2.setHallName("A2");
list.add(hall1);
list.add(hall2);
mock.checking(new Expectations() {
{
oneOf(hallRepository).findAll();
will(returnValue(list));
}
});
HallManager manager = new HallManager(hallRepository);
// Act
ArrayList<HallDTO> listDTO = manager.ReadAll();
// Assert
Assert.assertNotNull(listDTO);
Assert.assertEquals(listDTO.get(0).getHallId(), list.get(0).getHallId());
Assert.assertEquals(listDTO.get(1).getHallName(), list.get(1).getHallName());
mock.assertIsSatisfied();
}
Aggregations