Search in sources :

Example 6 with JsonTester

use of com.thoughtworks.go.util.JsonTester in project gocd by gocd.

the class JobStatusJsonPresentationModelTest method shouldReturnNotYetAssignedIfAgentUuidIsNull.

@Test
public void shouldReturnNotYetAssignedIfAgentUuidIsNull() throws Exception {
    JobInstance instance = JobInstanceMother.building("Plan1");
    instance.setAgentUuid(null);
    JobStatusJsonPresentationModel presenter = new JobStatusJsonPresentationModel(instance, null);
    JsonTester tester = new JsonTester(presenter.toJsonHash());
    tester.shouldContain(" { 'agent' : 'Not yet assigned' } ");
}
Also used : JsonTester(com.thoughtworks.go.util.JsonTester) JobInstance(com.thoughtworks.go.domain.JobInstance) Test(org.junit.Test)

Example 7 with JsonTester

use of com.thoughtworks.go.util.JsonTester 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, null, new DurationBean(instance.getId(), 10L));
    Map json = presenter.toJsonHash();
    new JsonTester(json).shouldContain("{ 'name' : 'test'," + " 'current_status' : 'building', " + " 'current_build_duration' : '5', " + " 'last_build_duration' : '10' " + "}");
}
Also used : DurationBean(com.thoughtworks.go.dto.DurationBean) JsonTester(com.thoughtworks.go.util.JsonTester) JobInstance(com.thoughtworks.go.domain.JobInstance) Map(java.util.Map) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 8 with JsonTester

use of com.thoughtworks.go.util.JsonTester 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 AgentConfig("1234", "localhost", null));
    JsonTester tester = new JsonTester(presenter.toJsonHash());
    tester.shouldContain(" { 'agent' : 'localhost' } ");
}
Also used : AgentConfig(com.thoughtworks.go.config.AgentConfig) JsonTester(com.thoughtworks.go.util.JsonTester) JobInstance(com.thoughtworks.go.domain.JobInstance) Test(org.junit.Test)

Example 9 with JsonTester

use of com.thoughtworks.go.util.JsonTester in project gocd by gocd.

the class PipelineJsonPresentationModelTest method shouldHaveCanForceStatus.

@Test
public void shouldHaveCanForceStatus() throws Exception {
    pipeline.setCanForce(true);
    Map<String, Object> json = pipeline.toJson();
    new JsonTester(json).shouldContain("{ 'name' : 'connectfour'," + "  'paused' : 'true'," + "  'pauseCause' : 'upgrading uat'," + "  'pauseBy' : 'jez'," + "  'stages' : []," + "  'forcedBuild' : 'true'," + "  'canForce' : 'true'" + "}");
}
Also used : JsonTester(com.thoughtworks.go.util.JsonTester) Test(org.junit.Test)

Example 10 with JsonTester

use of com.thoughtworks.go.util.JsonTester in project gocd by gocd.

the class PipelineJsonPresentationModelTest method shouldHaveCanPauseStatus.

@Test
public void shouldHaveCanPauseStatus() throws Exception {
    pipeline.setCanPause(true);
    Map<String, Object> json = pipeline.toJson();
    new JsonTester(json).shouldContain("{ 'canPause' : 'true'}");
    pipeline.setCanPause(false);
    json = pipeline.toJson();
    new JsonTester(json).shouldContain("{ 'canPause' : 'false'}");
}
Also used : JsonTester(com.thoughtworks.go.util.JsonTester) Test(org.junit.Test)

Aggregations

JsonTester (com.thoughtworks.go.util.JsonTester)15 Test (org.junit.Test)15 LinkedHashMap (java.util.LinkedHashMap)7 JobInstance (com.thoughtworks.go.domain.JobInstance)5 Map (java.util.Map)3 AgentConfig (com.thoughtworks.go.config.AgentConfig)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Agents (com.thoughtworks.go.config.Agents)1 DurationBean (com.thoughtworks.go.dto.DurationBean)1 ResolvableViewableStatus (com.thoughtworks.go.server.web.i18n.ResolvableViewableStatus)1 Expectations (org.jmock.Expectations)1 DateTime (org.joda.time.DateTime)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1