Search in sources :

Example 6 with JSONArray

use of com.sdicons.json.model.JSONArray in project gocd by gocd.

the class MaterialRevisionsJsonBuilderTest method buildJson.

private JSONArray buildJson() {
    materialRevisions.accept(builder);
    List json = builder.json();
    return (JSONArray) JsonUtils.parseJsonValue(json);
}
Also used : JSONArray(com.sdicons.json.model.JSONArray) List(java.util.List)

Example 7 with JSONArray

use of com.sdicons.json.model.JSONArray in project gocd by gocd.

the class MaterialRevisionsJsonBuilderTest method shouldShowEachMaterialInJson.

@Test
public void shouldShowEachMaterialInJson() {
    JSONArray revisions = buildJson();
    assertThat(revisions.size(), is(1));
    JSONObject jsonValue = (JSONObject) revisions.get(0);
    assertThat(jsonValue.get("scmType").render(false), is("\"Subversion\""));
    assertThat(jsonValue.get("location").render(false), is("\"http://url\""));
    assertThat(jsonValue.get("folder").render(false), is("\"svn-folder\""));
    MaterialRevision materialRevision = materialRevisions.getMaterialRevision(0);
    String revision = materialRevision.getRevision().getRevision();
    assertThat(jsonValue.get("revision").render(false), is("\"" + revision + "\""));
    assertThat(jsonValue.get("action").render(false), is("\"Modified\""));
    assertThat(jsonValue.get("user").render(false), is("\"" + ModificationsMother.MOD_USER_WITH_HTML_CHAR + "\""));
    String date = DateUtils.formatISO8601(materialRevision.getDateOfLatestModification());
    assertThat(jsonValue.get("date").render(false), is("\"" + date + "\""));
}
Also used : JSONObject(com.sdicons.json.model.JSONObject) JSONArray(com.sdicons.json.model.JSONArray) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Test(org.junit.Test)

Aggregations

JSONArray (com.sdicons.json.model.JSONArray)7 JSONObject (com.sdicons.json.model.JSONObject)6 Test (org.junit.Test)6 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)2 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)1 Modification (com.thoughtworks.go.domain.materials.Modification)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1