use of io.cdap.cdap.internal.app.runtime.artifact.plugin.nested.NestedConfigPlugin in project cdap by caskdata.
the class ArtifactRepositoryTest method instantiateAndValidate.
private void instantiateAndValidate(File pluginDir, Plugin pluginInfo, NestedConfigPlugin.Config expected, boolean containMacro) throws Exception {
Gson gson = new Gson();
try (PluginInstantiator instantiator = new PluginInstantiator(cConf, appClassLoader, pluginDir)) {
// here cannot use directly cast to NestedConfigPlugin since the classloaders are different, will get
// ClassCastException
Callable<String> plugin = instantiator.newInstance(pluginInfo);
NestedConfigPlugin.Config actual = gson.fromJson(plugin.call(), NestedConfigPlugin.Config.class);
Assert.assertEquals(expected, actual);
if (containMacro) {
Assert.assertTrue(actual.nested.containsMacro("Nested1"));
Assert.assertTrue(actual.nested.containsMacro("Nested2"));
} else {
Assert.assertFalse(actual.nested.containsMacro("Nested1"));
Assert.assertFalse(actual.nested.containsMacro("Nested2"));
}
}
}
Aggregations