Search in sources :

Example 6 with AddCfgProviderCommand

use of org.walkmod.commands.AddCfgProviderCommand 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 7 with AddCfgProviderCommand

use of org.walkmod.commands.AddCfgProviderCommand 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

AddCfgProviderCommand (org.walkmod.commands.AddCfgProviderCommand)7 File (java.io.File)6 Test (org.junit.Test)6 ProviderConfig (org.walkmod.conf.entities.ProviderConfig)6 Configuration (org.walkmod.conf.entities.Configuration)3 ConfigurationImpl (org.walkmod.conf.entities.impl.ConfigurationImpl)3 LinkedList (java.util.LinkedList)2 JCommander (com.beust.jcommander.JCommander)1 ParameterException (com.beust.jcommander.ParameterException)1 RenderedTable (de.vandermeer.asciitable.v2.RenderedTable)1 V2_AsciiTable (de.vandermeer.asciitable.v2.V2_AsciiTable)1 V2_AsciiTableRenderer (de.vandermeer.asciitable.v2.render.V2_AsciiTableRenderer)1 AddExcludesCommand (org.walkmod.commands.AddExcludesCommand)1 AddIncludesCommand (org.walkmod.commands.AddIncludesCommand)1 AddModuleCommand (org.walkmod.commands.AddModuleCommand)1 AddPluginCommand (org.walkmod.commands.AddPluginCommand)1 AddTransformationCommand (org.walkmod.commands.AddTransformationCommand)1 ApplyCommand (org.walkmod.commands.ApplyCommand)1 AsciiTableAware (org.walkmod.commands.AsciiTableAware)1 CheckCommand (org.walkmod.commands.CheckCommand)1