Search in sources :

Example 46 with ConceptDescription

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);
}
Also used : OpenmrsMatchers.hasConcept(org.openmrs.test.OpenmrsMatchers.hasConcept) Concept(org.openmrs.Concept) ConceptClass(org.openmrs.ConceptClass) ConceptNumeric(org.openmrs.ConceptNumeric) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) ConceptDatatype(org.openmrs.ConceptDatatype) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) Test(org.junit.Test)

Example 47 with ConceptDescription

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));
}
Also used : Locale(java.util.Locale) Concept(org.openmrs.Concept) ConceptName(org.openmrs.ConceptName) ConceptDescription(org.openmrs.ConceptDescription) OrderFrequency(org.openmrs.OrderFrequency) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)47 ConceptDescription (org.openmrs.ConceptDescription)47 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)47 ConceptName (org.openmrs.ConceptName)41 Concept (org.openmrs.Concept)32 ConceptDatatype (org.openmrs.ConceptDatatype)32 ConceptClass (org.openmrs.ConceptClass)31 OpenmrsMatchers.hasConcept (org.openmrs.test.OpenmrsMatchers.hasConcept)20 Locale (java.util.Locale)14 OrderFrequency (org.openmrs.OrderFrequency)5 ConceptMap (org.openmrs.ConceptMap)3 ConceptNumeric (org.openmrs.ConceptNumeric)3 ConceptService (org.openmrs.api.ConceptService)3 BindException (org.springframework.validation.BindException)3 Errors (org.springframework.validation.Errors)3 ConceptComplex (org.openmrs.ConceptComplex)2 ConceptProposal (org.openmrs.ConceptProposal)2 OrderUtilTest (org.openmrs.order.OrderUtilTest)2 HashSet (java.util.HashSet)1 ConceptNameTag (org.openmrs.ConceptNameTag)1