@Test public void saveGlobalProperties_shouldNotFailWithEmptyList() { adminService.saveGlobalProperties(new ArrayList<>()); }
@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 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_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()); }
@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")); }