Child extends BaseModel { public JSONObject values() throws JSONException { List<Object> names = asList(names()); Iterable<Object> systemFields = Iterables.transform(ChildTableColumn.systemFields(), new Function<ChildTableColumn, Object>() { @Override public Object apply(ChildTableColumn childTableColumn) { return childTableColumn.getColumnName(); } }); Iterables.removeAll(names, Lists.newArrayList(systemFields)); return new JSONObject(this, names.toArray(new String[names.size()])); } Child();  Child(Parcel parcel);  Child(String id, String createdBy, String content);  Child(String id, String createdBy, String content, boolean synced);  Child(String content);  Child(String content, boolean synced); boolean isValid(); JSONObject values(); @Override boolean isSynced(); @Override List<BaseModel> getConfirmedMatchingModels(PotentialMatchRepository potentialMatchRepository, ChildRepository childRepository, EnquiryRepository enquiryRepository); @Override List<BaseModel> getPotentialMatchingModels(PotentialMatchRepository potentialMatchRepo, ChildRepository childRepo, EnquiryRepository enquiryRepository); boolean isNew(); JSONArray getPhotos(); static List<String> idsFromMatches(Collection<PotentialMatch> potentialMatches); @Override String getRecordedAudio(); static final String CHILD_FORM_NAME; }
@Test public void shouldRemoveFieldIfBlank() throws JSONException { Child child = new Child(); child.put("name", "test"); assertThat(child.values().names().length(), equalTo(1)); child.put("name", "\r \n \r \n"); assertNull(child.values().names()); }
@Test public void valuesShouldReturnAllExceptSystemFields() throws JSONException, IOException { Child child = new Child(); child.put("test1", "value1"); for (Database.ChildTableColumn column : Database.ChildTableColumn.systemFields()) { child.put(column.getColumnName(), "test"); } assertThat(child.values(), equalJSONIgnoreOrder("{\"test1\":\"value1\"}")); }