@Test public void testToJsonBehavior() throws XWikiException { SolvedData data = new SolvedData("1", "200100", Arrays.asList("PM:1001", "PM:1002")); JSONObject json = data.toJSON(); Assert.assertEquals(3, json.length()); Assert.assertEquals(SolvedData.STATUS_PROPERTY_NAME, json.getString(SolvedData.STATUS_JSON_KEY)); Assert.assertEquals("200100", json.getString(SolvedData.NOTES_JSON_KEY)); Assert.assertEquals("PM:1001", ((JSONArray) json.get(SolvedData.PUBMED_ID_JSON_KEY)).get(0)); Assert.assertEquals("PM:1002", ((JSONArray) json.get(SolvedData.PUBMED_ID_JSON_KEY)).get(1)); data = new SolvedData("0", null, null); json = data.toJSON(); Assert.assertEquals(1, json.length()); Assert.assertEquals(SolvedData.STATUS_UNSOLVED, json.getString(SolvedData.STATUS_JSON_KEY)); }
public JSONObject toJSON() { Collection<String> properties = Arrays.asList(STATUS_PROPERTY_NAME, NOTES_PROPERTY_NAME, PUBMED_ID_PROPERTY_NAME); return this.toJSON(properties); }
SolvedData { public JSONObject toJSON() { Collection<String> properties = Arrays.asList(STATUS_PROPERTY_NAME, NOTES_PROPERTY_NAME, PUBMED_ID_PROPERTY_NAME); return this.toJSON(properties); } }
SolvedData { public JSONObject toJSON() { Collection<String> properties = Arrays.asList(STATUS_PROPERTY_NAME, NOTES_PROPERTY_NAME, PUBMED_ID_PROPERTY_NAME); return this.toJSON(properties); } SolvedData(String status, String notes, List<String> pubmedIds);  SolvedData(JSONObject jsonBlock); }
SolvedData { public JSONObject toJSON() { Collection<String> properties = Arrays.asList(STATUS_PROPERTY_NAME, NOTES_PROPERTY_NAME, PUBMED_ID_PROPERTY_NAME); return this.toJSON(properties); } SolvedData(String status, String notes, List<String> pubmedIds);  SolvedData(JSONObject jsonBlock); List<String> getPubmedIds(); String getNotes(); String getStatus(); void setPubmedIds(List<String> pubmedIds); void setNotes(String notes); void setStatus(String status); boolean isSolved(); boolean isEmpty(); JSONObject toJSON(); JSONObject toJSON(Collection<String> selectedFieldNames); }
SolvedData { public JSONObject toJSON() { Collection<String> properties = Arrays.asList(STATUS_PROPERTY_NAME, NOTES_PROPERTY_NAME, PUBMED_ID_PROPERTY_NAME); return this.toJSON(properties); } SolvedData(String status, String notes, List<String> pubmedIds);  SolvedData(JSONObject jsonBlock); List<String> getPubmedIds(); String getNotes(); String getStatus(); void setPubmedIds(List<String> pubmedIds); void setNotes(String notes); void setStatus(String status); boolean isSolved(); boolean isEmpty(); JSONObject toJSON(); JSONObject toJSON(Collection<String> selectedFieldNames); static final String STATUS_PROPERTY_NAME; static final String STATUS_JSON_KEY; static final String STATUS_UNSOLVED; static final String PUBMED_ID_PROPERTY_NAME; static final String PUBMED_ID_JSON_KEY; static final String NOTES_JSON_KEY; static final String NOTES_PROPERTY_NAME; static final List<String> STATUS_VALUES; }