use of org.walkmod.commands.AddTransformationCommand 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);
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testAddTransformationWithChainAndPath.
@Test
public void testAddTransformationWithChainAndPath() 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 {
prov.createConfig();
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, "src", null, null, false);
prov.addTransformationConfig("mychain", "src", command.buildTransformationCfg(), false, null, null);
String content = FileUtils.readFileToString(xml);
Assert.assertTrue(content.contains("imports-cleaner") && content.contains("src"));
} finally {
xml.delete();
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testAddTransformationInDefaultChain.
@Test
public void testAddTransformationInDefaultChain() 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 {
prov.createConfig();
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, false, null, null, null, null, false);
prov.addTransformationConfig(null, null, command.buildTransformationCfg(), false, null, null);
command = new AddTransformationCommand("setter-getter", "common", false, null, null, null, null, false, null, "default");
prov.addTransformationConfig("common", null, command.buildTransformationCfg(), false, null, "default");
command = new AddTransformationCommand("setter-getter", null, false, null, null, null, null, false, null, null);
prov.addTransformationConfig(null, null, command.buildTransformationCfg(), false, null, null);
String content = FileUtils.readFileToString(xml);
System.out.println(content);
Assert.assertTrue(content.contains("imports-cleaner"));
Assert.assertTrue(content.contains("common"));
Assert.assertTrue(content.contains("setter-getter"));
Assert.assertTrue(content.indexOf("common") < content.indexOf("default"));
} finally {
xml.delete();
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testAddIncludesToWriter.
@Test
public void testAddIncludesToWriter() 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, false, true);
String output = FileUtils.readFileToString(xml);
System.out.println(output);
Assert.assertTrue(output.contains("wildcard") && output.contains("foo"));
} finally {
FileUtils.deleteDirectory(aux);
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testSetWriter.
@Test
public void testSetWriter() 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.setWriter(null, "javalang:string-writer", null, false, null);
String output = FileUtils.readFileToString(xml);
System.out.println(output);
Assert.assertTrue(output.contains("javalang:string-writer"));
} finally {
if (xml.exists()) {
xml.delete();
}
}
}
Aggregations