use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testAddConfigurationParameterWithoutChain.
@Test
public void testAddConfigurationParameterWithoutChain() 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.addConfigurationParameter("testParam", "hello", "imports-cleaner", 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 testAddTransformation.
@Test
public void testAddTransformation() 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);
String content = FileUtils.readFileToString(xml);
Assert.assertTrue(content.contains("imports-cleaner"));
} finally {
xml.delete();
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testRemoveIncludes.
@Test
public void testRemoveIncludes() throws Exception {
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, null, null, null, false);
File aux = new File("src/test/resources/xmlincludes");
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("mychain", null, transfCfg, false, null, null);
prov.setWriter("mychain", "eclipse-writer", null, false, null);
prov.addIncludesToChain("mychain", Arrays.asList("foo"), false, true, false);
prov.removeIncludesFromChain("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);
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testAddTransformation.
@Test
public void testAddTransformation() throws Exception {
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, false, null, null, 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(null, null, transCfg, false, null, null);
String output = FileUtils.readFileToString(file);
String desiredOutput = "transformations:\n";
desiredOutput += "- type: \"imports-cleaner\"";
Assert.assertEquals(desiredOutput, output);
} finally {
if (file.exists()) {
file.delete();
}
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testAddConfigurationParameterWithCategory.
@Test
public void testAddConfigurationParameterWithCategory() throws Exception {
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, false, null, null, null, null, false);
File file = new File("src/test/resources/yaml/rmchains.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(null, null, transformationCfg, false, null, null);
provider.addConfigurationParameter("testParam", "hello", "imports-cleaner", "transformation", null, null, false);
String output = FileUtils.readFileToString(file);
System.out.println(output);
Assert.assertTrue(output.contains("params") && output.contains("testParam") && output.contains("hello"));
} finally {
if (file.exists()) {
file.delete();
}
}
}
Aggregations