use of org.locationtech.geogig.api.porcelain.ConfigOp in project GeoGig by boundlessgeo.
the class ConfigOpTest method test.
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"));
}
use of org.locationtech.geogig.api.porcelain.ConfigOp in project GeoGig by boundlessgeo.
the class ConfigOpTest method testGetDefaultWithNoLocalRepository.
@Test
public void testGetDefaultWithNoLocalRepository() {
ConfigDatabase database = mock(ConfigDatabase.class);
when(database.get(anyString())).thenThrow(new ConfigException(StatusCode.INVALID_LOCATION));
when(database.getGlobal(anyString())).thenReturn(Optional.of("value"));
ConfigOp config = new ConfigOp(database);
config.setScope(ConfigScope.DEFAULT).setAction(ConfigAction.CONFIG_GET).setName("section.key").setValue(null).call();
}
use of org.locationtech.geogig.api.porcelain.ConfigOp in project GeoGig by boundlessgeo.
the class ConfigOpTest method testNoAction.
@Test
public void testNoAction() {
final ConfigOp config = geogig.command(ConfigOp.class);
exception.expect(ConfigException.class);
config.setAction(ConfigAction.CONFIG_NO_ACTION).setName("section.key").setValue(null).call();
}
use of org.locationtech.geogig.api.porcelain.ConfigOp in project GeoGig by boundlessgeo.
the class ConfigOpTest method testListDefaultWithNoLocalRepository.
@Test
public void testListDefaultWithNoLocalRepository() {
ConfigDatabase database = mock(ConfigDatabase.class);
when(database.getAll()).thenThrow(new ConfigException(StatusCode.INVALID_LOCATION));
ConfigOp config = new ConfigOp(database);
config.setScope(ConfigScope.DEFAULT).setAction(ConfigAction.CONFIG_LIST).setName(null).setValue(null).call();
}
use of org.locationtech.geogig.api.porcelain.ConfigOp in project GeoGig by boundlessgeo.
the class ConfigOpTest method testNullNameValuePairForGet.
@Test
public void testNullNameValuePairForGet() {
final ConfigOp config = geogig.command(ConfigOp.class);
exception.expect(ConfigException.class);
config.setScope(ConfigScope.GLOBAL).setAction(ConfigAction.CONFIG_GET).setName(null).setValue(null).call();
}
Aggregations