assertFalse(service.supports(GlobalConfiguration.class));
}
@Test
public void testPersistRuleBaseElement_shouldCreateFileAndLoad() throws Exception {
RuleBaseElement element = new RuleBaseElement();
element.setCode("code");
element.setName("name");
element.setPackageName("package.org");
element.setType(RuleBaseElementType.Rule);
RuleBaseConfiguration conf = new RuleBaseConfiguration(element);
service.persist(conf);
String expectedFilename =
String.format("%s%s%s%s%s", element.getType(), separator, element.getName(), separator
, encoder.encode(element.getPackageName()));
File expectedTarget = new File(storageFolder, expectedFilename);
assertTrue(expectedTarget.exists());
String code = FileUtils.readFileToString(expectedTarget);
assertEquals("code", code);
List<ConfigItem<RuleBaseElement>> loaded = service.load(conf.getMetaData());
assertEquals(1, loaded.size());
RuleBaseElement loadedElement = loaded.get(0).getContent();
assertEquals(element.getName(), loadedElement.getName());
assertEquals(element.getCode(), loadedElement.getCode());
assertEquals(element.getPackageName(), loadedElement.getPackageName());
assertEquals(element.getType(), loadedElement.getType());
}