@Test(dependsOnMethods = { "persistNewTypes" }, groups = { "plugin.resource.metadata.test", "NewPlugin" })
public void persistDriftDefinitionTemplates() throws Exception {
ResourceType type = assertResourceTypeAssociationEquals("ServerA", PLUGIN_NAME, "driftDefinitionTemplates",
asList("drift-pc", "drift-fs"));
DriftDefinition driftDef = null;
Set<DriftDefinitionTemplate> drifts = type.getDriftDefinitionTemplates();
for (DriftDefinitionTemplate drift : drifts) {
if (drift.getName().equals("drift-pc")) {
driftDef = new DriftDefinition(drift.getConfiguration());
assertTrue(driftDef.isEnabled());
assertEquals(BaseDirValueContext.pluginConfiguration, driftDef.getBasedir().getValueContext());
assertEquals("connectionPropertyX", driftDef.getBasedir().getValueName());
assertEquals(123456L, driftDef.getInterval());
assertEquals(1, driftDef.getIncludes().size());
assertEquals(2, driftDef.getExcludes().size());
Filter filter = driftDef.getIncludes().get(0);
assertEquals("foo/bar", filter.getPath());
assertEquals("**/*.blech", filter.getPattern());
filter = driftDef.getExcludes().get(0);
assertEquals("/wot/gorilla", filter.getPath());
assertEquals("*.xml", filter.getPattern());
filter = driftDef.getExcludes().get(1);
assertEquals("/hello", filter.getPath());
assertEquals("", filter.getPattern());
} else if (drift.getName().equals("drift-fs")) {
driftDef = new DriftDefinition(drift.getConfiguration());
assertTrue(driftDef.isEnabled());
assertEquals(BaseDirValueContext.fileSystem, driftDef.getBasedir().getValueContext());
assertEquals("/", driftDef.getBasedir().getValueName());
assertEquals(DriftConfigurationDefinition.DEFAULT_INTERVAL, driftDef.getInterval());
assertEquals(0, driftDef.getIncludes().size());
assertEquals(0, driftDef.getExcludes().size());
} else {
fail("got an unexpected drift definition: " + driftDef);
}
}
}