Enquiry extends BaseModel { @Override public List<BaseModel> getPotentialMatchingModels(PotentialMatchRepository potentialMatchRepo, ChildRepository childRepository, EnquiryRepository enquiryRepository) throws JSONException { return getMatchesByConfirmationStatus(potentialMatchRepo, childRepository, false); } Enquiry();  Enquiry(String content, String createdBy);  Enquiry(Cursor cursor);  Enquiry(String enquiryJSON); boolean isValid(); JSONObject values(); @Override List<BaseModel> getConfirmedMatchingModels(PotentialMatchRepository potentialMatchRepository, ChildRepository childRepository, EnquiryRepository enquiryRepository); @Override List<BaseModel> getPotentialMatchingModels(PotentialMatchRepository potentialMatchRepo, ChildRepository childRepository, EnquiryRepository enquiryRepository); static List<String> idsFromMatches(Collection<PotentialMatch> potentialMatches); @Override String getApiPath(); @Override String getApiParameter(); @Override String getRecordedAudio(); static final String ENQUIRY_FORM_NAME; static final String FIELD_ATTACHMENTS; }
@Test public void enquiryShouldGetPotentialMatches() throws JSONException, SQLException { Child child1 = new Child("id1", "owner1", "{'test':'a','_id':'child_id_1' }"); Child child2 = new Child("id2", "owner1", "{'test':'a','_id':'child_id_2' }"); Child child3 = new Child("id3", "owner1", "{'test':'a','_id':'child_id_3' }"); childRepository.createOrUpdate(child1); childRepository.createOrUpdate(child2); childRepository.createOrUpdate(child3); potentialMatchRepository.createOrUpdate(new PotentialMatch("enquiry_id_1", "child_id_1", "potential_match_id_1")); potentialMatchRepository.createOrUpdate(new PotentialMatch("enquiry_id_1", "child_id_3", "potential_match_id_2")); String enquiryJSON = "{\n" + "\"synced\":\"true\",\n" + "\"_id\":\"enquiry_id_1\",\n" + "\"created_by\":\"some guy\"" + "}"; Enquiry enquiry = new Enquiry(enquiryJSON); List<BaseModel> children = enquiry.getPotentialMatchingModels(potentialMatchRepository, childRepository, null); assertEquals(2, children.size()); assertTrue(children.contains(child1)); assertTrue(children.contains(child3)); }
@Test public void shouldNotReturnConfirmedMatchesForPotentialMatches() throws JSONException, SQLException { Child child1 = new Child("id1", "owner1", "{'test':'a','_id':'child_id_1' }"); Child child2 = new Child("id2", "owner1", "{'test':'a','_id':'child_id_2' }"); childRepository.createOrUpdate(child1); childRepository.createOrUpdate(child2); potentialMatchRepository.createOrUpdate(new PotentialMatch("enquiry_id_1", "child_id_1", "potential_match_id_1")); potentialMatchRepository.createOrUpdate(new PotentialMatch("enquiry_id_1", "child_id_2", "potential_match_id_2", true)); String enquiryJSON = "{\n" + "\"synced\":\"true\",\n" + "\"_id\":\"enquiry_id_1\",\n" + "\"created_by\":\"some guy\"" + "}"; Enquiry enquiry = new Enquiry(enquiryJSON); List<BaseModel> children = enquiry.getPotentialMatchingModels(potentialMatchRepository, childRepository, null); assertEquals(1, children.size()); assertTrue(children.contains(child1)); }