Search in sources :

Example 11 with AddTransformationCommand

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

the class YAMLConfigurationProviderTest method testAddIncludesExcludeInDefault2.

@Test
public void testAddIncludesExcludeInDefault2() throws Exception {
    AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, null, null, null, false);
    File file = new File("src/test/resources/yaml/addIncludesInDefault.yml");
    if (file.exists()) {
        file.delete();
    }
    file.createNewFile();
    FileUtils.write(file, "");
    YAMLConfigurationProvider prov = new YAMLConfigurationProvider(file.getPath());
    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(file);
        System.out.println(output);
        Assert.assertTrue(output.contains("foo"));
    } finally {
        if (file.exists()) {
            file.delete();
        }
    }
}
Also used : TransformationConfig(org.walkmod.conf.entities.TransformationConfig) AddTransformationCommand(org.walkmod.commands.AddTransformationCommand) File(java.io.File) Test(org.junit.Test)

Example 12 with AddTransformationCommand

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

the class YAMLConfigurationProviderTest method testAddIncludes.

@Test
public void testAddIncludes() throws Exception {
    AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, null, null, null, false);
    File file = new File("src/test/resources/yaml/addIncludes.yml");
    if (file.exists()) {
        file.delete();
    }
    file.createNewFile();
    FileUtils.write(file, "");
    YAMLConfigurationProvider prov = new YAMLConfigurationProvider(file.getPath());
    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, false);
        String output = FileUtils.readFileToString(file);
        System.out.println(output);
        Assert.assertTrue(output.contains("foo"));
    } finally {
        if (file.exists()) {
            file.delete();
        }
    }
}
Also used : TransformationConfig(org.walkmod.conf.entities.TransformationConfig) AddTransformationCommand(org.walkmod.commands.AddTransformationCommand) File(java.io.File) Test(org.junit.Test)

Example 13 with AddTransformationCommand

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

the class YAMLConfigurationProviderTest method testAddTransformationWithBefore.

@Test
public void testAddTransformationWithBefore() throws Exception {
    AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, false, null, null, null, null, false);
    File file = new File("src/test/resources/yaml/addchain.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);
        TransformationConfig transformationCfg = command.buildTransformationCfg();
        provider.addTransformationConfig("default", null, transformationCfg, false, null, null);
        command = new AddTransformationCommand("setter-getter", "mychain", false, null, null, null, null, false, null, "default");
        transformationCfg = command.buildTransformationCfg();
        provider.addTransformationConfig("mychain", null, transformationCfg, false, null, "default");
        String output = FileUtils.readFileToString(file);
        Assert.assertTrue(output.contains("mychain"));
        Assert.assertTrue(output.contains("default"));
        Assert.assertTrue(output.indexOf("default") > output.indexOf("mychain"));
    } finally {
        if (file.exists()) {
            file.delete();
        }
    }
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) TransformationConfig(org.walkmod.conf.entities.TransformationConfig) AddTransformationCommand(org.walkmod.commands.AddTransformationCommand) File(java.io.File) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) Test(org.junit.Test)

Example 14 with AddTransformationCommand

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

the class YAMLConfigurationProviderTest method testAddIncludesToReaderAndWriter.

@Test
public void testAddIncludesToReaderAndWriter() throws Exception {
    AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, null, null, null, false);
    File file = new File("src/test/resources/yaml/addIncludes.yml");
    if (file.exists()) {
        file.delete();
    }
    file.createNewFile();
    FileUtils.write(file, "");
    YAMLConfigurationProvider prov = new YAMLConfigurationProvider(file.getPath());
    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(file);
        System.out.println(output);
        Assert.assertTrue(output.contains("foo"));
    } finally {
        if (file.exists()) {
            file.delete();
        }
    }
}
Also used : TransformationConfig(org.walkmod.conf.entities.TransformationConfig) AddTransformationCommand(org.walkmod.commands.AddTransformationCommand) File(java.io.File) Test(org.junit.Test)

Example 15 with AddTransformationCommand

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

the class YAMLConfigurationProviderTest method testAddTransformationToPath.

@Test
public void testAddTransformationToPath() throws Exception {
    AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, "src", null, null, false);
    File file = new File("src/test/resources/yaml/addtransformation.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);
        TransformationConfig transCfg = command.buildTransformationCfg();
        provider.addTransformationConfig("mychain", "src", transCfg, false, null, null);
        String output = FileUtils.readFileToString(file);
        Assert.assertTrue(output.contains("src"));
    } finally {
        if (file.exists()) {
            file.delete();
        }
    }
}
Also used : Configuration(org.walkmod.conf.entities.Configuration) TransformationConfig(org.walkmod.conf.entities.TransformationConfig) AddTransformationCommand(org.walkmod.commands.AddTransformationCommand) File(java.io.File) ConfigurationImpl(org.walkmod.conf.entities.impl.ConfigurationImpl) 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