Search in sources :

Example 21 with TestOrder

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

the class OrderServiceTest method saveOrder_shouldDefaultToCareSettingAndOrderTypeDefinedInTheOrderContextIfNull.

/**
 * @see OrderService#saveOrder(org.openmrs.Order, OrderContext)
 */
@Test
public void saveOrder_shouldDefaultToCareSettingAndOrderTypeDefinedInTheOrderContextIfNull() {
    Order order = new TestOrder();
    order.setPatient(patientService.getPatient(7));
    Concept trimune30 = conceptService.getConcept(792);
    order.setConcept(trimune30);
    order.setOrderer(providerService.getProvider(1));
    order.setEncounter(encounterService.getEncounter(3));
    order.setDateActivated(new Date());
    OrderType expectedOrderType = orderService.getOrderType(2);
    CareSetting expectedCareSetting = orderService.getCareSetting(1);
    OrderContext orderContext = new OrderContext();
    orderContext.setOrderType(expectedOrderType);
    orderContext.setCareSetting(expectedCareSetting);
    order = orderService.saveOrder(order, orderContext);
    assertFalse(expectedOrderType.getConceptClasses().contains(trimune30.getConceptClass()));
    assertEquals(expectedOrderType, order.getOrderType());
    assertEquals(expectedCareSetting, order.getCareSetting());
}
Also used : DrugOrder(org.openmrs.DrugOrder) TestOrder(org.openmrs.TestOrder) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) Order(org.openmrs.Order) Concept(org.openmrs.Concept) OrderType(org.openmrs.OrderType) TestOrder(org.openmrs.TestOrder) CareSetting(org.openmrs.CareSetting) Date(java.util.Date) BaseContextSensitiveTest(org.openmrs.test.BaseContextSensitiveTest) OrderUtilTest(org.openmrs.order.OrderUtilTest) Test(org.junit.Test)

Aggregations

TestOrder (org.openmrs.TestOrder)21 Test (org.junit.Test)19 BaseContextSensitiveTest (org.openmrs.test.BaseContextSensitiveTest)18 OrderUtilTest (org.openmrs.order.OrderUtilTest)13 Date (java.util.Date)12 Order (org.openmrs.Order)12 DrugOrder (org.openmrs.DrugOrder)10 Matchers.containsInAnyOrder (org.hamcrest.Matchers.containsInAnyOrder)9 Concept (org.openmrs.Concept)9 Patient (org.openmrs.Patient)8 Encounter (org.openmrs.Encounter)6 CareSetting (org.openmrs.CareSetting)4 BindException (org.springframework.validation.BindException)3 Errors (org.springframework.validation.Errors)3 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Ignore (org.junit.Ignore)2 GlobalProperty (org.openmrs.GlobalProperty)2 OrderType (org.openmrs.OrderType)2 ConceptService (org.openmrs.api.ConceptService)2