use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testAddParamToTheImplicitWriter.
@Test
public void testAddParamToTheImplicitWriter() throws Exception {
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, false, null, null, null, null, false);
File aux = new File("src/test/resources/xmlwriter");
if (aux.exists()) {
FileUtils.deleteDirectory(aux);
}
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.addConfigurationParameter("formatter", "formatter.xml", "eclipse-writer", "writer", null, null, false);
String output = FileUtils.readFileToString(xml);
System.out.println(output);
Assert.assertTrue(output.contains("formatter"));
} finally {
FileUtils.deleteDirectory(aux);
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testRemoveChainTransformations.
@Test
public void testRemoveChainTransformations() 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 command0 = new AddTransformationCommand("license-applier", "mychain", false, null, null, null, null, false);
prov.addTransformationConfig("mychain", null, command0.buildTransformationCfg(), false, null, null);
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, null, null, null, false);
prov.addTransformationConfig("mychain", null, command.buildTransformationCfg(), false, null, null);
prov.removeTransformations("mychain", list, false);
String output = FileUtils.readFileToString(xml);
Assert.assertTrue(!output.contains("imports-cleaner"));
Assert.assertTrue(output.contains("license-applier"));
list.add("license-applier");
prov.removeTransformations("mychain", list, false);
output = FileUtils.readFileToString(xml);
Assert.assertTrue(!output.contains("chain"));
} finally {
if (xml.exists()) {
xml.delete();
}
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testAddConfigurationParameterToWriterWithoutChain.
@Test
public void testAddConfigurationParameterToWriterWithoutChain() throws Exception {
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, false, null, null, null, null, false);
File aux = new File("src/test/resources/xmlparams");
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.setWriter(null, "eclipse-writer", null, false, null);
prov.addConfigurationParameter("testParam", "hello", "eclipse-writer", null, null, null, false);
String output = FileUtils.readFileToString(xml);
System.out.println(output);
Assert.assertTrue(output.contains("testParam") && output.contains("hello"));
} finally {
FileUtils.deleteDirectory(aux);
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testAddConfigurationParameterWithChainFilter.
@Test
public void testAddConfigurationParameterWithChainFilter() throws Exception {
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, null, null, null, false);
File aux = new File("src/test/resources/xmlparams");
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.addConfigurationParameter("testParam", "hello", "eclipse-writer", null, null, "mychain", false);
String output = FileUtils.readFileToString(xml);
System.out.println(output);
Assert.assertTrue(output.contains("testParam") && output.contains("hello"));
} finally {
FileUtils.deleteDirectory(aux);
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testAddIncludes.
@Test
public void testAddIncludes() 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, false);
String output = FileUtils.readFileToString(xml);
System.out.println(output);
Assert.assertTrue(output.contains("wildcard") && output.contains("foo"));
} finally {
FileUtils.deleteDirectory(aux);
}
}
Aggregations