Search in sources :

Example 21 with PluginConfig

use of org.walkmod.conf.entities.PluginConfig in project walkmod-core by walkmod.

the class XMLConfigurationProviderTest method testAddPluginRecursively.

@Test
public void testAddPluginRecursively() throws Exception {
    File aux = new File("src/test/resources/multmodulexml");
    aux.mkdirs();
    File module0 = new File(aux, "module0");
    module0.mkdir();
    File xml = new File(aux, "walkmod.xml");
    File modulexml = new File(module0, "walkmod.xml");
    XMLConfigurationProvider prov = new XMLConfigurationProvider(xml.getPath(), false);
    try {
        Configuration conf = new ConfigurationImpl();
        prov.init(conf);
        prov.createConfig();
        prov.addModules(Arrays.asList("module0"));
        List<String> plugins = new LinkedList<String>();
        plugins.add("org.walkmod:imports-cleaner");
        AddPluginCommand command = new AddPluginCommand(plugins);
        List<PluginConfig> pluginCfgs = command.build();
        prov.addPluginConfig(pluginCfgs.get(0), true);
        String output = FileUtils.readFileToString(modulexml);
        System.out.println(output);
        Assert.assertTrue(output.contains("imports-cleaner"));
    } finally {
        if (aux.exists()) {
            FileUtils.deleteQuietly(aux);
        }
    }
}
Also used : PluginConfig(org.walkmod.conf.entities.PluginConfig) Configuration(org.walkmod.conf.entities.Configuration) File(java.io.File) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) LinkedList(java.util.LinkedList) AddPluginCommand(org.walkmod.commands.AddPluginCommand) Test(org.junit.Test)

Example 22 with PluginConfig

use of org.walkmod.conf.entities.PluginConfig in project walkmod-core by walkmod.

the class YAMLConfigurationProviderTest method testCompleteYaml.

@Test
public void testCompleteYaml() {
    YAMLConfigurationProvider provider = new YAMLConfigurationProvider("src/test/resources/yaml/walkmod.yml");
    Configuration conf = new ConfigurationImpl();
    provider.init(conf);
    provider.load();
    Assert.assertEquals(2, conf.getPlugins().size());
    Iterator<PluginConfig> itPluginCfg = conf.getPlugins().iterator();
    PluginConfig firstPlugin = itPluginCfg.next();
    Assert.assertEquals("org.walkmod", firstPlugin.getGroupId());
    Assert.assertEquals("walkmod-maven-plugin", firstPlugin.getArtifactId());
    Assert.assertEquals("[1.0, 2.0)", firstPlugin.getVersion());
    Assert.assertEquals(1, conf.getProviderConfigurations().size());
    Iterator<ProviderConfig> itProvCfg = conf.getProviderConfigurations().iterator();
    Assert.assertEquals("walkmod:commons:maven", itProvCfg.next().getType());
    Assert.assertEquals(1, conf.getChainConfigs().size());
    ChainConfig cc = conf.getChainConfigs().iterator().next();
    Assert.assertEquals("main-chain", cc.getName());
    Assert.assertNotNull(cc.getReaderConfig());
    Assert.assertNull(cc.getReaderConfig().getPath());
    Assert.assertEquals(2, cc.getWalkerConfig().getTransformations().size());
    Assert.assertNotNull(cc.getWriterConfig());
    Assert.assertNull(cc.getWriterConfig().getPath());
    Iterator<TransformationConfig> it = cc.getWalkerConfig().getTransformations().iterator();
    TransformationConfig transCfg = it.next();
    Assert.assertEquals("walkmod:commons:method-refactor", transCfg.getType());
    Assert.assertNotNull(transCfg.getParameters());
    Assert.assertEquals("src/conf/refactoring-methods.json", transCfg.getParameters().get("refactoringConfigFile"));
}
Also used : PluginConfig(org.walkmod.conf.entities.PluginConfig) Configuration(org.walkmod.conf.entities.Configuration) ProviderConfig(org.walkmod.conf.entities.ProviderConfig) TransformationConfig(org.walkmod.conf.entities.TransformationConfig) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) ChainConfig(org.walkmod.conf.entities.ChainConfig) Test(org.junit.Test)

Aggregations

PluginConfig (org.walkmod.conf.entities.PluginConfig)22 LinkedList (java.util.LinkedList)10 Configuration (org.walkmod.conf.entities.Configuration)10 PluginConfigImpl (org.walkmod.conf.entities.impl.PluginConfigImpl)10 Test (org.junit.Test)9 ConfigurationImpl (org.walkmod.conf.entities.impl.ConfigurationImpl)9 File (java.io.File)8 ConfigurationException (org.walkmod.conf.ConfigurationException)4 ChainConfig (org.walkmod.conf.entities.ChainConfig)4 IOException (java.io.IOException)3 URL (java.net.URL)3 NodeList (org.w3c.dom.NodeList)3 WalkModFacade (org.walkmod.WalkModFacade)3 ProviderConfig (org.walkmod.conf.entities.ProviderConfig)3 Element (org.w3c.dom.Element)2 Node (org.w3c.dom.Node)2 AddPluginCommand (org.walkmod.commands.AddPluginCommand)2 TransformationConfig (org.walkmod.conf.entities.TransformationConfig)2 ChainConfigImpl (org.walkmod.conf.entities.impl.ChainConfigImpl)2 JSONArray (com.alibaba.fastjson.JSONArray)1