Search in sources :

Example 96 with Mockery

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();
}
Also used : Expectations(org.jmock.Expectations) CinemaTheatreRepository(com.management.repositories.CinemaTheatreRepository) ArrayList(java.util.ArrayList) CinemaTheatreDTO(com.management.dto.CinemaTheatreDTO) Mockery(org.jmock.Mockery) CinemaTheatre(com.management.entities.CinemaTheatre) Test(org.junit.Test)

Example 97 with Mockery

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();
}
Also used : Expectations(org.jmock.Expectations) EventDTO(com.management.dto.EventDTO) Event(com.management.entities.Event) EventRepository(com.management.repositories.EventRepository) Mockery(org.jmock.Mockery) Date(java.util.Date) Test(org.junit.Test)

Example 98 with Mockery

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();
}
Also used : Expectations(org.jmock.Expectations) EventRepository(com.management.repositories.EventRepository) Mockery(org.jmock.Mockery) Test(org.junit.Test)

Example 99 with Mockery

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());
}
Also used : Expectations(org.jmock.Expectations) FanZoneRepository(com.management.repositories.FanZoneRepository) FanZoneDTO(com.management.dto.FanZoneDTO) Mockery(org.jmock.Mockery) FanZone(com.management.entities.FanZone) Test(org.junit.Test)

Example 100 with Mockery

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();
}
Also used : Expectations(org.jmock.Expectations) FanZoneRepository(com.management.repositories.FanZoneRepository) Mockery(org.jmock.Mockery) Test(org.junit.Test)

Aggregations

Mockery (org.jmock.Mockery)148 Expectations (org.jmock.Expectations)118 Test (org.junit.Test)77 Before (org.junit.Before)28 ArrayList (java.util.ArrayList)24 Date (java.util.Date)21 JUnit4Mockery (org.jmock.integration.junit4.JUnit4Mockery)17 File (java.io.File)15 BeforeMethod (org.testng.annotations.BeforeMethod)15 Synchroniser (org.jmock.lib.concurrent.Synchroniser)14 List (java.util.List)11 ActorDTO (com.management.dto.ActorDTO)7 FanZoneDTO (com.management.dto.FanZoneDTO)6 PropsDTO (com.management.dto.PropsDTO)6 ActorPerformancesRepository (com.management.repositories.ActorPerformancesRepository)6 ActorRepository (com.management.repositories.ActorRepository)6 CinemaTheatreRepository (com.management.repositories.CinemaTheatreRepository)6 EventRepository (com.management.repositories.EventRepository)6 FriendsListRepository (com.management.repositories.FriendsListRepository)6 PerformanceRepository (com.management.repositories.PerformanceRepository)6