Refine search
/** * @see Concept#addSetMember(Concept) */ @Test public void addSetMember_shouldPlaceTheNewConceptLastInTheList() { Concept concept = new Concept(); Concept setMember1 = new Concept(1); concept.addSetMember(setMember1, 3); Concept setMember2 = new Concept(2); concept.addSetMember(setMember2); Assert.assertEquals(setMember2, concept.getSetMembers().get(1)); }
/** * @see Concept#addSetMember(Concept,int) */ @Test public void addSetMember_shouldAssignTheCallingComponentAsParentToTheConceptSet() { Concept concept = new Concept(); Concept setMember = new Concept(11); concept.addSetMember(setMember); ConceptSet conceptSet = (ConceptSet) concept.getConceptSets().toArray()[0]; Assert.assertEquals(concept, conceptSet.getConceptSet()); }
/** * @see Concept#addSetMember(Concept,int) */ @Test public void addSetMember_shouldAssignTheGivenConceptAsAConceptSet() { Concept concept = new Concept(); Concept setMember = new Concept(2); concept.addSetMember(setMember, 0); ConceptSet conceptSet = (ConceptSet) concept.getConceptSets().toArray()[0]; Assert.assertEquals(setMember, conceptSet.getConcept()); }
/** * @see ObsService#getObservations(List,List,List,List,List,List,List,Integer,Integer,Date,Date,boolean) * @see ObsService#getObservations(List,List,List,List,List,List,List,Integer,Integer,Date,Date,boolean,String) */ @Test public void getObservations_shouldGetAllObsWithQuestionConceptInGivenQuestionsParameter() { ObsService obsService = Context.getObsService(); List<Obs> obss = obsService.getObservations(null, null, Collections.singletonList(new Concept(5497)), null, null, null, null, null, null, null, null, false, null); Assert.assertEquals(2, obss.size()); }
/** * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean) * @see ObsService#getObservationCount(List,List,List,List,List,List,Integer,Date,Date,boolean,String) */ @Test public void getObservationCount_shouldGetCountOfObsWithQuestionConceptInGivenQuestionsParameter() { ObsService obsService = Context.getObsService(); Integer count = obsService.getObservationCount(null, null, Collections.singletonList(new Concept(5497)), null, null, null, null, null, null, false, null); Assert.assertEquals(2, count.intValue()); }
@Test public void shouldChangeConceptSetReferenceToParentConcept() { Concept c = new Concept(123); c.addSetMember(new Concept(1)); c.addSetMember(new Concept(2)); ConceptNumeric cn = new ConceptNumeric(c); for (ConceptSet cSet : cn.getConceptSets()) { Assert.assertSame(cn, cSet.getConceptSet()); } }
/** * When asked for a collection of compatible names, the returned collection should not include * any incompatible names. * * @see Concept#getCompatibleNames(Locale) */ @Test public void getCompatibleNames_shouldExcludeIncompatibleLanguageLocales() { Concept concept = new Concept(); concept.addName(new ConceptName("some name", new Locale("fr"))); Assert.assertEquals(0, concept.getCompatibleNames(new Locale("en")).size()); }
/** * @see Concept#getDescription(Locale,null) */ @Test public void getDescription_shouldNotReturnLanguageOnlyMatchForExactMatches() { Concept mockConcept = new Concept(); mockConcept.addDescription(new ConceptDescription("en desc", new Locale("en"))); Assert.assertNull(mockConcept.getDescription(new Locale("en", "US"), true)); }
/** * @see Concept#getName(Locale,null) */ @Test public void getName_shouldReturnNullIfNoNamesAreFoundInLocaleGivenExactEqualsTrue() { Locale nonMatchingNameLocale = new Locale("en", "US"); Locale localeToSearch = new Locale("en"); Concept concept = new Concept(); concept.addName(new ConceptName("some name", nonMatchingNameLocale)); Assert.assertNull(concept.getName(localeToSearch, true)); }
/** * @see Concept#getName() */ @Test public void getName_shouldReturnNameAnyNameIfNoLocaleMatchGivenExactEqualsFalse() { Locale locale = new Locale("en"); Locale localeToSearch = new Locale("fr"); Concept concept = new Concept(); concept.addName(new ConceptName("Test Concept", locale)); Assert.assertNotNull((concept.getName(localeToSearch, false))); }
/** * @see Concept#getDescription(Locale,null) */ @Test public void getDescription_shouldReturnMatchOnLanguageOnly() { Concept mockConcept = new Concept(); mockConcept.addDescription(new ConceptDescription("en desc", new Locale("en"))); Assert.assertEquals("en desc", mockConcept.getDescription(new Locale("en", "US"), false).getDescription()); }
/** * @see Concept#getDescription(Locale,null) */ @Test public void getDescription_shouldReturnMatchOnLocaleExactly() { Concept mockConcept = new Concept(); mockConcept.addDescription(new ConceptDescription("en_US desc", new Locale("en", "US"))); Assert.assertEquals("en_US desc", mockConcept.getDescription(new Locale("en", "US"), false).getDescription()); }
/** * @see Order#hasSameOrderableAs(Order) */ @Test public void hasSameOrderableAs_shouldReturnFalseIfTheConceptOfTheOrdersDoNotMatch() throws Exception { Order order = new Order(); order.setConcept(new Concept()); Order otherOrder = new Order(); otherOrder.setConcept(new Concept()); assertFalse(order.hasSameOrderableAs(otherOrder)); }
/** * @see DrugOrder#hasSameOrderableAs(Order) */ @Test public void hasSameOrderableAs_shouldReturnFalseIfBothDrugsAreNullAndTheConceptsAreDifferent() { DrugOrder order = new DrugOrder(); order.setConcept(new Concept()); DrugOrder otherOrder = new DrugOrder(); otherOrder.setConcept(new Concept()); assertFalse(order.hasSameOrderableAs(otherOrder)); }
/** * @see ObsService#getObservationsByPersonAndConcept(Person,Concept) */ @Test public void getObservationsByPersonAndConcept_shouldGetObservationsMatchingPersonAndQuestion() { ObsService obsService = Context.getObsService(); List<Obs> obss = obsService.getObservationsByPersonAndConcept(new Person(7), new Concept(5089)); Assert.assertEquals(3, obss.size()); Assert.assertEquals(16, obss.get(0).getObsId().intValue()); Assert.assertEquals(10, obss.get(1).getObsId().intValue()); Assert.assertEquals(7, obss.get(2).getObsId().intValue()); }