use of org.walkmod.conf.entities.TransformationConfig 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.conf.entities.TransformationConfig 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"));
}
use of org.walkmod.conf.entities.TransformationConfig 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.conf.entities.TransformationConfig in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testChainsYaml.
@Test
public void testChainsYaml() {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider("src/test/resources/yaml/chains.yml");
Configuration conf = new ConfigurationImpl();
provider.init(conf);
provider.load();
Assert.assertNotNull(conf.getChainConfigs());
ChainConfig cc = conf.getChainConfigs().iterator().next();
Iterator<TransformationConfig> it = cc.getWalkerConfig().getTransformations().iterator();
TransformationConfig first = it.next();
Assert.assertEquals("walkmod:commons:method-refactor", first.getType());
Assert.assertNotNull(cc.getReaderConfig());
Assert.assertNotNull(cc.getWriterConfig());
}
use of org.walkmod.conf.entities.TransformationConfig 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