### Question:
DLFileVersionResolversImpl implements DLFileVersionResolvers { @Override public DataFetcher<CompletableFuture<DLFileVersion>> getDLFileVersionDataFetcher() { return environment -> { long fileVersionId = getFileVersionId(environment); if (fileVersionId <= 0) { return null; } DataLoader<Long, DLFileVersion> dataLoader = environment.getDataLoader(DLFileVersionBatchLoader.KEY); return dataLoader.load(fileVersionId); }; }  @Reference(unbind = "-") void setDLFileVersionLocalService(DLFileVersionLocalService dlFileVersionLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<DLFileVersion>> getDLFileVersionsDataFetcher(); @Override DataFetcher<CompletableFuture<DLFileVersion>> getDLFileVersionDataFetcher();  }### Answer:
@Test public void getDLFileVersionDataFetcher_should_return_the_searched_object() throws Exception { DLFileVersion expectedResult = mock(DLFileVersion.class); expectedResult.setFileVersionId(FILE_VERSION_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("fileVersionId")) .thenReturn(FILE_VERSION_ID); when(dataLoader.load(FILE_VERSION_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<DLFileVersion> asyncResult = resolvers.getDLFileVersionDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); DLFileVersion result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getDLFileVersionDataFetcher_no_specified_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("fileVersionId")) .thenReturn(0L); CompletableFuture<DLFileVersion> asyncResult = resolvers.getDLFileVersionDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getDLFileVersionDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("fileVersionId")) .thenReturn(FILE_VERSION_ID); when(dataLoader.load(FILE_VERSION_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<DLFileVersion> asyncResult = resolvers.getDLFileVersionDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); DLFileVersion result = asyncResult.get(); assertNull(result); }