Skip to content

Commit ae0957e

Browse files
daviddkayiwa
david
authored andcommittedMar 1, 2013
TRUNK-3190: add unit test for HibernateConceptDAO.getConceptsByAnswer
(cherry picked from commit 34d76e2)
1 parent 945d5c6 commit ae0957e

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed
 

‎api/src/main/java/org/openmrs/api/db/ConceptDAO.java

+1
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ public List<ConceptSearchResult> getConcepts(String phrase, List<Locale> locales
243243

244244
/**
245245
* @see org.openmrs.api.ConceptService#getConceptsByAnswer(org.openmrs.Concept)
246+
* @should return concepts for the given answer concept
246247
*/
247248
public List<Concept> getConceptsByAnswer(Concept concept) throws DAOException;
248249

‎api/src/main/java/org/openmrs/api/db/hibernate/HibernateConceptDAO.java

-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,6 @@ public List<ConceptWord> getConceptWords(String phrase, List<Locale> locales, bo
635635
*/
636636
@SuppressWarnings("unchecked")
637637
public List<Concept> getConceptsByAnswer(Concept concept) {
638-
// TODO broken until Hibernate fixes component and HQL code
639638
String q = "select c from Concept c join c.answers ca where ca.answerConcept = :answer";
640639
Query query = sessionFactory.getCurrentSession().createQuery(q);
641640
query.setParameter("answer", concept);

‎api/src/test/java/org/openmrs/api/db/ConceptDAOTest.java

+15
Original file line numberDiff line numberDiff line change
@@ -439,4 +439,19 @@ public void getConcepts_shouldNotReturnConceptsWithMatchingNamesThatAreVoided()
439439
Assert.assertEquals(0, dao.getConcepts("VOIDED", null, false, new ArrayList<ConceptClass>(),
440440
new ArrayList<ConceptDatatype>()).size());
441441
}
442+
443+
/**
444+
* @see ConceptDAO#getConceptsByAnswer(Concept)
445+
* @verifies return concepts for the given answer concept
446+
*/
447+
@Test
448+
public void getConceptsByAnswer_shouldReturnConceptsForTheGivenAnswerConcept() throws Exception {
449+
Concept concept = dao.getConcept(22);
450+
List<Concept> conceptsByAnswer = dao.getConceptsByAnswer(concept);
451+
Assert.assertNotNull(conceptsByAnswer);
452+
Assert.assertEquals(1, conceptsByAnswer.size());
453+
Concept conceptByAnswer = conceptsByAnswer.get(0);
454+
Assert.assertEquals(21, conceptByAnswer.getConceptId().intValue());
455+
}
456+
442457
}

0 commit comments

Comments
 (0)
Please sign in to comment.