use of com.thoughtworks.go.domain.JobState 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 com.thoughtworks.go.domain.JobState in project gocd by gocd.
the class BuildStateTypeHandlerCallbackTest method shouldReturnScheduledWhenGivenStringScheduled.
@Test
public void shouldReturnScheduledWhenGivenStringScheduled() throws SQLException {
context.checking(new Expectations() {
{
one(resultGetter).getString();
will(returnValue(JobState.Scheduled.toString()));
}
});
BuildStateTypeHandlerCallback callback = new BuildStateTypeHandlerCallback();
JobState result = (JobState) callback.getResult(resultGetter);
assertThat(result, is(equal(JobState.Scheduled)));
}
use of com.thoughtworks.go.domain.JobState in project gocd by gocd.
the class BuildRepositoryServiceTest method shouldUpdateStatusFromAssignedAgent.
@Test
public void shouldUpdateStatusFromAssignedAgent() throws Exception {
JobState state = JobState.Completing;
buildRepositoryService.updateStatusFromAgent(jobInstance.getIdentifier(), state, agentUuid);
verify(scheduleService).updateJobStatus(jobInstance.getIdentifier(), state);
}
use of com.thoughtworks.go.domain.JobState in project gocd by gocd.
the class BuildRepositoryRemoteImpl method reportCompleted.
public void reportCompleted(final AgentRuntimeInfo agentRuntimeInfo, final JobIdentifier jobIdentifier, final JobResult result) {
final JobState state = JobState.Completed;
handleFailuresDuringReporting(agentRuntimeInfo, jobIdentifier, "status and result", String.format("%s, %s", state, result), () -> {
// TODO: may be i don't belong here, ping already updates agent runtime info
agentService.updateRuntimeInfo(agentRuntimeInfo);
buildRepositoryService.completing(jobIdentifier, result, agentRuntimeInfo.getUUId());
buildRepositoryService.updateStatusFromAgent(jobIdentifier, state, agentRuntimeInfo.getUUId());
jobStatusTopic.post(new JobStatusMessage(jobIdentifier, state, agentRuntimeInfo.getUUId()));
});
}
use of com.thoughtworks.go.domain.JobState in project gocd by gocd.
the class BuildStateTypeHandlerCallbackTest method shouldReturnStateWithStringColumnName.
@Test
public void shouldReturnStateWithStringColumnName() throws SQLException {
ResultSet rs = mock(ResultSet.class);
when(rs.getString("foo")).thenReturn(JobState.Scheduled.toString());
BuildStateTypeHandlerCallback callback = new BuildStateTypeHandlerCallback(JobState.class);
JobState result = callback.getResult(rs, "foo");
assertThat(result, is(JobState.Scheduled));
}
Aggregations