### Question:
ListTypeResolversImpl implements ListTypeResolvers { @Override public DataFetcher<CompletableFuture<ListType>> getListTypeDataFetcher() { return environment -> { long listTypeId = getListTypeId(environment); if (listTypeId <= 0) { return null; } DataLoader<Long, ListType> dataLoader = environment.getDataLoader(ListTypeBatchLoader.KEY); return dataLoader.load(listTypeId); }; }  @Reference(unbind = "-") void setListTypeLocalService(ListTypeLocalService listtypeLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<ListType>> getListTypesDataFetcher(); @Override DataFetcher<List<ListType>> getListTypesByTypeDataFetcher(); @Override DataFetcher<CompletableFuture<ListType>> getListTypeDataFetcher(); @Override DataFetcher<ListType> createListTypeDataFetcher(); @Override DataFetcher<ListType> deleteListTypeDataFetcher();  }### Answer:
@Test public void getListTypeDataFetcher_should_return_the_searched_object() throws Exception { ListType expectedResult = mock(ListType.class); expectedResult.setListTypeId(LIST_TYPE_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("listTypeId")) .thenReturn(LIST_TYPE_ID); when(dataLoader.load(LIST_TYPE_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<ListType> asyncResult = resolvers.getListTypeDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); ListType result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getListTypeDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("listTypeId")) .thenReturn(0L); CompletableFuture<ListType> asyncResult = resolvers.getListTypeDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getListTypeDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("listTypeId")) .thenReturn(LIST_TYPE_ID); when(dataLoader.load(LIST_TYPE_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<ListType> asyncResult = resolvers.getListTypeDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); ListType result = asyncResult.get(); assertNull(result); }