Child extends BaseModel { public boolean isNew() { return !has(internal_id.getColumnName()); } 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 shouldBeNewIfThereIsNoID() throws JSONException { Child child = new Child("id1", "user1", "{ 'test1' : 'value1' }"); assertThat(child.isNew(), is(true)); }
@Test public void shouldNotBeNewIfThereIsID() throws JSONException { Child child = new Child(); child.put(internal_id.getColumnName(), "xyz"); assertThat(child.isNew(), is(false)); }