@Test public void getGlobalPropertyByUuid_shouldReturnNullIfNoObjectFoundWithGivenUuid() { assertNull(adminService.getGlobalPropertyByUuid("some invalid uuid")); }
@Test public void getGlobalPropertyByUuid_shouldFindObjectGivenValidUuid() { String uuid = "4f55827e-26fe-102b-80cb-0017a47871b3"; GlobalProperty prop = adminService.getGlobalPropertyByUuid(uuid); assertEquals("locale.allowed.list", prop.getProperty()); }
/** * Fetches a global property by uuid, if no match is found, it tries to look up one with a * matching name with the assumption that the passed parameter is a global property name * * @see DelegatingCrudResource#getByUniqueId(java.lang.String) */ @Override public GlobalProperty getByUniqueId(String uuid) { GlobalProperty gp = Context.getAdministrationService().getGlobalPropertyByUuid(uuid); if (gp == null) { //We assume the caller is fetching by name gp = Context.getAdministrationService().getGlobalPropertyObject(uuid); } return gp; }
@Override public GlobalProperty newObject() { return Context.getAdministrationService().getGlobalPropertyByUuid(getUuidProperty()); }
@Test public void shouldDeleteASystemSetting() throws Exception { assertNotNull(service.getGlobalPropertyByUuid(getUuid())); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); handle(req); assertNull(service.getGlobalPropertyByUuid(getUuid())); } }
@Test public void shouldPurgeASystemSetting() throws Exception { assertNotNull(service.getGlobalPropertyByUuid(getUuid())); MockHttpServletRequest req = request(RequestMethod.DELETE, getURI() + "/" + getUuid()); req.addParameter("purge", "true"); handle(req); assertNull(service.getGlobalPropertyByUuid(getUuid())); }
@Test public void shouldEditASystemSetting() throws Exception { final String newValue = "Adding description by editing property"; GlobalProperty expectedProperty = service.getGlobalPropertyByUuid(getUuid()); assertNull(expectedProperty.getDescription()); String json = "{ \"description\":\"" + newValue + "\" }"; SimpleObject updatedProperty = deserialize(handle(newPostRequest(getURI() + "/" + getUuid(), json))); assertTrue(newValue.equals(PropertyUtils.getProperty(updatedProperty, "description"))); }
@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")); }