use of org.jmock.Mockery in project Internet-Software-Architectures by zivko11.
the class CinemaTheatreManagerTests method ReadAllCinemaTheatres_ReturnsAllCinemaTheatres.
@Test
public void ReadAllCinemaTheatres_ReturnsAllCinemaTheatres() {
// Arrange
Mockery mock = new Mockery();
cinemaTheatreRepository = mock.mock(CinemaTheatreRepository.class);
final ArrayList<CinemaTheatre> list = new ArrayList<CinemaTheatre>();
CinemaTheatre cinemaTheatre1 = new CinemaTheatre();
cinemaTheatre1.setCtAdress("Bulevar oslobodjenja 11");
cinemaTheatre1.setCtDescription("Ovo je opis.");
cinemaTheatre1.setCtName("Bioskop");
cinemaTheatre1.setCtPhone(1234567890);
cinemaTheatre1.setCtStateid("381");
CinemaTheatre cinemaTheatre2 = new CinemaTheatre();
cinemaTheatre2.setCtAdress("Bulevar oslobodjenja 9");
cinemaTheatre2.setCtDescription("Takodje opis.");
cinemaTheatre2.setCtName("Kazaliste");
cinemaTheatre2.setCtPhone(987654321);
cinemaTheatre2.setCtStateid("386");
list.add(cinemaTheatre1);
list.add(cinemaTheatre2);
mock.checking(new Expectations() {
{
oneOf(cinemaTheatreRepository).findAll();
will(returnValue(list));
}
});
CinemaTheatreManager manager = new CinemaTheatreManager(cinemaTheatreRepository);
// Act
ArrayList<CinemaTheatreDTO> listDTO = manager.ReadAll();
// Assert
Assert.assertNotNull(listDTO);
Assert.assertEquals(list.get(0).getCtAdress(), listDTO.get(0).getCtAdress());
Assert.assertEquals(list.get(0).getCtDescription(), listDTO.get(0).getCtDescription());
Assert.assertEquals(list.get(0).getCtName(), listDTO.get(0).getCtName());
Assert.assertEquals(list.get(0).getCtPhone(), listDTO.get(0).getCtPhone());
Assert.assertEquals(list.get(1).getCtAdress(), listDTO.get(1).getCtAdress());
Assert.assertEquals(list.get(1).getCtDescription(), listDTO.get(1).getCtDescription());
Assert.assertEquals(list.get(1).getCtName(), listDTO.get(1).getCtName());
Assert.assertEquals(list.get(1).getCtPhone(), listDTO.get(1).getCtPhone());
mock.assertIsSatisfied();
}
use of org.jmock.Mockery in project Internet-Software-Architectures by zivko11.
the class EvenetManagerTests method ReadEvent_ReturnsEvent.
@Test
public void ReadEvent_ReturnsEvent() {
// Arrange
Mockery mock = new Mockery();
eventRepository = mock.mock(EventRepository.class);
final Event event = new Event();
event.setEventDate(new Date());
mock.checking(new Expectations() {
{
oneOf(eventRepository).findOne(1);
will(returnValue(event));
}
});
EventManager manager = new EventManager(eventRepository);
// Act
EventDTO dto = manager.Read(1);
// Assert
Assert.assertNotNull(dto);
Assert.assertEquals(dto.getEventId(), event.getEventId());
mock.assertIsSatisfied();
}
use of org.jmock.Mockery in project Internet-Software-Architectures by zivko11.
the class EvenetManagerTests method DeletingEvent_ReturnsBoolean.
@Test
public void DeletingEvent_ReturnsBoolean() {
// Arrange
Mockery mock = new Mockery();
eventRepository = mock.mock(EventRepository.class);
// expectations
mock.checking(new Expectations() {
{
oneOf(eventRepository).delete(1);
}
});
// Act and assert
EventManager manager = new EventManager(eventRepository);
Assert.assertNotNull(manager);
Assert.assertTrue(manager.Delete(1));
mock.assertIsSatisfied();
}
use of org.jmock.Mockery 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 org.jmock.Mockery 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();
}
Aggregations