### Question:
DLFolderResolversImpl implements DLFolderResolvers { @Override public DataFetcher<CompletableFuture<DLFolder>> getDLFolderDataFetcher() { return environment -> { long folderId = getFolderId(environment); if (folderId <= 0) { return null; } DataLoader<Long, DLFolder> dataLoader = environment.getDataLoader(DLFolderBatchLoader.KEY); return dataLoader.load(folderId); }; }  @Reference(unbind = "-") void setDLFolderLocalService(DLFolderLocalService dlFolderLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<DLFolder>> getDLFoldersDataFetcher(); @Override DataFetcher<List<DLFolder>> getDLFoldersForTypeDataFetcher(); @Override DataFetcher<CompletableFuture<DLFolder>> getDLFolderDataFetcher(); @Override DataFetcher<DLFolder> createDLFolderDataFetcher(); @Override DataFetcher<DLFolder> updateDLFolderDataFetcher(); @Override DataFetcher<DLFolder> deleteDLFolderDataFetcher();  }### Answer:
@Test public void getDLFolderDataFetcher_should_return_the_searched_object() throws Exception { DLFolder expectedResult = mock(DLFolder.class); expectedResult.setFolderId(FOLDER_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("folderId")) .thenReturn(FOLDER_ID); when(dataLoader.load(FOLDER_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<DLFolder> asyncResult = resolvers.getDLFolderDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); DLFolder result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getDLFolderDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("folderId")) .thenReturn(0L); CompletableFuture<DLFolder> asyncResult = resolvers.getDLFolderDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getDLFolderDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("folderId")) .thenReturn(FOLDER_ID); when(dataLoader.load(FOLDER_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<DLFolder> asyncResult = resolvers.getDLFolderDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); DLFolder result = asyncResult.get(); assertNull(result); }