use of org.openmrs.ConceptDescription in project openmrs-core by openmrs.
the class ConceptServiceTest method saveConcept_shouldSaveANewConceptNumeric.
/**
* @see ConceptService#saveConcept(Concept)
*/
@Test
public void saveConcept_shouldSaveANewConceptNumeric() {
executeDataSet(INITIAL_CONCEPTS_XML);
Context.setLocale(Locale.US);
// this tests saving a never before in the database conceptnumeric
ConceptNumeric cn3 = new ConceptNumeric();
cn3.setDatatype(new ConceptDatatype(1));
cn3.setConceptClass(new ConceptClass(1));
ConceptName cn = new ConceptName("a brand new conceptnumeric", Locale.US);
cn3.addName(cn);
cn3.addDescription(new ConceptDescription("some description", null));
cn3.setHiAbsolute(50.0);
conceptService.saveConcept(cn3);
Concept thirdConcept = conceptService.getConcept(cn3.getConceptId());
assertTrue(thirdConcept instanceof ConceptNumeric);
ConceptNumeric thirdConceptNumeric = (ConceptNumeric) thirdConcept;
assertEquals("a brand new conceptnumeric", thirdConceptNumeric.getName(Locale.US).getName());
assertEquals(50.0, thirdConceptNumeric.getHiAbsolute(), 0);
}
use of org.openmrs.ConceptDescription in project openmrs-core by openmrs.
the class OrderServiceTest method getOrderFrequencies_shouldReturnUniqueFrequencies.
/**
* @see OrderService#getOrderFrequencies(String, java.util.Locale, boolean, boolean)
*/
@Test
public void getOrderFrequencies_shouldReturnUniqueFrequencies() {
executeDataSet("org/openmrs/api/include/OrderServiceTest-otherOrderFrequencies.xml");
final String searchPhrase = "once";
final Locale locale = Locale.ENGLISH;
List<OrderFrequency> orderFrequencies = orderService.getOrderFrequencies(searchPhrase, locale, true, false);
assertEquals(1, orderFrequencies.size());
final OrderFrequency expectedOrderFrequency = orderService.getOrderFrequency(100);
assertEquals(expectedOrderFrequency, orderFrequencies.get(0));
// Add a new name to the frequency concept so that our search phrase matches on 2
// concept names for the same frequency concept
Concept frequencyConcept = expectedOrderFrequency.getConcept();
final String newConceptName = searchPhrase + " A Day";
frequencyConcept.addName(new ConceptName(newConceptName, locale));
frequencyConcept.addDescription(new ConceptDescription("some description", null));
conceptService.saveConcept(frequencyConcept);
orderFrequencies = orderService.getOrderFrequencies(searchPhrase, locale, true, false);
assertEquals(1, orderFrequencies.size());
assertEquals(expectedOrderFrequency, orderFrequencies.get(0));
}
Aggregations