use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class MemoryDataTest method testDeepSerialization.
@Test
public void testDeepSerialization() {
List<List<?>> values = Lists.newArrayList();
List<List<?>> sub = Lists.newArrayList();
values.add(sub);
SimpleData data1 = new SimpleData(1, 2.0, "3", Arrays.asList("foo", "bar", "baz"));
SimpleData data2 = new SimpleData(2, 3.0, "4", Arrays.asList("bar", "baz", "foo"));
SimpleData data3 = new SimpleData(3, 4.0, "5", Arrays.asList("baz", "foo", "bar"));
sub.add(ImmutableList.of(data1));
sub.add(ImmutableList.of(data2));
DataContainer main = DataContainer.createNew();
main.set(DataQuery.of("ROOT"), data3);
main.set(DataQuery.of("SINGLE"), ImmutableList.of(data2));
main.set(DataQuery.of("SUB"), values);
main.getMap(of()).get();
}
use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class MemoryDataTest method testAbsents.
@Test
public void testAbsents() {
DataContainer container = DataContainer.createNew();
DataQuery testQuery = of("foo", "bar", "baz");
assertTrue(!container.get(testQuery).isPresent());
assertTrue(!container.getBoolean(testQuery).isPresent());
assertTrue(!container.getBooleanList(testQuery).isPresent());
assertTrue(!container.getByteList(testQuery).isPresent());
assertTrue(!container.getCharacterList(testQuery).isPresent());
assertTrue(!container.getDouble(testQuery).isPresent());
assertTrue(!container.getDoubleList(testQuery).isPresent());
assertTrue(!container.getFloatList(testQuery).isPresent());
assertTrue(!container.getInt(testQuery).isPresent());
assertTrue(!container.getIntegerList(testQuery).isPresent());
assertTrue(!container.getList(testQuery).isPresent());
assertTrue(!container.getLong(testQuery).isPresent());
assertTrue(!container.getLongList(testQuery).isPresent());
assertTrue(!container.getMapList(testQuery).isPresent());
assertTrue(!container.getShortList(testQuery).isPresent());
assertTrue(!container.getString(testQuery).isPresent());
assertTrue(!container.getStringList(testQuery).isPresent());
assertTrue(!container.getView(testQuery).isPresent());
}
use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class MemoryDataTest method testCreateView.
@Test
public void testCreateView() {
DataContainer container = DataContainer.createNew();
DataQuery tempQuery = of("foo", "bar", "baz");
container.createView(tempQuery);
assertTrue(container.getView(tempQuery).isPresent());
}
use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class MemoryDataTest method testGetSerializable.
@Test
public void testGetSerializable() throws Exception {
initBuilder();
List<String> myList = ImmutableList.of("foo", "bar", "baz");
SimpleData temp = new SimpleData(1, 2.0, "foo", myList);
DataContainer container = temp.toContainer();
Optional<SimpleData> fromContainer = container.getSerializable(of(), SimpleData.class);
assertTrue(fromContainer.isPresent());
assertTrue(Objects.equal(fromContainer.get(), temp));
assertTrue(container.contains(of("myStringList")));
assertTrue(container.getStringList(of("myStringList")).get().equals(myList));
}
use of org.spongepowered.api.data.DataContainer in project SpongeCommon by SpongePowered.
the class MemoryDataTest method testGetName.
@Test
public void testGetName() {
DataContainer container = DataContainer.createNew();
assertTrue(container.getName() != null);
}
Aggregations