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();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
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();
}
}
}
Aggregations