Search in sources :

Example 26 with AddTransformationCommand

use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.

the class XMLConfigurationProviderTest method testAddIncludesExcludeInDefault.

@Test
public void testAddIncludesExcludeInDefault() throws Exception {
    AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, false, null, null, null, null, false);
    File aux = new File("src/test/resources/xmlincludes2");
    aux.mkdirs();
    File xml = new File(aux, "walkmod.xml");
    XMLConfigurationProvider prov = new XMLConfigurationProvider(xml.getPath(), false);
    try {
        prov.createConfig();
        TransformationConfig transfCfg = command.buildTransformationCfg();
        prov.addTransformationConfig(null, null, transfCfg, false, null, null);
        prov.addIncludesToChain(null, Arrays.asList("foo"), false, true, false);
        String output = FileUtils.readFileToString(xml);
        System.out.println(output);
        Assert.assertTrue(output.contains("wildcard") && output.contains("foo"));
    } finally {
        FileUtils.deleteDirectory(aux);
    }
}
Also used : TransformationConfig(org.walkmod.conf.entities.TransformationConfig) AddTransformationCommand(org.walkmod.commands.AddTransformationCommand) File(java.io.File) Test(org.junit.Test)

Example 27 with AddTransformationCommand

use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.

the class XMLConfigurationProviderTest method testRemoveChains.

@Test
public void testRemoveChains() throws Exception {
    AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, null, null, null, false);
    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 {
        prov.createConfig();
        TransformationConfig transfCfg = command.buildTransformationCfg();
        prov.addTransformationConfig("mychain", null, transfCfg, false, null, null);
        String output = FileUtils.readFileToString(xml);
        Assert.assertTrue(output.contains("mychain"));
        List<String> chains = new LinkedList<String>();
        chains.add("mychain");
        prov.removeChains(chains, false);
        output = FileUtils.readFileToString(xml);
        System.out.println(output);
        Assert.assertTrue(!output.contains("mychain"));
    } finally {
        if (xml.exists()) {
            xml.delete();
        }
    }
}
Also used : TransformationConfig(org.walkmod.conf.entities.TransformationConfig) AddTransformationCommand(org.walkmod.commands.AddTransformationCommand) File(java.io.File) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 28 with AddTransformationCommand

use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.

the class XMLConfigurationProviderTest method testSetReader.

@Test
public void testSetReader() 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();
        AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, false, null, null, null, null, false);
        prov.addTransformationConfig(null, null, command.buildTransformationCfg(), false, null, null);
        prov.setReader(null, "walkmod:commons:file-reader", null, false, null);
        String output = FileUtils.readFileToString(xml);
        System.out.println(output);
        Assert.assertTrue(output.contains("walkmod:commons:file-reader"));
    } 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) Test(org.junit.Test)

Example 29 with AddTransformationCommand

use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.

the class XMLConfigurationProviderTest method testAddExcludes.

@Test
public void testAddExcludes() throws Exception {
    AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, null, null, null, false);
    File aux = new File("src/test/resources/xmlincludes");
    aux.mkdirs();
    File xml = new File(aux, "walkmod.xml");
    XMLConfigurationProvider prov = new XMLConfigurationProvider(xml.getPath(), false);
    try {
        prov.createConfig();
        TransformationConfig transfCfg = command.buildTransformationCfg();
        prov.addTransformationConfig("mychain", null, transfCfg, false, null, null);
        prov.setWriter("mychain", "eclipse-writer", null, false, null);
        prov.addExcludesToChain("mychain", Arrays.asList("foo"), false, true, false);
        String output = FileUtils.readFileToString(xml);
        System.out.println(output);
        Assert.assertTrue(output.contains("wildcard") && output.contains("foo"));
    } finally {
        FileUtils.deleteDirectory(aux);
    }
}
Also used : TransformationConfig(org.walkmod.conf.entities.TransformationConfig) AddTransformationCommand(org.walkmod.commands.AddTransformationCommand) File(java.io.File) Test(org.junit.Test)

Example 30 with AddTransformationCommand

use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.

the class XMLConfigurationProviderTest method testAddIncludesToReaderAndWriter.

@Test
public void testAddIncludesToReaderAndWriter() throws Exception {
    AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, null, null, null, false);
    File aux = new File("src/test/resources/xmlincludes");
    aux.mkdirs();
    File xml = new File(aux, "walkmod.xml");
    XMLConfigurationProvider prov = new XMLConfigurationProvider(xml.getPath(), false);
    try {
        prov.createConfig();
        TransformationConfig transfCfg = command.buildTransformationCfg();
        prov.addTransformationConfig("mychain", null, transfCfg, false, null, null);
        prov.setWriter("mychain", "eclipse-writer", null, false, null);
        prov.addIncludesToChain("mychain", Arrays.asList("foo"), false, true, true);
        String output = FileUtils.readFileToString(xml);
        System.out.println(output);
        Assert.assertTrue(output.contains("wildcard") && output.contains("foo"));
    } finally {
        FileUtils.deleteDirectory(aux);
    }
}
Also used : TransformationConfig(org.walkmod.conf.entities.TransformationConfig) AddTransformationCommand(org.walkmod.commands.AddTransformationCommand) File(java.io.File) Test(org.junit.Test)

Aggregations

AddTransformationCommand (org.walkmod.commands.AddTransformationCommand)52 File (java.io.File)51 Test (org.junit.Test)51 TransformationConfig (org.walkmod.conf.entities.TransformationConfig)36 Configuration (org.walkmod.conf.entities.Configuration)21 ConfigurationImpl (org.walkmod.conf.entities.impl.ConfigurationImpl)21 LinkedList (java.util.LinkedList)8 HashMap (java.util.HashMap)5 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 AddCfgProviderCommand (org.walkmod.commands.AddCfgProviderCommand)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 ApplyCommand (org.walkmod.commands.ApplyCommand)1 AsciiTableAware (org.walkmod.commands.AsciiTableAware)1