use of com.thoughtworks.go.util.JsonTester 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.util.JsonTester in project gocd by gocd.
the class JsonViewTest method testShouldRenderNestedMaps.
@Test
public void testShouldRenderNestedMaps() throws Exception {
Map<String, Object> map = new LinkedHashMap<>();
Map<String, Object> nestedMap = new LinkedHashMap<>();
nestedMap.put("keyA", "valueA");
map.put("key1", nestedMap);
JsonView view = new JsonView();
String json = view.renderJson(map);
new JsonTester(json).is("{ 'key1' : {" + " 'keyA' : 'valueA'" + " }" + "}");
}
use of com.thoughtworks.go.util.JsonTester in project gocd by gocd.
the class JsonViewTest method testShouldReturnOutputWithoutWhitespaceThatIsNotAllowedInHeaders.
@Test
public void testShouldReturnOutputWithoutWhitespaceThatIsNotAllowedInHeaders() throws Exception {
JsonView view = new JsonView(requestContext);
MockHttpServletResponse response = new MockHttpServletResponse();
Map<String, Object> map = new LinkedHashMap<>();
map.put("key", "\r\t\n");
view.renderMergedOutputModel(asMap(map), new MockHttpServletRequest(), response);
String json = response.getContentAsString();
new JsonTester(json).is("{ 'key' : '\\r\\t\\n' }");
}
use of com.thoughtworks.go.util.JsonTester in project gocd by gocd.
the class JsonViewTest method testShouldRenderI18n.
@Test
public void testShouldRenderI18n() {
Map<String, Object> map = new LinkedHashMap<>();
final String i18nMessage = "waiting(zh_CN)";
final ResolvableViewableStatus resolvableViewableStatus = new ResolvableViewableStatus(WAITING);
map.put("key1", resolvableViewableStatus);
JsonView view = new JsonView(requestContext);
mockContext.checking(new Expectations() {
{
one(requestContext).getMessage(with(equal(resolvableViewableStatus)));
will(returnValue(i18nMessage));
}
});
String json = view.renderJson(map);
mockContext.assertIsSatisfied();
new JsonTester(json).is("{ 'key1' : '" + i18nMessage + "' }");
}
use of com.thoughtworks.go.util.JsonTester in project gocd by gocd.
the class JsonViewTest method testShouldRenderFakeMapsWithoutTheSurroundingMap.
@Test
public void testShouldRenderFakeMapsWithoutTheSurroundingMap() 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(asMap(list));
new JsonTester(json).is("[ { 'key1' : 'value1' }, 'value2' ]");
}
Aggregations