use of org.walkmod.conf.entities.ProviderConfig 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.ProviderConfig in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testConfigProvidersConfig.
@Test
public void testConfigProvidersConfig() 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);
String output = FileUtils.readFileToString(file);
String desiredOutput = "conf-providers:\n";
desiredOutput += "- type: \"maven\"";
Assert.assertEquals(desiredOutput, output);
} finally {
if (file.exists()) {
file.delete();
}
}
}
use of org.walkmod.conf.entities.ProviderConfig in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testConfigProvidersConfigRecursive.
@Test
public void testConfigProvidersConfigRecursive() throws Exception {
AddCfgProviderCommand command = new AddCfgProviderCommand("maven", null);
File parentDir = new File("src/test/resources/multimoduleyaml");
parentDir.mkdirs();
File module0 = new File(parentDir, "module0");
module0.mkdir();
File file = new File(parentDir, "walkmod.yml");
if (file.exists()) {
file.delete();
}
file.createNewFile();
FileUtils.write(file, "");
File cfg0 = new File(module0, "walkmod.yml");
try {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
Configuration conf = new ConfigurationImpl();
provider.init(conf);
ProviderConfig provCfg = command.build();
provider.addModules(Arrays.asList("module0"));
provider.addProviderConfig(provCfg, true);
String output = FileUtils.readFileToString(cfg0);
String desiredOutput = "conf-providers:\n";
desiredOutput += "- type: \"maven\"";
Assert.assertEquals(desiredOutput, output);
} finally {
if (parentDir.exists()) {
FileUtils.deleteDirectory(parentDir);
}
}
}
Aggregations