use of org.terasology.persistence.typeHandling.inMemory.arrays.PersistedIntegerArray in project Terasology by MovingBlocks.
the class ArrayTypeHandlerTest method testDeserialize.
@Test
void testDeserialize() {
IntTypeHandler elementTypeHandler = mock(IntTypeHandler.class);
ArrayTypeHandler<Integer> typeHandler = new ArrayTypeHandler<>(elementTypeHandler, TypeInfo.of(Integer.class));
TIntList intList = new TIntArrayList(ARRAY_SIZE);
for (Integer i : Collections.nCopies(ARRAY_SIZE, -1)) {
intList.add(i);
}
typeHandler.deserialize(new PersistedIntegerArray(intList));
verify(elementTypeHandler, times(intList.size())).deserialize(any());
}
use of org.terasology.persistence.typeHandling.inMemory.arrays.PersistedIntegerArray in project Terasology by MovingBlocks.
the class CollectionTypeHandlerTest method testDeserialize.
@Test
void testDeserialize() {
IntTypeHandler elementTypeHandler = mock(IntTypeHandler.class);
CollectionCopyConstructor<Collection<Integer>, Integer> constructor = mock(CollectionCopyConstructor.class);
when(constructor.construct(Lists.newArrayList())).then((Answer<Collection<Integer>>) invocation -> Queues.newArrayDeque());
CollectionTypeHandler<Integer> typeHandler = new CollectionTypeHandler<>(elementTypeHandler, constructor);
TIntList intList = new TIntArrayList();
for (Integer i : Collections.nCopies(500, -1)) {
intList.add(i);
}
typeHandler.deserialize(new PersistedIntegerArray(intList));
verify(constructor).construct(Lists.newArrayList());
verify(elementTypeHandler, times(intList.size())).deserialize(any());
}
Aggregations