### Question:
DLFileEntryResolversImpl implements DLFileEntryResolvers { @Override public DataFetcher<CompletableFuture<DLFileEntry>> getDLFileEntryDataFetcher() { return environment -> { long fileEntryId = getFileEntryId(environment); if (fileEntryId <= 0) { return null; } DataLoader<Long, DLFileEntry> dataLoader = environment.getDataLoader(DLFileEntryBatchLoader.KEY); return dataLoader.load(fileEntryId); }; }  @Reference(unbind = "-") void setDLFileEntryLocalService(DLFileEntryLocalService dlFileEntryLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<DLFileEntry>> getDLFileEntriesDataFetcher(); @Override DataFetcher<CompletableFuture<DLFileEntry>> getDLFileEntryDataFetcher(); @Override DataFetcher<DLFileEntry> createDLFileEntryDataFetcher(); @Override DataFetcher<DLFileEntry> updateDLFileEntryDataFetcher(); @Override DataFetcher<DLFileEntry> deleteDLFileEntryDataFetcher();  }### Answer:
@Test public void getDLFileEntryDataFetcher_should_return_the_searched_object() throws Exception { DLFileEntry expectedResult = mock(DLFileEntry.class); expectedResult.setFileEntryId(FILE_ENTRY_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("fileEntryId")) .thenReturn(FILE_ENTRY_ID); when(dataLoader.load(FILE_ENTRY_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<DLFileEntry> asyncResult = resolvers.getDLFileEntryDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); DLFileEntry result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getDLFileEntryDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("fileEntryId")) .thenReturn(0L); CompletableFuture<DLFileEntry> asyncResult = resolvers.getDLFileEntryDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getDLFileEntryDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("fileEntryId")) .thenReturn(FILE_ENTRY_ID); when(dataLoader.load(FILE_ENTRY_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<DLFileEntry> asyncResult = resolvers.getDLFileEntryDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); DLFileEntry result = asyncResult.get(); assertNull(result); }