Search in sources :

Example 86 with Expectations

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

the class BuildRepositoryServiceTest method shouldReturnFalseIfBuildInstanceDoesNotExist.

@Test
public void shouldReturnFalseIfBuildInstanceDoesNotExist() {
    context.checking(new Expectations() {

        {
            one(jobInstanceService).buildByIdWithTransitions((long) with(any(Integer.class)));
            will(returnValue(NullJobInstance.NULL));
        }
    });
    assertThat(buildRepositoryService.isCancelledOrRescheduled(123L), is(false));
}
Also used : Expectations(org.jmock.Expectations) Test(org.junit.Test)

Example 87 with Expectations

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

the class BuildRepositoryServiceTest method shouldNotUpdateStatusFromWrongAgent.

@Test(expected = RuntimeException.class)
public void shouldNotUpdateStatusFromWrongAgent() throws Exception {
    final JobState state = JobState.Assigned;
    final JobInstance instance = context.mock(JobInstance.class);
    context.checking(new Expectations() {

        {
            one(instance).isNull();
            will(returnValue(false));
            one(instance).getResult();
            will(returnValue(JobResult.Unknown));
            one(jobInstanceService).buildByIdWithTransitions(jobIdendifier.getBuildId());
            will(returnValue(instance));
            one(instance).getState();
            one(instance).changeState(with(equal(state)));
            one(jobInstanceService).updateStateAndResult(instance);
            atLeast(1).of(instance).getAgentUuid();
            will(returnValue(agentUuid));
        }
    });
    buildRepositoryService.updateStatusFromAgent(jobIdendifier, state, "wrongId");
}
Also used : Expectations(org.jmock.Expectations) JobInstance(com.thoughtworks.go.domain.JobInstance) NullJobInstance(com.thoughtworks.go.domain.NullJobInstance) JobState(com.thoughtworks.go.domain.JobState) Test(org.junit.Test)

Example 88 with Expectations

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

the class JobDetailServiceTest method setUp.

@Before
public void setUp() throws Exception {
    artifactsService = context.mock(ArtifactsService.class);
    configService = context.mock(GoConfigService.class);
    jobInstanceDao = context.mock(JobInstanceDao.class);
    jobDetailService = new JobDetailService(artifactsService, jobInstanceDao, configService);
    final String jobName = "jobConfig1";
    final int id = 1;
    job = JobInstanceMother.completed(jobName, JobResult.Failed);
    job.setId(id);
    job.setIdentifier(new JobIdentifier("pipeline", "Label:1", "stage", "1", jobName));
    final Tabs tabs = new Tabs();
    customizedTab = new Tab("myArtifacts", "my/artifact/path");
    tabs.add(customizedTab);
    context.checking(new Expectations() {

        {
            one(configService).getCustomizedTabs("pipeline", "stage", jobName);
            will(returnValue(tabs));
        }
    });
}
Also used : Expectations(org.jmock.Expectations) Tab(com.thoughtworks.go.config.Tab) Tabs(com.thoughtworks.go.config.Tabs) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) JobInstanceDao(com.thoughtworks.go.server.dao.JobInstanceDao) Before(org.junit.Before)

Example 89 with Expectations

use of org.jmock.Expectations in project commons-gdx by gemserk.

the class ContactsTest method addingAContactReusesOneIfAvailable.

@Test
public void addingAContactReusesOneIfAvailable() {
    mockery.checking(new Expectations() {

        {
            ignoring(fixtureA);
            ignoring(fixtureB);
        }
    });
    Contact reusedContact = new Contact();
    contacts.contacts.add(reusedContact);
    contacts.activeContacts = 0;
    contacts.addContact(fixtureA, fixtureB, new Vector2());
    assertTrue(contacts.isInContact());
    assertThat(1, IsEqual.equalTo(contacts.getContactCount()));
    Contact contact = contacts.contacts.get(0);
    assertThat(true, IsEqual.equalTo(contact.inContact));
    assertThat(contact.myFixture, same(fixtureA));
    assertThat(contact.otherFixture, same(fixtureB));
}
Also used : Expectations(org.jmock.Expectations) Vector2(com.badlogic.gdx.math.Vector2) Contact(com.gemserk.commons.gdx.box2d.Contacts.Contact) Test(org.junit.Test)

Example 90 with Expectations

use of org.jmock.Expectations in project commons-gdx by gemserk.

the class ContactsTest method removesFirstContactIfItMatches.

@Test
public void removesFirstContactIfItMatches() {
    mockery.checking(new Expectations() {

        {
            ignoring(fixtureA);
            ignoring(fixtureB);
        }
    });
    contacts.addContact(fixtureA, fixtureB, normal);
    assertTrue(contacts.isInContact());
    assertThat(1, IsEqual.equalTo(contacts.getContactCount()));
    contacts.removeContact(fixtureA, fixtureB);
    assertFalse(contacts.isInContact());
    assertThat(0, IsEqual.equalTo(contacts.getContactCount()));
    Contact removedContact = contacts.contacts.get(0);
    assertFalse(removedContact.inContact);
    assertNull(removedContact.myFixture);
    assertNull(removedContact.otherFixture);
}
Also used : Expectations(org.jmock.Expectations) Contact(com.gemserk.commons.gdx.box2d.Contacts.Contact) Test(org.junit.Test)

Aggregations

Expectations (org.jmock.Expectations)651 Test (org.junit.Test)443 UnitTest (org.apache.geode.test.junit.categories.UnitTest)109 File (java.io.File)41 ConfigurationServiceImpl (org.nhindirect.config.service.impl.ConfigurationServiceImpl)41 InternalCache (org.apache.geode.internal.cache.InternalCache)35 SlingHttpServletRequest (org.apache.sling.api.SlingHttpServletRequest)33 SlingHttpServletResponse (org.apache.sling.api.SlingHttpServletResponse)32 Resource (org.apache.sling.api.resource.Resource)31 RewriterResponse (org.apache.sling.security.impl.ContentDispositionFilter.RewriterResponse)31 ArrayList (java.util.ArrayList)27 DiskStore (org.apache.geode.cache.DiskStore)23 ValueMap (org.apache.sling.api.resource.ValueMap)21 Before (org.junit.Before)20 CertificateGetOptions (org.nhindirect.config.service.impl.CertificateGetOptions)20 Sequence (org.jmock.Sequence)19 Cache (org.apache.geode.cache.Cache)18 Region (org.apache.geode.cache.Region)18 DistributedMember (org.apache.geode.distributed.DistributedMember)18 IntegrationTest (org.apache.geode.test.junit.categories.IntegrationTest)17