use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusJsonPresentationModelTest method shouldShowBuildStatusForCompleted.
@Test
public void shouldShowBuildStatusForCompleted() throws Exception {
JobInstance instance = JobInstanceMother.completed("test", JobResult.Passed);
JobStatusJsonPresentationModel presenter = new JobStatusJsonPresentationModel(instance);
Map json = presenter.toJsonHash();
JSONAssert.assertEquals("{\n" + " \"name\": \"test\",\n" + " \"current_status\": \"passed\"\n" + "}", new Gson().toJson(json), false);
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusJsonPresentationModelTest method shouldReturnNotYetAssignedIfAgentUuidIsNull.
@Test
public void shouldReturnNotYetAssignedIfAgentUuidIsNull() throws Exception {
JobInstance instance = JobInstanceMother.building("Plan1");
instance.setAgentUuid(null);
// "Not assigned" should depend on whether or not the JobInstance has an agentUuid, regardless of
// the Agent object passed to the presenter, as this is the canonical definition of job assignment
JobStatusJsonPresentationModel presenter = new JobStatusJsonPresentationModel(instance, mock(Agent.class), mock(DurationBean.class));
JSONAssert.assertEquals("{\n \"agent\": \"Not yet assigned\"\n}", new Gson().toJson(presenter.toJsonHash()), false);
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusJsonPresentationModelTest method shouldReturnAgentHostname.
@Test
public void shouldReturnAgentHostname() throws Exception {
JobInstance instance = JobInstanceMother.building("Plan1");
instance.setAgentUuid("1234");
JobStatusJsonPresentationModel presenter = new JobStatusJsonPresentationModel(instance, new Agent("1234", "cookie", "localhost", "address"), mock(DurationBean.class));
JSONAssert.assertEquals("{\n" + " \"agent\": \"localhost\"\n" + "}", new Gson().toJson(presenter.toJsonHash()), false);
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusJsonPresentationModelTest method shouldShowFailuresTabwhenBuildFailed.
@Test
public void shouldShowFailuresTabwhenBuildFailed() throws Exception {
JobInstance instance = JobInstanceMother.failed("plan1");
JobStatusJsonPresentationModel buildStatusJson = new JobStatusJsonPresentationModel(instance);
assertThat(buildStatusJson.getTabToShow(), is("#tab-failures"));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusJsonPresentationModelTest method shouldShowElapsedAndRemainingTimeForIncompleteBuild.
@Test
public void shouldShowElapsedAndRemainingTimeForIncompleteBuild() throws Exception {
JobInstance instance = JobInstanceMother.building("test", new DateTime().minusSeconds(5).toDate());
JobStatusJsonPresentationModel presenter = new JobStatusJsonPresentationModel(instance, mock(Agent.class), new DurationBean(instance.getId(), 10L));
Map json = presenter.toJsonHash();
JSONAssert.assertEquals("{\n" + " \"name\": \"test\",\n" + " \"current_status\": \"building\",\n" + " \"current_build_duration\": \"5\",\n" + " \"last_build_duration\": \"10\"\n" + "}", new Gson().toJson(json), false);
}
Aggregations