Search in sources :

Example 31 with TransformationConfig

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

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

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

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

Example 35 with TransformationConfig

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

the class XMLConfigurationProviderTest method testAddIncludesExcludeInDefault2.

@Test
public void testAddIncludesExcludeInDefault2() throws Exception {
    AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", 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("mychain", null, transfCfg, false, null, null);
        command = new AddTransformationCommand("imports-cleaner", null, false, null, null, null, null, false);
        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)

Aggregations

TransformationConfig (org.walkmod.conf.entities.TransformationConfig)52 Test (org.junit.Test)40 File (java.io.File)36 AddTransformationCommand (org.walkmod.commands.AddTransformationCommand)36 Configuration (org.walkmod.conf.entities.Configuration)23 ConfigurationImpl (org.walkmod.conf.entities.impl.ConfigurationImpl)20 ChainConfig (org.walkmod.conf.entities.ChainConfig)11 LinkedList (java.util.LinkedList)7 HashMap (java.util.HashMap)5 WalkerConfig (org.walkmod.conf.entities.WalkerConfig)5 Element (org.w3c.dom.Element)3 ReaderConfig (org.walkmod.conf.entities.ReaderConfig)3 WriterConfig (org.walkmod.conf.entities.WriterConfig)3 ChainConfigImpl (org.walkmod.conf.entities.impl.ChainConfigImpl)3 TransformationConfigImpl (org.walkmod.conf.entities.impl.TransformationConfigImpl)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2 TextNode (com.fasterxml.jackson.databind.node.TextNode)2