@@ -0,0 +1,2973 @@
+/*%0A * Copyright 2019 MovingBlocks%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *      http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage org.terasology.persistence.typeHandling;%0A%0Aimport com.google.common.collect.Lists;%0Aimport org.junit.Test;%0Aimport org.mockito.invocation.InvocationOnMock;%0Aimport org.mockito.stubbing.Answer;%0Aimport org.terasology.reflection.TypeInfo;%0A%0Aimport java.util.List;%0Aimport java.util.Optional;%0A%0Aimport static org.hamcrest.CoreMatchers.*;%0Aimport static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertThat;%0Aimport static org.mockito.Mockito.*;%0A%0Apublic class FutureTypeHandlerTest %7B%0A    private final TypeHandlerLibrary typeHandlerLibrary = spy(TypeHandlerLibrary.createDefaultLibrary());%0A%0A    private static class RecursiveType%3CT%3E %7B%0A        final T data;%0A        final List%3CRecursiveType%3CT%3E%3E children;%0A%0A        @SafeVarargs%0A        private RecursiveType(T data, RecursiveType%3CT%3E... children) %7B%0A            this.data = data;%0A            this.children = Lists.newArrayList(children);%0A        %7D%0A    %7D%0A%0A    private class ResultCaptor%3CT%3E implements Answer %7B%0A        private T result = null;%0A        public T getResult() %7B%0A            return result;%0A        %7D%0A%0A        @Override%0A        public T answer(InvocationOnMock invocationOnMock) throws Throwable %7B%0A            result = (T) invocationOnMock.callRealMethod();%0A            return result;%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testRecursiveType() %7B%0A        ResultCaptor%3COptional%3CTypeHandler%3CRecursiveType%3CInteger%3E%3E%3E%3E resultCaptor = new ResultCaptor%3C%3E();%0A%0A        doAnswer(resultCaptor).when(typeHandlerLibrary).getTypeHandler(%0A                eq(new TypeInfo%3CRecursiveType%3CInteger%3E%3E() %7B%7D.getType()), (ClassLoader) any()%0A        );%0A%0A        TypeHandler%3CRecursiveType%3CInteger%3E%3E typeHandler =%0A                typeHandlerLibrary.getTypeHandler(%0A                        new TypeInfo%3CRecursiveType%3CInteger%3E%3E() %7B%7D,%0A                        FutureTypeHandlerTest.class%0A                ).get();%0A        %0A        verify(typeHandlerLibrary, times(1)).getTypeHandler(%0A                eq(new TypeInfo%3CRecursiveType%3CInteger%3E%3E() %7B%7D.getType()), (ClassLoader) any()%0A        );%0A%0A        assertThat(resultCaptor.getResult().get(),%0A                both(notNullValue()).and(instanceOf(FutureTypeHandler.class)));%0A%0A        FutureTypeHandler%3CRecursiveType%3CInteger%3E%3E future =%0A                (FutureTypeHandler%3CRecursiveType%3CInteger%3E%3E) resultCaptor.getResult().get();%0A%0A        assertEquals(typeHandler, future.typeHandler);%0A    %7D%0A%7D

Add FutureTypeHandlerTest