Search in sources :

Example 91 with Mockery

use of org.jmock.Mockery in project gocd by gocd.

the class BuildFailedErrorDetectorTest method setUp.

@Before
public void setUp() {
    context = new Mockery();
    reporter = context.mock(Reporter.class);
    detector = new BuildFailedErrorDetector(reporter);
}
Also used : Mockery(org.jmock.Mockery) Before(org.junit.Before)

Example 92 with Mockery

use of org.jmock.Mockery in project gocd by gocd.

the class SystemServiceTest method shouldPopulateServerDetailsModel.

@Test
public void shouldPopulateServerDetailsModel() {
    Mockery mockery = new Mockery();
    final DbMetadataDao dao = mockery.mock(DbMetadataDao.class);
    mockery.checking(new Expectations() {

        {
            one(dao).getSchemaVersion();
            will(returnValue(20));
        }
    });
    new SystemEnvironment().setProperty("java.version", "1.5");
    new SystemEnvironment().setProperty("os.name", "Linux");
    new SystemEnvironment().setProperty("os.version", "2.6");
    Map<String, Object> model = new HashMap<>();
    new SystemService(dao, null).populateServerDetailsModel(model);
    assertThat(model.get("jvm_version"), is("1.5"));
    assertThat(model.get("os_info"), is("Linux 2.6"));
    assertThat(model.get("schema_version"), is(20));
    mockery.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) SystemEnvironment(com.thoughtworks.go.util.SystemEnvironment) HashMap(java.util.HashMap) Mockery(org.jmock.Mockery) DbMetadataDao(com.thoughtworks.go.server.dao.DbMetadataDao) Test(org.junit.Test)

Example 93 with Mockery

use of org.jmock.Mockery in project Internet-Software-Architectures by zivko11.

the class ActorManagerTests method ReadActor_ReturnsActor.

@Test
public void ReadActor_ReturnsActor() {
    // Arrange
    Mockery mock = new Mockery();
    actorRepository = mock.mock(ActorRepository.class);
    final Actor actor = new Actor();
    actor.setAcName("Zivko");
    actor.setAcSurname("Stanisic");
    mock.checking(new Expectations() {

        {
            oneOf(actorRepository).findOne(1);
            will(returnValue(actor));
        }
    });
    ActorManager manager = new ActorManager(actorRepository);
    // Act
    ActorDTO dto = manager.Read(1);
    // Assert
    Assert.assertNotNull(dto);
    Assert.assertEquals(dto.getAcName(), actor.getAcName());
    Assert.assertEquals(dto.getAcSurname(), actor.getAcSurname());
    mock.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) ActorDTO(com.management.dto.ActorDTO) Actor(com.management.entities.Actor) Mockery(org.jmock.Mockery) ActorRepository(com.management.repositories.ActorRepository) Test(org.junit.Test)

Example 94 with Mockery

use of org.jmock.Mockery in project Internet-Software-Architectures by zivko11.

the class ActorManagerTests method DeletingActor_ReturnsBoolean.

@Test
public void DeletingActor_ReturnsBoolean() {
    // Arrange
    Mockery mock = new Mockery();
    actorRepository = mock.mock(ActorRepository.class);
    // expectations
    mock.checking(new Expectations() {

        {
            oneOf(actorRepository).delete(1);
        }
    });
    // Act and assert
    ActorManager manager = new ActorManager(actorRepository);
    Assert.assertNotNull(manager);
    Assert.assertTrue(manager.Delete(1));
    mock.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) Mockery(org.jmock.Mockery) ActorRepository(com.management.repositories.ActorRepository) Test(org.junit.Test)

Example 95 with Mockery

use of org.jmock.Mockery in project Internet-Software-Architectures by zivko11.

the class ActorPerformancesManagerTests method DeletingActorPerformances_ReturnsBoolean.

@Test
public void DeletingActorPerformances_ReturnsBoolean() {
    // Arrange
    Mockery mock = new Mockery();
    actorReprformancesRepository = mock.mock(ActorPerformancesRepository.class);
    // expectations
    mock.checking(new Expectations() {

        {
            oneOf(actorReprformancesRepository).delete(1);
        }
    });
    // Act and assert
    ActorPerformancesManager manager = new ActorPerformancesManager(actorReprformancesRepository);
    Assert.assertNotNull(manager);
    Assert.assertTrue(manager.Delete(1));
    mock.assertIsSatisfied();
}
Also used : Expectations(org.jmock.Expectations) ActorPerformancesRepository(com.management.repositories.ActorPerformancesRepository) 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