use of org.walkmod.conf.entities.impl.ConfigurationImpl in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testAddModulesToConfig.
@Test
public void testAddModulesToConfig() throws Exception {
List<String> list = new LinkedList<String>();
list.add("module1");
File file = new File("src/test/resources/yaml/addmodules.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);
provider.addModules(list);
String output = FileUtils.readFileToString(file);
String desiredOutput = "modules:\n";
desiredOutput += "- \"module1\"";
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 testAddConfigurationParameterWithChain.
@Test
public void testAddConfigurationParameterWithChain() 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, "mychain", false);
String output = FileUtils.readFileToString(file);
System.out.println(output);
Assert.assertTrue(output.contains("params") && output.contains("testParam") && output.contains("hello"));
provider.addConfigurationParameter("testParam", "bye", "imports-cleaner", null, null, "mychain2", false);
output = FileUtils.readFileToString(file);
System.out.println(output);
Assert.assertFalse(output.contains("params") && output.contains("testParam") && output.contains("bye"));
provider.addConfigurationParameter("testParam", "bye", "imports-cleaner", null, null, "mychain", false);
output = FileUtils.readFileToString(file);
System.out.println(output);
Assert.assertTrue(output.contains("params") && output.contains("testParam") && output.contains("bye") && !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 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.impl.ConfigurationImpl 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);
}
}
}
use of org.walkmod.conf.entities.impl.ConfigurationImpl in project walkmod-core by walkmod.
the class YAMLConfigurationProviderTest method testEmptyChain.
@Test
public void testEmptyChain() throws Exception {
File file = new File("src/test/resources/yaml/addEmptychain.yml");
if (file.exists()) {
file.delete();
}
file.createNewFile();
FileUtils.write(file, "");
YAMLConfigurationProvider provider = new YAMLConfigurationProvider(file.getPath());
Configuration conf = new ConfigurationImpl();
provider.init(conf);
ChainConfig chainCfg = new ChainConfigImpl();
try {
provider.addChainConfig(chainCfg, false, null);
String output = FileUtils.readFileToString(file);
Assert.assertEquals("", output);
} finally {
if (file.exists()) {
file.delete();
}
}
}
Aggregations