use of org.spongepowered.api.data.DataQuery in project SpongeCommon by SpongePowered.
the class MemoryDataTest method testNumberedLists.
@Test
public void testNumberedLists() {
DataContainer container = DataContainer.createNew();
DataQuery testQuery = of("foo", "bar", "baz");
List<Integer> intList = ImmutableList.of(1, 2, 3, 4);
container.set(testQuery, intList);
assertTrue(container.getIntegerList(testQuery).isPresent());
assertTrue(container.getIntegerList(testQuery).get().equals(intList));
List<Double> doubleList = ImmutableList.of(1.0D, 2.0D, 3.0D, 4.0D);
container.set(testQuery, doubleList);
assertTrue(container.getDoubleList(testQuery).isPresent());
assertTrue(container.getDoubleList(testQuery).get().equals(doubleList));
List<Short> shortList = ImmutableList.of((short) 1, (short) 2, (short) 3, (short) 4);
container.set(testQuery, shortList);
assertTrue(container.getShortList(testQuery).isPresent());
assertTrue(container.getShortList(testQuery).get().equals(shortList));
List<Byte> byteList = ImmutableList.of((byte) 1, (byte) 2, (byte) 3, (byte) 4);
container.set(testQuery, byteList);
assertTrue(container.getByteList(testQuery).isPresent());
assertTrue(container.getByteList(testQuery).get().equals(byteList));
}
use of org.spongepowered.api.data.DataQuery in project SpongeCommon by SpongePowered.
the class MemoryDataTest method testEmptyQuery.
@Test
public void testEmptyQuery() {
DataContainer container = DataContainer.createNew();
DataQuery query = of("");
container.set(query, "foo");
assertTrue(container.get(query).isPresent());
assertTrue(container.get(query).get().equals("foo"));
}
use of org.spongepowered.api.data.DataQuery in project SpongeCommon by SpongePowered.
the class MemoryDataTest method testBoolean.
@Test
public void testBoolean() {
DataContainer container = DataContainer.createNew();
DataQuery testQuery = of("foo", "bar");
container.set(testQuery, false);
Optional<Boolean> booleanOptional = container.getBoolean(testQuery);
assertTrue(booleanOptional.isPresent());
assertTrue(!booleanOptional.get());
}
use of org.spongepowered.api.data.DataQuery in project SpongeCommon by SpongePowered.
the class MemoryDataTest method testIncorrectType.
@Test
public void testIncorrectType() {
DataContainer container = DataContainer.createNew();
DataQuery testQuery = of("foo", "bar");
container.set(testQuery, "foo");
Optional<Integer> optional = container.getInt(testQuery);
assertTrue(!optional.isPresent());
}
use of org.spongepowered.api.data.DataQuery in project SpongeCommon by SpongePowered.
the class MemoryDataTest method testSetData.
@Test
public void testSetData() {
DataContainer container = DataContainer.createNew();
DataQuery testQuery = of('.', "foo.bar");
container.set(testQuery, 1);
Optional<Integer> optional = container.getInt(testQuery);
assertTrue(optional.isPresent());
}
Aggregations