use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testAddTransformationToPath2.
@Test
public void testAddTransformationToPath2() throws Exception {
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, 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(null, "src", transCfg, false, null, null);
String output = FileUtils.readFileToString(file);
Assert.assertTrue(output.contains("src"));
} finally {
if (file.exists()) {
file.delete();
}
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testAddIncludesExcludeInDefault.
@Test
public void testAddIncludesExcludeInDefault() throws Exception {
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, 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(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();
}
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testAddConfigurationParameterToWriter.
@Test
public void testAddConfigurationParameterToWriter() 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.setWriter(null, "eclipse-writer", null, false, null);
provider.addConfigurationParameter("testParam", "hello", "eclipse-writer", null, 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();
}
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testRemoveTranformationRecursively.
@Test
public void testRemoveTranformationRecursively() throws Exception {
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", null, false, null, null, null, null, false);
List<String> list = new LinkedList<String>();
list.add("imports-cleaner");
File dir = new File("src/test/resources/yamlmultimodule");
dir.mkdirs();
File module0 = new File(dir, "module0");
module0.mkdir();
File module1 = new File(dir, "module1");
module1.mkdir();
File file = new File(dir, "walkmod.yml");
if (file.exists()) {
file.delete();
}
File cfg0 = new File(module0, "walkmod.yml");
try {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
Configuration conf = new ConfigurationImpl();
provider.init(conf);
provider.createConfig();
provider.addModules(Arrays.asList("module0", "module1"));
provider.addTransformationConfig(null, null, command.buildTransformationCfg(), true, null, null);
String output = FileUtils.readFileToString(cfg0);
Assert.assertTrue(output.contains("imports-cleaner"));
provider.removeTransformations(null, list, true);
output = FileUtils.readFileToString(cfg0);
Assert.assertTrue(!output.contains("imports-cleaner"));
} finally {
if (file.exists()) {
FileUtils.deleteDirectory(dir);
}
}
}
use of org.walkmod.commands.AddTransformationCommand in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testAddConfigurationParameter.
@Test
public void testAddConfigurationParameter() throws Exception {
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", 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("mychain", null, transformationCfg, false, null, null);
provider.addConfigurationParameter("testParam", "hello", "imports-cleaner", null, 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