use of com.sdicons.json.model.JSONArray in project gocd by gocd.
the class MaterialRevisionsJsonBuilderTest method shouldShowEmptyFolderInJson.
@Test
public void shouldShowEmptyFolderInJson() {
svnMaterial.setFolder(null);
JSONArray revisions = buildJson();
assertThat(revisions.size(), is(1));
JSONObject jsonValue = (JSONObject) revisions.get(0);
assertThat(jsonValue.get("folder").render(false), is("\"\""));
}
use of com.sdicons.json.model.JSONArray in project gocd by gocd.
the class MaterialRevisionsJsonBuilderTest method shouldNotProcessPackageMaterialComment.
@Test
public void shouldNotProcessPackageMaterialComment() throws Exception {
HashMap<String, String> map = new HashMap<>();
map.put("TYPE", "PACKAGE_MATERIAL");
map.put("TRACKBACK_URL", "google.com");
map.put("COMMENT", "comment");
String packageMaterialComment = JsonHelper.toJsonString(map);
Modification modification = new Modification("user", packageMaterialComment, "some@com", new Date(), "1234");
materialRevisions = new MaterialRevisions(new MaterialRevision(MaterialsMother.packageMaterial(), modification));
JSONArray jsonArray = buildJson();
JSONObject modificationJson = (JSONObject) ((JSONArray) ((JSONObject) jsonArray.get(0)).get("modifications")).get(0);
assertThat(modificationJson.get("comment").render(false), is(JsonHelper.toJsonString(packageMaterialComment)));
}
use of com.sdicons.json.model.JSONArray in project gocd by gocd.
the class MaterialRevisionsJsonBuilderTest method shouldEscapeUsername.
@Test
public void shouldEscapeUsername() throws Exception {
JSONArray revisions = buildJson();
JSONObject revision = (JSONObject) revisions.get(0);
JSONArray jsonArray = (JSONArray) revision.get("modifications");
JSONObject modification = (JSONObject) jsonArray.get(0);
assertAttributeInJson(modification, "user", ModificationsMother.MOD_USER_WITH_HTML_CHAR);
assertAttributeInJson(modification, "comment", escapeHtml(ModificationsMother.MOD_COMMENT_3));
}
use of com.sdicons.json.model.JSONArray in project gocd by gocd.
the class MaterialRevisionsJsonBuilderTest method shouldShowEachModificationInJson.
@Test
public void shouldShowEachModificationInJson() {
JSONArray revisions = buildJson();
JSONObject revision = (JSONObject) revisions.get(0);
JSONArray jsonArray = (JSONArray) revision.get("modifications");
assertThat(jsonArray.size(), is(3));
JSONObject modification = (JSONObject) jsonArray.get(2);
assertAttributeInJson(modification, "user", ModificationsMother.MOD_USER);
assertAttributeInJson(modification, "comment", ModificationsMother.MOD_COMMENT);
assertAttributeInJson(modification, "date", DateUtils.formatISO8601(ModificationsMother.TWO_DAYS_AGO_CHECKIN));
JSONArray modifiedFiles = (JSONArray) modification.get("modifiedFiles");
assertThat(modifiedFiles.size(), is(1));
JSONObject file = (JSONObject) modifiedFiles.get(0);
assertAttributeInJson(file, "action", ModificationsMother.MOD_MODIFIED_ACTION.toString());
assertAttributeInJson(file, "fileName", ModificationsMother.MOD_FILE_BUILD_XML);
}
use of com.sdicons.json.model.JSONArray in project gocd by gocd.
the class MaterialRevisionsJsonBuilderTest method shouldContainModificationChanged.
@Test
public void shouldContainModificationChanged() throws Exception {
materialRevisions.getMaterialRevision(0).markAsChanged();
JSONArray revisions = buildJson();
JSONObject revision = (JSONObject) revisions.get(0);
JSONArray jsonArray = (JSONArray) revision.get("modifications");
assertAttributeInJson(revision, "changed", "true");
}
Aggregations