Search in sources :

Example 11 with ProviderConfig

use of org.walkmod.conf.entities.ProviderConfig 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 12 with ProviderConfig

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

the class YAMLConfigurationProviderTest method testConfigProvidersConfig.

@Test
public void testConfigProvidersConfig() throws Exception {
    AddCfgProviderCommand command = new AddCfgProviderCommand("maven", null);
    File file = new File("src/test/resources/yaml/addcfgproviders.yml");
    if (file.exists()) {
        file.delete();
    }
    file.createNewFile();
    FileUtils.write(file, "");
    try {
        YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
        Configuration conf = new ConfigurationImpl();
        provider.init(conf);
        ProviderConfig provCfg = command.build();
        provider.addProviderConfig(provCfg, false);
        String output = FileUtils.readFileToString(file);
        String desiredOutput = "conf-providers:\n";
        desiredOutput += "- type: \"maven\"";
        Assert.assertEquals(desiredOutput, output);
    } finally {
        if (file.exists()) {
            file.delete();
        }
    }
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) AddCfgProviderCommand(org.walkmod.commands.AddCfgProviderCommand) ProviderConfig(org.walkmod.conf.entities.ProviderConfig) File(java.io.File) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) Test(org.junit.Test)

Example 13 with ProviderConfig

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

the class YAMLConfigurationProviderTest method testConfigProvidersConfigRecursive.

@Test
public void testConfigProvidersConfigRecursive() throws Exception {
    AddCfgProviderCommand command = new AddCfgProviderCommand("maven", null);
    File parentDir = new File("src/test/resources/multimoduleyaml");
    parentDir.mkdirs();
    File module0 = new File(parentDir, "module0");
    module0.mkdir();
    File file = new File(parentDir, "walkmod.yml");
    if (file.exists()) {
        file.delete();
    }
    file.createNewFile();
    FileUtils.write(file, "");
    File cfg0 = new File(module0, "walkmod.yml");
    try {
        YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
        Configuration conf = new ConfigurationImpl();
        provider.init(conf);
        ProviderConfig provCfg = command.build();
        provider.addModules(Arrays.asList("module0"));
        provider.addProviderConfig(provCfg, true);
        String output = FileUtils.readFileToString(cfg0);
        String desiredOutput = "conf-providers:\n";
        desiredOutput += "- type: \"maven\"";
        Assert.assertEquals(desiredOutput, output);
    } finally {
        if (parentDir.exists()) {
            FileUtils.deleteDirectory(parentDir);
        }
    }
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) AddCfgProviderCommand(org.walkmod.commands.AddCfgProviderCommand) ProviderConfig(org.walkmod.conf.entities.ProviderConfig) File(java.io.File) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) Test(org.junit.Test)

Aggregations

ProviderConfig (org.walkmod.conf.entities.ProviderConfig)13 File (java.io.File)7 Test (org.junit.Test)7 AddCfgProviderCommand (org.walkmod.commands.AddCfgProviderCommand)6 Configuration (org.walkmod.conf.entities.Configuration)5 LinkedList (java.util.LinkedList)4 ConfigurationImpl (org.walkmod.conf.entities.impl.ConfigurationImpl)4 ChainConfig (org.walkmod.conf.entities.ChainConfig)3 PluginConfig (org.walkmod.conf.entities.PluginConfig)3 ProviderConfigImpl (org.walkmod.conf.entities.impl.ProviderConfigImpl)3 HashMap (java.util.HashMap)2 MergePolicyConfig (org.walkmod.conf.entities.MergePolicyConfig)2 TransformationConfig (org.walkmod.conf.entities.TransformationConfig)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 V2_AsciiTable (de.vandermeer.asciitable.v2.V2_AsciiTable)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1