/** * @see OrderService#getOrderTypes(boolean) */ @Test public void getOrderTypes_shouldGetAllNonRetiredOrderTypesIfIncludeRetiredIsSetToFalse() { assertEquals(11, orderService.getOrderTypes(false).size()); }
/** * @see OrderService#getOrderTypes(boolean) */ @Test public void getOrderTypes_shouldGetAllOrderTypesIfIncludeRetiredIsSetToTrue() { assertEquals(14, orderService.getOrderTypes(true).size()); }
/** * @see OrderService#saveOrderType(org.openmrs.OrderType) */ @Test public void saveOrderType_shouldAddANewOrderTypeToTheDatabase() { int orderTypeCount = orderService.getOrderTypes(true).size(); OrderType orderType = new OrderType(); orderType.setName("New Order"); orderType.setJavaClassName("org.openmrs.NewTestOrder"); orderType.setDescription("New order type for testing"); orderType.setRetired(false); orderType = orderService.saveOrderType(orderType); assertNotNull(orderType); assertEquals("New Order", orderType.getName()); assertNotNull(orderType.getId()); assertEquals((orderTypeCount + 1), orderService.getOrderTypes(true).size()); }
for (OrderType ot : Context.getOrderService().getOrderTypes(true)) { if (ot != null) {
@Override public long getAllCount() { return service.getOrderTypes(false).size(); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<OrderType> doSearch(RequestContext context) { List<OrderType> orderTypes = Context.getOrderService().getOrderTypes(context.getIncludeAll()); for (Iterator<OrderType> iterator = orderTypes.iterator(); iterator.hasNext();) { OrderType ot = iterator.next(); if (!Pattern.compile(Pattern.quote(context.getParameter("q")), Pattern.CASE_INSENSITIVE).matcher(ot.getName()) .find()) { iterator.remove(); } } return new NeedsPaging<OrderType>(orderTypes, context); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<OrderType> doGetAll(RequestContext context) { return new NeedsPaging<OrderType>(Context.getOrderService().getOrderTypes(context.getIncludeAll()), context); }
List<OrderType> orderTypes = Context.getOrderService().getOrderTypes(false); List<ConceptClass> orderableConceptClasses = getOrderableConceptClasses(orderTypes);
@Test public void shouldListAllOrderTypesIncludingRetiredOnesIfIncludeAllIsSetToTrue() throws Exception { SimpleObject result = deserialize(handle(newGetRequest(getURI(), new Parameter("includeAll", "true")))); assertNotNull(result); assertEquals(service.getOrderTypes(true).size(), Util.getResultsSize(result)); }
@Test public void shouldCreateANewOrderType() throws Exception { OrderService orderService = Context.getOrderService(); int orderTypeCount = orderService.getOrderTypes(true).size(); SimpleObject orderType = new SimpleObject(); orderType.add("name", "New Order"); orderType.add("javaClassName", "org.openmrs.NewTestOrder"); orderType.add("description", "New order type for testing"); MockHttpServletRequest req = newPostRequest(getURI(), orderType); SimpleObject newOrder = deserialize(handle(req)); assertNotNull(newOrder); List<OrderType> orderTypes = service.getOrderTypes(true); assertEquals(++orderTypeCount, orderTypes.size()); assertNotNull(PropertyUtils.getProperty(newOrder, "javaClassName")); assertEquals(orderType.get("name"), Util.getByPath(newOrder, "name")); assertEquals(orderType.get("javaClassName"), Util.getByPath(newOrder, "javaClassName")); assertEquals(orderType.get("description"), Util.getByPath(newOrder, "description")); }