use of com.enonic.xp.script.serializer.MapSerializable in project xp by enonic.
the class ScriptMapGeneratorTest method testListValue.
@Test
public void testListValue() {
final List<Object> level2List = new ArrayList<>();
level2List.add("list2A");
level2List.add("list2B");
final List<Object> level1List = new ArrayList<>();
level1List.add("list1A");
level1List.add("list1B");
level1List.add(level2List);
final Map<String, Object> map = new HashMap<>();
map.put("mapValue", 1);
final HashMultimap<Object, Object> multimap = HashMultimap.create();
multimap.put("multimapValue", 1);
multimap.put("multimapValue", 2);
final List<Object> list = new ArrayList<>();
list.add(1);
list.add(true);
list.add("string");
list.add(level1List);
list.add(map);
list.add(multimap);
final MapSerializable value = gen -> gen.value("root", list);
final ScriptExports exports = runTestScript("serializer/serializer-test.js");
exports.executeMethod("testListValue", value);
}
use of com.enonic.xp.script.serializer.MapSerializable in project xp by enonic.
the class ScriptMapGeneratorTest method testObject.
@Test
public void testObject() {
final Object obj = (MapSerializable) gen -> {
gen.value("a", 1);
gen.value("b", "2");
gen.value("c", 3L);
gen.value("d", 4.0f);
};
final ScriptExports exports = runTestScript("serializer/serializer-test.js");
exports.executeMethod("testObject", obj);
}
Aggregations