### Question:
ExpandoTableResolversImpl implements ExpandoTableResolvers { @Override public DataFetcher<CompletableFuture<ExpandoTable>> getExpandoTableDataFetcher() { return environment -> { long tableId = getTableId(environment); if (tableId <= 0) { return null; } DataLoader<Long, ExpandoTable> dataLoader = environment.getDataLoader(ExpandoTableBatchLoader.KEY); return dataLoader.load(tableId); }; }  @Reference(unbind = "-") void setExpandoTableLocalService(ExpandoTableLocalService expandoTableLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<ExpandoTable>> getExpandoTablesDataFetcher(); @Override DataFetcher<CompletableFuture<ExpandoTable>> getExpandoTableDataFetcher(); @Override DataFetcher<ExpandoTable> createExpandoTableDataFetcher(); @Override DataFetcher<ExpandoTable> updateExpandoTableDataFetcher(); @Override DataFetcher<ExpandoTable> deleteExpandoTableDataFetcher();  }### Answer:
@Test public void getExpandoTableDataFetcher_should_return_the_searched_object() throws Exception { ExpandoTable expectedResult = mock(ExpandoTable.class); expectedResult.setTableId(TABLE_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("tableId")) .thenReturn(TABLE_ID); when(dataLoader.load(TABLE_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<ExpandoTable> asyncResult = resolvers.getExpandoTableDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); ExpandoTable result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getExpandoTableDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("tableId")) .thenReturn(0L); CompletableFuture<ExpandoTable> asyncResult = resolvers.getExpandoTableDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getExpandoTableDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("tableId")) .thenReturn(TABLE_ID); when(dataLoader.load(TABLE_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<ExpandoTable> asyncResult = resolvers.getExpandoTableDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); ExpandoTable result = asyncResult.get(); assertNull(result); }