use of org.walkmod.conf.entities.impl.ConfigurationImpl 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();
}
}
}
use of org.walkmod.conf.entities.impl.ConfigurationImpl in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testAddChainTransformation.
@Test
public void testAddChainTransformation() throws Exception {
Map<String, String> params = new HashMap<String, String>();
params.put("refactoringConfigFile", "src/conf/refactoring-methods.json");
AddTransformationCommand command = new AddTransformationCommand("walkmod:commons:method-refactor", null, false, null, null, null, params, 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(null, null, transformationCfg, false, null, null);
String output = FileUtils.readFileToString(file);
String desiredOutput = "transformations:\n";
desiredOutput += "- type: \"walkmod:commons:method-refactor\"\n";
desiredOutput += " params:\n";
desiredOutput += " refactoringConfigFile: \"src/conf/refactoring-methods.json\"";
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 testAddPluginRecursively.
@Test
public void testAddPluginRecursively() throws Exception {
File dir = new File("src/test/resources/multimoduleyaml");
dir.mkdirs();
File module0 = new File(dir, "module0");
module0.mkdir();
File moduleCfg = new File(module0, "walkmod.yml");
File file = new File(dir, "walkmod.yml");
if (file.exists()) {
file.delete();
}
file.createNewFile();
try {
YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
Configuration conf = new ConfigurationImpl();
provider.init(conf);
provider.addModules(Arrays.asList("module0"));
PluginConfig pluginCfg = new PluginConfigImpl();
pluginCfg.setGroupId("org.walkmod");
pluginCfg.setArtifactId("myplugin");
pluginCfg.setVersion("1.0");
provider.addPluginConfig(pluginCfg, true);
String output = FileUtils.readFileToString(moduleCfg);
String desiredOutput = "plugins:\n";
desiredOutput += "- \"org.walkmod:myplugin:1.0\"";
Assert.assertEquals(desiredOutput, output);
} finally {
if (dir.exists()) {
FileUtils.deleteDirectory(dir);
}
}
}
use of org.walkmod.conf.entities.impl.ConfigurationImpl in project walkmod-core by walkmod.
the class WalkModFacade method inspectPlugin.
/**
* Retrieves the bean definitions that contains an specific plugin.
*
* @param plugin
* Plugin container of bean definitions.
* @return List of bean definitions.
*/
public List<BeanDefinition> inspectPlugin(PluginConfig plugin) {
Configuration conf = new ConfigurationImpl();
Collection<PluginConfig> plugins = new LinkedList<PluginConfig>();
plugins.add(plugin);
conf.setPlugins(plugins);
ConfigurationManager manager = new ConfigurationManager(conf, false, locateConfigurationProvider());
manager.executeConfigurationProviders();
return conf.getAvailableBeans(plugin);
}
use of org.walkmod.conf.entities.impl.ConfigurationImpl in project walkmod-core by walkmod.
the class WalkModFacade method createConfig.
private Configuration createConfig(String[] chains, ConfigurationProvider... cp) throws InvalidConfigurationException {
Configuration config = new ConfigurationImpl();
try {
DynamicConfigurationProvider prov = new DynamicConfigurationProvider(options, chains);
prov.init(config);
prov.load();
ConfigurationManager cfgManager = new ConfigurationManager(config, cp);
DynamicModulesConfigurationProvider prov2 = new DynamicModulesConfigurationProvider();
prov2.init(config);
prov2.load();
config = cfgManager.getConfiguration();
config.setParameters(options.getMutableCopyOfDynamicArgs());
} catch (Exception e) {
printConfigError(e);
}
return config;
}
Aggregations