use of org.walkmod.conf.entities.impl.ConfigurationImpl 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.conf.entities.impl.ConfigurationImpl 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();
}
}
}
use of org.walkmod.conf.entities.impl.ConfigurationImpl 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.conf.entities.impl.ConfigurationImpl in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testAddPlugin.
@Test
public void testAddPlugin() throws Exception {
File file = new File("src/test/resources/yaml/addplugin.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);
PluginConfig pluginCfg = new PluginConfigImpl();
pluginCfg.setGroupId("org.walkmod");
pluginCfg.setArtifactId("myplugin");
pluginCfg.setVersion("1.0");
provider.addPluginConfig(pluginCfg, false);
String output = FileUtils.readFileToString(file);
String desiredOutput = "plugins:\n";
desiredOutput += "- \"org.walkmod:myplugin:1.0\"";
Assert.assertEquals(desiredOutput, output);
} finally {
if (file.exists()) {
file.delete();
}
}
}
use of org.walkmod.conf.entities.impl.ConfigurationImpl in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testTransformationsYaml.
@Test
public void testTransformationsYaml() {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider("src/test/resources/yaml/basic.yml");
Configuration conf = new ConfigurationImpl();
provider.init(conf);
provider.load();
Assert.assertNotNull(conf.getChainConfigs());
ChainConfig cc = conf.getChainConfigs().iterator().next();
Assert.assertNotNull(cc.getWalkerConfig().getTransformations());
Iterator<TransformationConfig> it = cc.getWalkerConfig().getTransformations().iterator();
TransformationConfig tc = it.next();
Assert.assertEquals("walkmod:commons:method-refactor", tc.getType());
Assert.assertEquals("src/conf/refactoring-methods.json", tc.getParameters().get("refactoringConfigFile"));
}
Aggregations