Search in sources :

Example 56 with Configuration

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

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

Example 58 with Configuration

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

Configuration (org.walkmod.conf.entities.Configuration)58 ConfigurationImpl (org.walkmod.conf.entities.impl.ConfigurationImpl)48 Test (org.junit.Test)43 File (java.io.File)38 TransformationConfig (org.walkmod.conf.entities.TransformationConfig)23 LinkedList (java.util.LinkedList)21 AddTransformationCommand (org.walkmod.commands.AddTransformationCommand)21 ChainConfig (org.walkmod.conf.entities.ChainConfig)11 PluginConfig (org.walkmod.conf.entities.PluginConfig)10 HashMap (java.util.HashMap)6 WalkModException (org.walkmod.exceptions.WalkModException)6 V2_AsciiTable (de.vandermeer.asciitable.v2.V2_AsciiTable)5 IOException (java.io.IOException)5 WalkModFacade (org.walkmod.WalkModFacade)5 ConfigurationManager (org.walkmod.conf.ConfigurationManager)5 ProviderConfig (org.walkmod.conf.entities.ProviderConfig)5 PluginConfigImpl (org.walkmod.conf.entities.impl.PluginConfigImpl)5 Document (org.w3c.dom.Document)4 NodeList (org.w3c.dom.NodeList)4 InvalidConfigurationException (org.walkmod.exceptions.InvalidConfigurationException)4