Search in sources :

Example 11 with JsonTester

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

the class PipelineJsonPresentationModelTest method shouldReturnJson.

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

Example 12 with JsonTester

use of com.thoughtworks.go.util.JsonTester 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, null);
    Map json = presenter.toJsonHash();
    new JsonTester(json).shouldContain("{ 'name' : 'test'," + " 'current_status' : 'passed' " + "}");
}
Also used : JsonTester(com.thoughtworks.go.util.JsonTester) JobInstance(com.thoughtworks.go.domain.JobInstance) Map(java.util.Map) Test(org.junit.Test)

Example 13 with JsonTester

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

the class JsonViewTest method testShouldRenderEmptyMap.

@Test
public void testShouldRenderEmptyMap() throws Exception {
    JsonView view = new JsonView();
    String json = view.renderJson(new LinkedHashMap());
    new JsonTester(json).is("{ }");
}
Also used : JsonTester(com.thoughtworks.go.util.JsonTester) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 14 with JsonTester

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

the class JsonViewTest method testShouldRenderAllKeyValuePairsFromMap.

@Test
public void testShouldRenderAllKeyValuePairsFromMap() throws Exception {
    Map<String, Object> map = new LinkedHashMap<>();
    map.put("key1", "value1");
    map.put("key2", "value2");
    String json = new JsonView().renderJson(map);
    new JsonTester(json).is("{ 'key1' : 'value1', 'key2' : 'value2' }");
}
Also used : JsonTester(com.thoughtworks.go.util.JsonTester) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 15 with JsonTester

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

the class JsonViewTest method testShouldRenderArray.

@Test
public void testShouldRenderArray() throws Exception {
    List list = new ArrayList();
    Map<String, Object> nestedMap = new LinkedHashMap<>();
    nestedMap.put("key1", "value1");
    list.add(nestedMap);
    list.add("value2");
    JsonView view = new JsonView();
    String json = view.renderJson(list);
    new JsonTester(json).is("[ { 'key1' : 'value1' }, 'value2' ]");
}
Also used : JsonTester(com.thoughtworks.go.util.JsonTester) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) 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