Search in sources :

Example 11 with JobInstance

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(""));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) Test(org.junit.Test)

Example 12 with JobInstance

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-%"));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Map(java.util.Map) Test(org.junit.Test)

Example 13 with JobInstance

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"));
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) Map(java.util.Map) Test(org.junit.Test)

Example 14 with JobInstance

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' " + "}");
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) JsonTester(com.thoughtworks.go.util.JsonTester) JobInstance(com.thoughtworks.go.domain.JobInstance) Agents(com.thoughtworks.go.config.Agents) Map(java.util.Map) Test(org.junit.Test)

Example 15 with JobInstance

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);
}
Also used : JobInstance(com.thoughtworks.go.domain.JobInstance) ArrayList(java.util.ArrayList)

Aggregations

JobInstance (com.thoughtworks.go.domain.JobInstance)90 Test (org.junit.Test)65 Stage (com.thoughtworks.go.domain.Stage)23 Pipeline (com.thoughtworks.go.domain.Pipeline)22 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)16 JobInstances (com.thoughtworks.go.domain.JobInstances)11 JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)10 Stages (com.thoughtworks.go.domain.Stages)5 JsonTester (com.thoughtworks.go.util.JsonTester)5 Map (java.util.Map)5 ModelAndView (org.springframework.web.servlet.ModelAndView)5 AgentConfig (com.thoughtworks.go.config.AgentConfig)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 Date (java.util.Date)4 ArtifactPropertiesGenerator (com.thoughtworks.go.config.ArtifactPropertiesGenerator)3 Resource (com.thoughtworks.go.config.Resource)3 DirectoryEntries (com.thoughtworks.go.domain.DirectoryEntries)3 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3 ProjectStatus (com.thoughtworks.go.domain.activity.ProjectStatus)3 StageDao (com.thoughtworks.go.server.dao.StageDao)3