@SuppressWarnings("rawtypes") @Test(priority = 3) public void testCreateNew() throws Exception { config.put("property1", "value1"); config.put("property2", "value2"); configObjectService.create(rname, id, json(config), false).getOrThrow(); ConfigObjectService.ParsedId parsedId = configObjectService.getParsedId(rname, id); Configuration config = configObjectService.findExistingConfiguration(parsedId); assertNotNull(config); assertNotNull(config.getProperties()); Dictionary properties = config.getProperties(); EnhancedConfig enhancedConfig = new JSONEnhancedConfig(); JsonValue value = enhancedConfig.getConfiguration(properties, rname.toString(), false); assertTrue(value.keys().contains("property1")); Assert.assertEquals(value.get("property1").asString(), "value1"); }
@SuppressWarnings("rawtypes") @Test(priority = 6) public void testUpdate() throws Exception { config.put("property1", "newvalue1"); config.put("property2", "newvalue2"); when(enhancedConfig.getConfiguration(any(Dictionary.class), any(String.class), eq(false))) .thenReturn(json(config)); configObjectService.update(rname, id, json(config)).getOrThrow(); ConfigObjectService.ParsedId parsedId = configObjectService.getParsedId(rname, id); Configuration config = configObjectService.findExistingConfiguration(parsedId); assertNotNull(config); assertNotNull(config.getProperties()); Dictionary properties = config.getProperties(); JSONEnhancedConfig enhancedConfig = new JSONEnhancedConfig(); JsonValue value = enhancedConfig.getConfiguration(properties, rname.toString(), false); assertTrue(value.keys().contains("property1")); Assert.assertEquals(value.get("property1").asString(), "newvalue1"); }