Search in sources :

Example 16 with ConceptSearchResult

use of org.openmrs.ConceptSearchResult in project openmrs-core by openmrs.

the class ConceptDAOTest method getConcepts_shouldReturnCorrectResultsIfAConceptNameContainsSameWordMoreThanOnce.

/**
 * @see {@link
 *      ConceptDAO#getConcepts(String,List<Locale>,null,List<ConceptClass>,List<ConceptClass>,
 *      List<ConceptDatatype>,List<ConceptDatatype>,Concept,Integer,Integer)}
 */
@SuppressWarnings("unchecked")
@Test
@Ignore
public void getConcepts_shouldReturnCorrectResultsIfAConceptNameContainsSameWordMoreThanOnce() {
    ConceptService cs = Context.getConceptService();
    ConceptClass cc = cs.getConceptClass(1);
    Locale locale = Locale.ENGLISH;
    ConceptDatatype dt = cs.getConceptDatatype(4);
    Concept c1 = new Concept();
    ConceptName cn1a = new ConceptName("ONE TERM", locale);
    c1.addName(cn1a);
    c1.setConceptClass(cc);
    c1.setDatatype(dt);
    cs.saveConcept(c1);
    ConceptName cn1b = new ConceptName("ONE TO ONE", locale);
    cn1b.setConceptNameType(ConceptNameType.FULLY_SPECIFIED);
    cn1b.setLocalePreferred(true);
    c1.addName(cn1b);
    cs.saveConcept(c1);
    Assert.assertTrue(cn1a.isSynonym());
    Assert.assertTrue(cn1b.getConceptNameId() > cn1a.getConceptNameId());
    Concept c2 = new Concept();
    ConceptName cn2a = new ConceptName("ONE TO MANY", locale);
    c2.addName(cn2a);
    c2.setConceptClass(cc);
    c2.setDatatype(dt);
    cs.saveConcept(c2);
    updateSearchIndex();
    List<ConceptSearchResult> searchResults1 = dao.getConcepts("one", Collections.singletonList(locale), false, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, Collections.EMPTY_LIST, null, null, null);
    Assert.assertEquals(2, searchResults1.size());
    Assert.assertEquals(c1, searchResults1.get(0).getConcept());
    Assert.assertEquals(cn1b, searchResults1.get(0).getConceptName());
}
Also used : Locale(java.util.Locale) Concept(org.openmrs.Concept) ConceptClass(org.openmrs.ConceptClass) ConceptName(org.openmrs.ConceptName) ConceptSearchResult(org.openmrs.ConceptSearchResult) ConceptService(org.openmrs.api.ConceptService) ConceptDatatype(org.openmrs.ConceptDatatype) Ignore(org.junit.Ignore) Test(org.junit.Test) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest)

Aggregations

ConceptSearchResult (org.openmrs.ConceptSearchResult)16 Test (org.junit.Test)10 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)10 Locale (java.util.Locale)8 Concept (org.openmrs.Concept)8 ArrayList (java.util.ArrayList)5 SimpleObject (org.openmrs.ui.framework.SimpleObject)5 ConceptName (org.openmrs.ConceptName)4 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)4 Method (java.lang.reflect.Method)2 Ignore (org.junit.Ignore)2 ConceptClass (org.openmrs.ConceptClass)2 ConceptDatatype (org.openmrs.ConceptDatatype)2 ConceptSource (org.openmrs.ConceptSource)2 ConceptService (org.openmrs.api.ConceptService)2 CodedOrFreeTextAnswer (org.openmrs.module.emrapi.diagnosis.CodedOrFreeTextAnswer)2 IOException (java.io.IOException)1 ConceptDescription (org.openmrs.ConceptDescription)1 ConceptStopWord (org.openmrs.ConceptStopWord)1 DiagnosesFragmentController (org.openmrs.module.coreapps.fragment.controller.DiagnosesFragmentController)1