use of org.walkmod.conf.entities.Configuration in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testRemoveProvider.
@Test
public void testRemoveProvider() throws Exception {
AddCfgProviderCommand command = new AddCfgProviderCommand("maven", null);
File file = new File("src/test/resources/yaml/addcfgproviders.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);
ProviderConfig provCfg = command.build();
provider.addProviderConfig(provCfg, false);
List<String> providers = new LinkedList<String>();
providers.add("maven");
provider.removeProviders(providers, false);
String output = FileUtils.readFileToString(file);
System.out.println(output);
Assert.assertTrue(!output.contains("maven"));
} finally {
if (file.exists()) {
file.delete();
}
}
}
use of org.walkmod.conf.entities.Configuration 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.Configuration in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testSetWriter.
@Test
public void testSetWriter() throws Exception {
List<String> list = new LinkedList<String>();
list.add("javalang:string-writer");
File file = new File("src/test/resources/yaml/setWriter.yml");
if (file.exists()) {
file.delete();
}
file.createNewFile();
String input = "transformations:\n";
input += "- type: \"imports-cleaner\"";
FileUtils.write(file, input);
try {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
Configuration conf = new ConfigurationImpl();
provider.init(conf);
provider.setWriter(null, list.get(0), null, false, null);
String output = FileUtils.readFileToString(file);
System.out.println(output);
Assert.assertTrue(output.contains("javalang:string-writer"));
} finally {
if (file.exists()) {
file.delete();
}
}
}
use of org.walkmod.conf.entities.Configuration 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.conf.entities.Configuration 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