/** * @see LocationService#getAllLocationAttributeTypes() */ @Test public void getAllLocationAttributeTypes_shouldReturnAllLocationAttributeTypesIncludingRetiredOnes() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); Assert.assertEquals(2, Context.getLocationService().getAllLocationAttributeTypes().size()); }
/** * @see LocationService#purgeLocationAttributeType(LocationAttributeType) */ @Test public void purgeLocationAttributeType_shouldCompletelyRemoveALocationAttributeType() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); Assert.assertEquals(2, Context.getLocationService().getAllLocationAttributeTypes().size()); Context.getLocationService().purgeLocationAttributeType(Context.getLocationService().getLocationAttributeType(2)); Assert.assertEquals(1, Context.getLocationService().getAllLocationAttributeTypes().size()); }
/** * @see LocationService#saveLocationAttributeType(LocationAttributeType) */ @Test public void saveLocationAttributeType_shouldEditAnExistingLocationAttributeType() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); LocationService service = Context.getLocationService(); Assert.assertEquals(2, service.getAllLocationAttributeTypes().size()); LocationAttributeType lat = service.getLocationAttributeType(1); lat.setName("A new name"); service.saveLocationAttributeType(lat); Assert.assertEquals(2, service.getAllLocationAttributeTypes().size()); Assert.assertEquals("A new name", service.getLocationAttributeType(1).getName()); }
/** * @see LocationService#saveLocationAttributeType(LocationAttributeType) */ @Test public void saveLocationAttributeType_shouldCreateANewLocationAttributeType() { executeDataSet(LOC_ATTRIBUTE_DATA_XML); Assert.assertEquals(2, Context.getLocationService().getAllLocationAttributeTypes().size()); LocationAttributeType lat = new LocationAttributeType(); lat.setName("Another one"); lat.setDatatypeClassname(FreeTextDatatype.class.getName()); Context.getLocationService().saveLocationAttributeType(lat); Assert.assertNotNull(lat.getId()); Assert.assertEquals(3, Context.getLocationService().getAllLocationAttributeTypes().size()); }
"address3", "address4", "address5", "address6", "address7", "address8", "address9", "address10", "address11", "address12", "address13", "address14", "address15", "retireReason"); super.validateAttributes(location, errors, Context.getLocationService().getAllLocationAttributeTypes());
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<LocationAttributeType> doGetAll(RequestContext context) throws ResponseException { return new NeedsPaging<LocationAttributeType>(service().getAllLocationAttributeTypes(), context); }
/** * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doSearch(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<LocationAttributeType> doSearch(RequestContext context) { // TODO: Should be a LocationAttributeType search method in LocationService List<LocationAttributeType> allAttrs = service().getAllLocationAttributeTypes(); List<LocationAttributeType> queryResult = new ArrayList<LocationAttributeType>(); for (LocationAttributeType locAttr : allAttrs) { if (Pattern.compile(Pattern.quote(context.getParameter("q")), Pattern.CASE_INSENSITIVE) .matcher(locAttr.getName()).find()) { queryResult.add(locAttr); } } return new NeedsPaging<LocationAttributeType>(queryResult, context); } }
/** * @see org.openmrs.module.webservices.rest.web.v1_0.controller.MainResourceControllerTest#getAllCount() */ @Override public long getAllCount() { return Context.getLocationService().getAllLocationAttributeTypes().size(); }
/** * @see LocationAttributeTypeController#createLocationAttributeType(SimpleObject,WebRequest) * @verifies create a new LocationAttributeType */ @Test public void createLocationAttributeType_shouldCreateANewLocationAttributeType() throws Exception { int before = Context.getLocationService().getAllLocationAttributeTypes().size(); String json = "{ \"name\":\"Some attributeType\",\"description\":\"Attribute Type for location\",\"datatypeClassname\":\"org.openmrs.customdatatype.datatype.FreeTextDatatype\"}"; handle(newPostRequest(getURI(), json)); Assert.assertEquals(before + 1, Context.getLocationService().getAllLocationAttributeTypes().size()); }