/** * Gets the value of the global property delegate * * @param instance the delegate instance to get the value off * @return value object */ @PropertyGetter("value") public static Object getValue(GlobalProperty globalProperty) { if (StringUtils.isNotEmpty(globalProperty.getDatatypeClassname()) && StringUtils.isNotEmpty(globalProperty.getDatatypeConfig())) { return globalProperty.getValue(); } else { return globalProperty.getPropertyValue(); } }
/** * Gets the display name of the global property delegate * * @param instance the delegate instance to get the display name off * @return string as "section - name = value" */ @PropertyGetter("display") public static String getDisplayString(GlobalProperty globalProperty) { return getSection(globalProperty) + " - " + getName(globalProperty) + " = " + globalProperty.getValue(); }
@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")); }
@Test public void shouldGetASystemSettingWithDotByName() throws Exception { final String name = "concept.defaultConceptMapType"; 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")); } }
@Test public void shouldFindASystemSettingWithUUID() throws Exception { SimpleObject property = deserialize(handle(newGetRequest(getURI() + "/" + getUuid()))); GlobalProperty expectedProperty = service.getGlobalPropertyByUuid(getUuid()); assertNotNull(property); assertEquals(expectedProperty.getUuid(), PropertyUtils.getProperty(property, "uuid")); assertEquals(expectedProperty.getProperty(), PropertyUtils.getProperty(property, "property")); assertEquals(expectedProperty.getValue(), PropertyUtils.getProperty(property, "value")); }