Child extends BaseModel { public boolean isValid() { int numberOfNonInternalFields = names().length(); for (ChildTableColumn field : ChildTableColumn.internalFields()) { if (has(field.getColumnName())) { numberOfNonInternalFields--; } } return numberOfNonInternalFields > 0; } 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 testAtLeastOneFieldIsFilledExcludingIdAndOwner() throws JSONException { Child child = new Child("id1", "owner1", null); assertThat(child.isValid(), is(false)); child.put("test1", "value1"); assertThat(child.isValid(), is(true)); child.remove("test1"); assertThat(child.isValid(), is(false)); }
@Test public void testAtLeastOneFieldIsFilledExcludingOwner() throws JSONException { Child child = new Child("id1", "owner1", ""); Assert.assertThat(child.isValid(), is(false)); child.put("test1", "value1"); Assert.assertThat(child.isValid(), is(true)); child.remove("test1"); Assert.assertThat(child.isValid(), is(false)); }