use of com.management.repositories.PerformanceRepository 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();
}
Aggregations