Search in sources :

Example 6 with JSONObject

use of com.sdicons.json.model.JSONObject 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");
}
Also used : JSONObject(com.sdicons.json.model.JSONObject) JSONArray(com.sdicons.json.model.JSONArray) Test(org.junit.Test)

Example 7 with JSONObject

use of com.sdicons.json.model.JSONObject 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

JSONObject (com.sdicons.json.model.JSONObject)7 JSONArray (com.sdicons.json.model.JSONArray)6 Test (org.junit.Test)6 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)2 JSONValue (com.sdicons.json.model.JSONValue)1 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