@After
public final void tearDownInternal() {
}
private void test(ConfigOp.ConfigScope scope) {
final ConfigOp config = geogig.command(ConfigOp.class);
config.setScope(scope);
config.setAction(ConfigAction.CONFIG_SET).setName("section.string").setValue("1").call();
Map<String, String> result = config.setAction(ConfigAction.CONFIG_GET)
.setName("section.string").setValue(null).call().or(new HashMap<String, String>());
assertEquals("1", result.get("section.string"));
// Test overwriting a value that already exists
config.setAction(ConfigAction.CONFIG_SET).setName("section.string").setValue("2").call();
result = config.setAction(ConfigAction.CONFIG_GET).setName("section.string").setValue(null)
.call().or(new HashMap<String, String>());
assertEquals("2", result.get("section.string"));
// Test unsetting a value that exists
config.setAction(ConfigAction.CONFIG_UNSET).setName("section.string").setValue(null).call();
result = config.setAction(ConfigAction.CONFIG_GET).setName("section.string").setValue(null)
.call().or(new HashMap<String, String>());
assertNull(result.get("section.string"));
// Test unsetting a value that doesn't exist
config.setAction(ConfigAction.CONFIG_UNSET).setName("section.string").setValue(null).call();
result = config.setAction(ConfigAction.CONFIG_GET).setName("section.string").setValue(null)
.call().or(new HashMap<String, String>());
assertNull(result.get("section.string"));
// Test removing a section that exists
config.setAction(ConfigAction.CONFIG_SET).setName("section.string").setValue("1").call();
config.setAction(ConfigAction.CONFIG_SET).setName("section.string2").setValue("2").call();
config.setAction(ConfigAction.CONFIG_REMOVE_SECTION).setName("section").setValue(null)
.call();
result = config.setAction(ConfigAction.CONFIG_GET).setName("section.string").setValue(null)
.call().or(new HashMap<String, String>());
assertNull(result.get("section.string"));
result = config.setAction(ConfigAction.CONFIG_GET).setName("section.string2")
.setValue(null).call().or(new HashMap<String, String>());
assertNull(result.get("section.string2"));
// Try listing the config file
config.setAction(ConfigAction.CONFIG_SET).setName("section.string").setValue("1").call();
config.setAction(ConfigAction.CONFIG_SET).setName("section.string2").setValue("2").call();
result = config.setAction(ConfigAction.CONFIG_LIST).call()
.or(new HashMap<String, String>());
assertEquals("1", result.get("section.string"));
assertEquals("2", result.get("section.string2"));
}