Child extends BaseModel { @Override public List<BaseModel> getPotentialMatchingModels(PotentialMatchRepository potentialMatchRepo, ChildRepository childRepo, EnquiryRepository enquiryRepository) throws JSONException { return getMatchesByConfirmationStatus(potentialMatchRepo, enquiryRepository, false); } 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 shouldGetPotentialMatches() throws JSONException, SQLException { Child child = new Child("id_1", "", "{'_id' : 'child_id_1'}"); String enquiryJSON = "{\n" + "\"synced\":\"true\",\n" + "\"_id\":\"enquiry_id_1\",\n" + "\"created_by\":\"some guy\"" + "}"; Enquiry enquiry = new Enquiry(enquiryJSON); enquiryRepository.createOrUpdate(enquiry); String enquiryJSON2 = "{\n" + "\"synced\":\"true\",\n" + "\"_id\":\"enquiry_id_2\",\n" + "\"created_by\":\"some guy\"" + "}"; enquiryRepository.createOrUpdate(new Enquiry(enquiryJSON2)); potentialMatchRepository.createOrUpdate(new PotentialMatch("enquiry_id_1", "child_id_1", "potential_match_id_1")); potentialMatchRepository.createOrUpdate(new PotentialMatch("enquiry_id_2", "child_id_2", "potential_match_id_2")); List<BaseModel> enquiries = child.getPotentialMatchingModels(potentialMatchRepository, null, enquiryRepository); assertThat(enquiries.size(), is(1)); assertEquals(enquiry.getUniqueId(), enquiries.get(0).getUniqueId()); }
@Test public void shouldNotReturnConfirmedMatchesForPotentialMatches() throws JSONException, SQLException { Child child = new Child("id_1", "", "{'_id' : 'child_id_1'}"); String enquiryJSON = "{\n" + "\"synced\":\"true\",\n" + "\"_id\":\"enquiry_id_1\",\n" + "\"created_by\":\"some guy\"" + "}"; Enquiry enquiry = new Enquiry(enquiryJSON); enquiryRepository.createOrUpdate(enquiry); String enquiryJSON2 = "{\n" + "\"synced\":\"true\",\n" + "\"_id\":\"enquiry_id_2\",\n" + "\"created_by\":\"some guy\"" + "}"; enquiryRepository.createOrUpdate(new Enquiry(enquiryJSON2)); potentialMatchRepository.createOrUpdate(new PotentialMatch("enquiry_id_1", "child_id_1", "potential_match_id_1")); potentialMatchRepository.createOrUpdate(new PotentialMatch("enquiry_id_2", "child_id_1", "potential_match_id_2", true)); List<BaseModel> enquiries = child.getPotentialMatchingModels(potentialMatchRepository, null, enquiryRepository); assertThat(enquiries.size(), is(1)); assertEquals(enquiry.getUniqueId(), enquiries.get(0).getUniqueId()); }