Search in sources :

Example 61 with JobInstance

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

Example 62 with JobInstance

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);
}
Also used : Agent(com.thoughtworks.go.server.domain.Agent) DurationBean(com.thoughtworks.go.dto.DurationBean) JobInstance(com.thoughtworks.go.domain.JobInstance) Gson(com.google.gson.Gson) Test(org.junit.Test)

Example 63 with JobInstance

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);
}
Also used : Agent(com.thoughtworks.go.server.domain.Agent) DurationBean(com.thoughtworks.go.dto.DurationBean) JobInstance(com.thoughtworks.go.domain.JobInstance) Gson(com.google.gson.Gson) Test(org.junit.Test)

Example 64 with JobInstance

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

Example 65 with JobInstance

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);
}
Also used : Agent(com.thoughtworks.go.server.domain.Agent) DurationBean(com.thoughtworks.go.dto.DurationBean) JobInstance(com.thoughtworks.go.domain.JobInstance) Gson(com.google.gson.Gson) Map(java.util.Map) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

JobInstance (com.thoughtworks.go.domain.JobInstance)82 Test (org.junit.Test)56 Stage (com.thoughtworks.go.domain.Stage)16 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)15 Pipeline (com.thoughtworks.go.domain.Pipeline)15 JobInstances (com.thoughtworks.go.domain.JobInstances)12 JobConfigIdentifier (com.thoughtworks.go.domain.JobConfigIdentifier)7 Agent (com.thoughtworks.go.server.domain.Agent)6 Gson (com.google.gson.Gson)5 Stages (com.thoughtworks.go.domain.Stages)5 Map (java.util.Map)5 DurationBean (com.thoughtworks.go.dto.DurationBean)4 DateTime (org.joda.time.DateTime)4 ArtifactPropertiesGenerator (com.thoughtworks.go.config.ArtifactPropertiesGenerator)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)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 JobInstanceModel (com.thoughtworks.go.server.ui.JobInstanceModel)3