Search in sources :

Example 21 with ChainConfig

use of org.walkmod.conf.entities.ChainConfig 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)

Example 22 with ChainConfig

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

the class YAMLConfigurationProviderTest method testEmptyChain.

@Test
public void testEmptyChain() throws Exception {
    File file = new File("src/test/resources/yaml/addEmptychain.yml");
    if (file.exists()) {
        file.delete();
    }
    file.createNewFile();
    FileUtils.write(file, "");
    YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
    Configuration conf = new ConfigurationImpl();
    provider.init(conf);
    ChainConfig chainCfg = new ChainConfigImpl();
    try {
        provider.addChainConfig(chainCfg, false, null);
        String output = FileUtils.readFileToString(file);
        Assert.assertEquals("", output);
    } finally {
        if (file.exists()) {
            file.delete();
        }
    }
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) ChainConfigImpl(org.walkmod.conf.entities.impl.ChainConfigImpl) File(java.io.File) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) ChainConfig(org.walkmod.conf.entities.ChainConfig) Test(org.junit.Test)

Aggregations

ChainConfig (org.walkmod.conf.entities.ChainConfig)22 Configuration (org.walkmod.conf.entities.Configuration)11 TransformationConfig (org.walkmod.conf.entities.TransformationConfig)11 LinkedList (java.util.LinkedList)8 ChainConfigImpl (org.walkmod.conf.entities.impl.ChainConfigImpl)8 ConfigurationImpl (org.walkmod.conf.entities.impl.ConfigurationImpl)8 WalkerConfig (org.walkmod.conf.entities.WalkerConfig)6 Test (org.junit.Test)5 Element (org.w3c.dom.Element)5 Node (org.w3c.dom.Node)4 NodeList (org.w3c.dom.NodeList)4 PluginConfig (org.walkmod.conf.entities.PluginConfig)4 Document (org.w3c.dom.Document)3 ChainAdapter (org.walkmod.ChainAdapter)3 ProviderConfig (org.walkmod.conf.entities.ProviderConfig)3 ReaderConfig (org.walkmod.conf.entities.ReaderConfig)3 WriterConfig (org.walkmod.conf.entities.WriterConfig)3 WalkModException (org.walkmod.exceptions.WalkModException)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 V2_AsciiTable (de.vandermeer.asciitable.v2.V2_AsciiTable)2