update to xbib net 2.0.1

This commit is contained in:
Jörg Prante 2019-08-29 16:05:58 +02:00
parent 22658af20e
commit f7d4422d8f
2 changed files with 27 additions and 2 deletions

View file

@ -12,15 +12,20 @@ import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.io.StringReader; import java.io.StringReader;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger;
/** /**
* *
*/ */
public class SettingsTest extends Assert { public class SettingsTest extends Assert {
private static final Logger logger = Logger.getLogger(SettingsTest.class.getName());
@Test @Test
public void testEmpty() { public void testEmpty() {
Settings settings = Settings.EMPTY_SETTINGS; Settings settings = Settings.EMPTY_SETTINGS;
@ -36,6 +41,26 @@ public class SettingsTest extends Assert {
assertEquals("c", settings.getAsArray("input")[2]); assertEquals("c", settings.getAsArray("input")[2]);
} }
@SuppressWarnings("unchecked")
@Test
public void testArrayOfMaps() {
Settings settings = Settings.settingsBuilder()
.put("location.0.code", "Code 0")
.put("location.0.name", "Name 0")
.put("location.1.code", "Code 1")
.put("location.1.name", "Name 1")
.build();
// turn map with index keys 0,1,... into a list of maps
Map<String, Object> map = settings.getAsSettings("location").getAsStructuredMap();
List<Map<String, Object>> list = new ArrayList<>();
for (Map.Entry<String, Object> entry : map.entrySet()) {
list.add((Map<String, Object>) entry.getValue());
}
logger.info(list.toString());
assertEquals("[{name=Name 0, code=Code 0}, {name=Name 1, code=Code 1}]", list.toString());
}
@Test @Test
public void testGroups() { public void testGroups() {
Settings settings = Settings.settingsBuilder() Settings settings = Settings.settingsBuilder()

View file

@ -1,8 +1,8 @@
group = org.xbib group = org.xbib
name = content name = content
version = 2.0.0 version = 2.0.1
xbib-net.version = 2.0.0 xbib-net.version = 2.0.1
jackson.version = 2.9.9 jackson.version = 2.9.9
jackson-databind.version = 2.9.9.2 jackson-databind.version = 2.9.9.2