use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusJsonPresentationModelTest method shouldShowDefaultTabwhenBuildIsNeitherFailedNorPassed.
@Test
public void shouldShowDefaultTabwhenBuildIsNeitherFailedNorPassed() throws Exception {
JobInstance instance = JobInstanceMother.cancelled("plan1");
JobStatusJsonPresentationModel buildStatusJson = new JobStatusJsonPresentationModel(instance, null);
assertThat(buildStatusJson.getTabToShow(), is(""));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusJsonPresentationModelTest method shouldIncludeBuildLocatorForDisplay.
@Test
public void shouldIncludeBuildLocatorForDisplay() throws Exception {
JobInstance instance = JobInstanceMother.completed("job-%", JobResult.Passed);
instance.setIdentifier(new JobIdentifier("cruise-%", 1, "label-1", "dev-%", "1", "job-%", -1L));
JobStatusJsonPresentationModel presenter = new JobStatusJsonPresentationModel(instance, null);
Map json = presenter.toJsonHash();
assertThat(JsonUtils.from(json).getString("buildLocatorForDisplay"), is("cruise-%/label-1/dev-%/1/job-%"));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusJsonPresentationModelTest method shouldEncodeBuildLocator.
@Test
public void shouldEncodeBuildLocator() throws Exception {
JobInstance instance = JobInstanceMother.completed("job-%", JobResult.Passed);
instance.setIdentifier(new JobIdentifier("cruise-%", 1, "label-1", "dev-%", "1", "job-%", -1L));
JobStatusJsonPresentationModel presenter = new JobStatusJsonPresentationModel(instance, null);
Map json = presenter.toJsonHash();
assertThat(JsonUtils.from(json).getString("buildLocator"), is("cruise-%25/1/dev-%25/1/job-%25"));
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class JobStatusJsonPresentationModelTest method shouldShowBuildStatus.
@Test
public void shouldShowBuildStatus() throws Exception {
JobInstance instance = JobInstanceMother.assigned("test");
instance.setId(12);
instance.setAgentUuid("1234");
final Agents agents = new Agents(new AgentConfig("1234", "localhost", "1234"));
JobStatusJsonPresentationModel presenter = new JobStatusJsonPresentationModel(instance, agents.getAgentByUuid(instance.getAgentUuid()));
Map json = presenter.toJsonHash();
new JsonTester(json).shouldContain("{ 'name' : 'test'," + " 'id' : '12', " + " 'agent' : 'localhost', " + " 'current_status' : 'assigned' " + "}");
}
use of com.thoughtworks.go.domain.JobInstance in project gocd by gocd.
the class StageConverter method createStageDTO.
private StageNotificationDTO.StageDTO createStageDTO() {
ArrayList<StageNotificationDTO.JobDTO> jobs = new ArrayList<>();
for (JobInstance job : stage.getJobInstances()) {
StageNotificationDTO.JobDTO jobDTO = new StageNotificationDTO.JobDTO(job.getName(), job.getScheduledDate(), job.getCompletedDate(), job.getState(), job.getResult(), job.getAgentUuid());
jobs.add(jobDTO);
}
return new StageNotificationDTO.StageDTO(stage.getName(), stage.getCounter(), stage.getApprovalType(), stage.getApprovedBy(), stage.getState(), stage.getResult(), stage.getCreatedTime(), stage.getLastTransitionedTime(), jobs);
}
Aggregations