use of org.walkmod.conf.entities.TransformationConfig in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testRemoveChains.
@Test
public void testRemoveChains() 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);
List<String> chains = new LinkedList<String>();
chains.add("mychain");
provider.removeChains(chains, false);
String output = FileUtils.readFileToString(file);
System.out.println(output);
Assert.assertTrue(!output.contains("mychain"));
} finally {
if (file.exists()) {
file.delete();
}
}
}
use of org.walkmod.conf.entities.TransformationConfig in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testAddExcludes.
@Test
public void testAddExcludes() throws Exception {
AddTransformationCommand command = new AddTransformationCommand("imports-cleaner", "mychain", false, null, null, null, null, false);
File file = new File("src/test/resources/yaml/addExcludes.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.addExcludesToChain("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.conf.entities.TransformationConfig in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testRemoveIncludes.
@Test
public void testRemoveIncludes() 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);
prov.removeIncludesFromChain("default", 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.conf.entities.TransformationConfig in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testCompleteYaml.
@Test
public void testCompleteYaml() {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider("src/test/resources/yaml/walkmod.yml");
Configuration conf = new ConfigurationImpl();
provider.init(conf);
provider.load();
Assert.assertEquals(2, conf.getPlugins().size());
Iterator<PluginConfig> itPluginCfg = conf.getPlugins().iterator();
PluginConfig firstPlugin = itPluginCfg.next();
Assert.assertEquals("org.walkmod", firstPlugin.getGroupId());
Assert.assertEquals("walkmod-maven-plugin", firstPlugin.getArtifactId());
Assert.assertEquals("[1.0, 2.0)", firstPlugin.getVersion());
Assert.assertEquals(1, conf.getProviderConfigurations().size());
Iterator<ProviderConfig> itProvCfg = conf.getProviderConfigurations().iterator();
Assert.assertEquals("walkmod:commons:maven", itProvCfg.next().getType());
Assert.assertEquals(1, conf.getChainConfigs().size());
ChainConfig cc = conf.getChainConfigs().iterator().next();
Assert.assertEquals("main-chain", cc.getName());
Assert.assertNotNull(cc.getReaderConfig());
Assert.assertNull(cc.getReaderConfig().getPath());
Assert.assertEquals(2, cc.getWalkerConfig().getTransformations().size());
Assert.assertNotNull(cc.getWriterConfig());
Assert.assertNull(cc.getWriterConfig().getPath());
Iterator<TransformationConfig> it = cc.getWalkerConfig().getTransformations().iterator();
TransformationConfig transCfg = it.next();
Assert.assertEquals("walkmod:commons:method-refactor", transCfg.getType());
Assert.assertNotNull(transCfg.getParameters());
Assert.assertEquals("src/conf/refactoring-methods.json", transCfg.getParameters().get("refactoringConfigFile"));
}
use of org.walkmod.conf.entities.TransformationConfig in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testAddIncludesToWriter.
@Test
public void testAddIncludesToWriter() 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, false, true);
String output = FileUtils.readFileToString(file);
System.out.println(output);
Assert.assertTrue(output.contains("foo"));
} finally {
if (file.exists()) {
file.delete();
}
}
}
Aggregations