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));
}
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");
}
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));
}
});
}
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));
}
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);
}
Aggregations