Search in sources :

Example 6 with Configuration

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

the class XMLConfigurationProviderTest method testRemoveTransformationsRecursively.

@Test
public void testRemoveTransformationsRecursively() throws Exception {
    List<String> list = new LinkedList<String>();
    list.add("imports-cleaner");
    File aux = new File("src/test/resources/xmlmultimodule");
    aux.mkdirs();
    File module0 = new File(aux, "module0");
    File module1 = new File(aux, "module1");
    File cfg0 = new File(module0, "walkmod.xml");
    File cfg1 = new File(module1, "walkmod.xml");
    module0.mkdir();
    module1.mkdir();
    File xml = new File(aux, "walkmod.xml");
    XMLConfigurationProvider prov = new XMLConfigurationProvider(xml.getPath(), false);
    try {
        Configuration conf = new ConfigurationImpl();
        prov.init(conf);
        prov.createConfig();
        prov.addModules(Arrays.asList("module0", "module1"));
        AddTransformationCommand command0 = new AddTransformationCommand("license-applier", "mychain", false, null, null, null, null, true);
        prov.addTransformationConfig("mychain", null, command0.buildTransformationCfg(), true, null, null);
        String output = FileUtils.readFileToString(cfg0);
        System.out.println(output);
        AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, null, null, null, true);
        prov.addTransformationConfig("mychain", null, command.buildTransformationCfg(), true, null, null);
        output = FileUtils.readFileToString(cfg0);
        System.out.println(output);
        prov.removeTransformations("mychain", list, true);
        output = FileUtils.readFileToString(cfg0);
        Assert.assertTrue(!output.contains("imports-cleaner"));
        Assert.assertTrue(output.contains("license-applier"));
        output = FileUtils.readFileToString(cfg1);
        Assert.assertTrue(!output.contains("imports-cleaner"));
        Assert.assertTrue(output.contains("license-applier"));
    } finally {
        if (aux.exists()) {
            FileUtils.deleteDirectory(aux);
        }
    }
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) AddTransformationCommand(org.walkmod.commands.AddTransformationCommand) File(java.io.File) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 7 with Configuration

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

the class XMLConfigurationProviderTest method testRemoveTranformation.

@Test
public void testRemoveTranformation() throws Exception {
    List<String> list = new LinkedList<String>();
    list.add("imports-cleaner");
    File aux = new File("src/test/resources/xml");
    aux.mkdirs();
    File xml = new File(aux, "walkmod.xml");
    XMLConfigurationProvider prov = new XMLConfigurationProvider(xml.getPath(), false);
    try {
        Configuration conf = new ConfigurationImpl();
        prov.init(conf);
        prov.createConfig();
        AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, false, null, null, null, null, false);
        prov.addTransformationConfig(null, null, command.buildTransformationCfg(), false, null, null);
        prov.removeTransformations(null, list, false);
        String output = FileUtils.readFileToString(xml);
        Assert.assertTrue(!output.contains("imports-cleaner"));
    } finally {
        if (xml.exists()) {
            xml.delete();
        }
    }
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) AddTransformationCommand(org.walkmod.commands.AddTransformationCommand) File(java.io.File) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 8 with Configuration

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

the class XMLConfigurationProviderTest method testRemoveModule.

@Test
public void testRemoveModule() throws Exception {
    File aux = new File("src/test/resources/xml");
    aux.mkdirs();
    File xml = new File(aux, "walkmod.xml");
    XMLConfigurationProvider prov = new XMLConfigurationProvider(xml.getPath(), false);
    try {
        Configuration conf = new ConfigurationImpl();
        prov.init(conf);
        prov.createConfig();
        List<String> modules = new LinkedList<String>();
        modules.add("module1");
        prov.addModules(modules);
        String output = FileUtils.readFileToString(xml);
        System.out.println(output);
        Assert.assertTrue(output.contains("module1"));
        prov.removeModules(modules);
        output = FileUtils.readFileToString(xml);
        System.out.println(output);
        Assert.assertTrue(!output.contains("module1"));
    } finally {
        if (xml.exists()) {
            xml.delete();
        }
    }
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) File(java.io.File) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 9 with Configuration

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

the class XMLConfigurationProviderTest method testVersion1_1.

@Test
public void testVersion1_1() throws Exception {
    XMLConfigurationProvider prov = new XMLConfigurationProvider("src/test/resources/multimodule/walkmod.xml", false);
    Configuration conf = new ConfigurationImpl();
    prov.init(conf);
    prov.load();
    Assert.assertEquals(0, conf.getChainConfigs().size());
    Assert.assertEquals(2, conf.getModules().size());
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) Test(org.junit.Test)

Example 10 with Configuration

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

the class XMLConfigurationProviderTest method testVersion1_0.

@Test
public void testVersion1_0() throws Exception {
    XMLConfigurationProvider prov = new XMLConfigurationProvider("src/test/resources/testFiles/walkmod.xml", false);
    Configuration conf = new ConfigurationImpl();
    prov.init(conf);
    prov.load();
    Assert.assertEquals(1, conf.getChainConfigs().size());
    Assert.assertEquals("default", conf.getChainConfigs().iterator().next().getName());
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) 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