@Test public void getAllGlobalProperties_shouldReturnAllGlobalPropertiesInTheDatabase() { int allGlobalPropertiesSize = adminService.getAllGlobalProperties().size(); executeDataSet(ADMIN_INITIAL_DATA_XML); assertEquals(allGlobalPropertiesSize + 9, adminService.getAllGlobalProperties().size()); }
@Test public void purgeGlobalProperties_shouldDeleteGlobalPropertiesFromDatabase() { int originalSize = adminService.getAllGlobalProperties().size(); List<GlobalProperty> props = new ArrayList<>(); props.add(new GlobalProperty("a.property.key", "something")); props.add(new GlobalProperty("a.property.KEY", "somethingelse")); adminService.saveGlobalProperties(props); int afterSaveSize = adminService.getAllGlobalProperties().size(); assertEquals(originalSize + 1, afterSaveSize); adminService.purgeGlobalProperties(props); int afterPurgeSize = adminService.getAllGlobalProperties().size(); assertEquals(originalSize, afterPurgeSize); }
@Test public void saveGlobalProperties_shouldSavePropertiesWithCaseDifferenceOnly() { int originalSize = adminService.getAllGlobalProperties().size(); List<GlobalProperty> props = new ArrayList<>(); props.add(new GlobalProperty("a.property.key", "something")); props.add(new GlobalProperty("a.property.KEY", "somethingelse")); adminService.saveGlobalProperties(props); // make sure that we now have two properties props = adminService.getAllGlobalProperties(); assertEquals(originalSize + 1, props.size()); assertTrue(props.contains(adminService.getGlobalPropertyObject("a.property.KEY"))); }
@Test public void purgeGlobalProperty_shouldDeleteGlobalPropertyFromDatabase() { executeDataSet(ADMIN_INITIAL_DATA_XML); int allGlobalPropertiesSize = adminService.getAllGlobalProperties().size(); adminService.purgeGlobalProperty(adminService.getGlobalPropertyObject("a_valid_gp_key")); assertEquals(allGlobalPropertiesSize -1, adminService.getAllGlobalProperties().size()); }
@Test public void saveGlobalProperties_shouldSaveAllGlobalPropertiesToTheDatabase() { // get the current global properties List<GlobalProperty> globalProperties = adminService.getAllGlobalProperties(); // and now add some new ones to it globalProperties.add(new GlobalProperty("new prop1", "new prop value1", "desc")); globalProperties.add(new GlobalProperty("new prop2", "new prop value2", "desc")); adminService.saveGlobalProperties(globalProperties); assertEquals("new prop value1", adminService.getGlobalProperty("new prop1")); assertEquals("new prop value2", adminService.getGlobalProperty("new prop2")); }
Map<String, GlobalProperty> propsMissingDescription = new HashMap<>(); Map<String, GlobalProperty> propsMissingDatatype = new HashMap<>(); for (GlobalProperty prop : Context.getAdministrationService().getAllGlobalProperties()) { currentPropNames.add(prop.getProperty().toUpperCase()); if (prop.getDescription() == null) {
@Test public void saveGlobalProperties_shouldAssignUuidToAllNewProperties() { // get the current global properties List<GlobalProperty> globalProperties = adminService.getAllGlobalProperties(); // and now add a new one to it and save it globalProperties.add(new GlobalProperty("new prop", "new prop value", "desc")); adminService.saveGlobalProperties(globalProperties); assertNotNull(adminService.getGlobalPropertyObject("new prop").getUuid()); }
@Override public long getAllCount() { return service.getAllGlobalProperties().size(); }
/** * Get all the global properties * * @see org.openmrs.module.webservices.rest.web.resource.impl.DelegatingCrudResource#doGetAll(org.openmrs.module.webservices.rest.web.RequestContext) */ @Override protected NeedsPaging<GlobalProperty> doGetAll(RequestContext context) { List<GlobalProperty> allGlobalPropertys = Context.getAdministrationService().getAllGlobalProperties(); return new NeedsPaging<GlobalProperty>(allGlobalPropertys, context); }
@Test public void shouldGetASystemSettingByName() throws Exception { final String name = service.getAllGlobalProperties().get(0).getProperty(); MockHttpServletRequest req = request(RequestMethod.GET, getURI() + "/" + name); SimpleObject result = deserialize(handle(req)); GlobalProperty gp = service.getGlobalPropertyObject(name); assertEquals(gp.getUuid(), PropertyUtils.getProperty(result, "uuid")); assertEquals(gp.getProperty(), PropertyUtils.getProperty(result, "property")); assertEquals(gp.getDescription(), PropertyUtils.getProperty(result, "description")); assertEquals(gp.getValue(), PropertyUtils.getProperty(result, "value")); }