Search in sources :

Example 1 with NestedConfigPlugin

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"));
        }
    }
}
Also used : NestedConfigPlugin(io.cdap.cdap.internal.app.runtime.artifact.plugin.nested.NestedConfigPlugin) Gson(com.google.gson.Gson) PluginInstantiator(io.cdap.cdap.internal.app.runtime.plugin.PluginInstantiator)

Aggregations

Gson (com.google.gson.Gson)1 NestedConfigPlugin (io.cdap.cdap.internal.app.runtime.artifact.plugin.nested.NestedConfigPlugin)1 PluginInstantiator (io.cdap.cdap.internal.app.runtime.plugin.PluginInstantiator)1