use of org.walkmod.conf.entities.PluginConfig in project walkmod-core by walkmod.
the class XMLConfigurationProviderTest method testAddPluginRecursively.
@Test
public void testAddPluginRecursively() throws Exception {
File aux = new File("src/test/resources/multmodulexml");
aux.mkdirs();
File module0 = new File(aux, "module0");
module0.mkdir();
File xml = new File(aux, "walkmod.xml");
File modulexml = new File(module0, "walkmod.xml");
XMLConfigurationProvider prov = new XMLConfigurationProvider(xml.getPath(), false);
try {
Configuration conf = new ConfigurationImpl();
prov.init(conf);
prov.createConfig();
prov.addModules(Arrays.asList("module0"));
List<String> plugins = new LinkedList<String>();
plugins.add("org.walkmod:imports-cleaner");
AddPluginCommand command = new AddPluginCommand(plugins);
List<PluginConfig> pluginCfgs = command.build();
prov.addPluginConfig(pluginCfgs.get(0), true);
String output = FileUtils.readFileToString(modulexml);
System.out.println(output);
Assert.assertTrue(output.contains("imports-cleaner"));
} finally {
if (aux.exists()) {
FileUtils.deleteQuietly(aux);
}
}
}
use of org.walkmod.conf.entities.PluginConfig 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"));
}
Aggregations