### Question:
DLFileEntryMetadataResolversImpl implements DLFileEntryMetadataResolvers { @Override public DataFetcher<CompletableFuture<DLFileEntryMetadata>> getDLFileEntryMetadataDataFetcher() { return environment -> { long fileEntryMetadataId = util.getLongArg(environment, "fileEntryMetadataId"); if (fileEntryMetadataId <= 0) { return null; } DataLoader<Long, DLFileEntryMetadata> dataLoader = environment.getDataLoader(DLFileEntryMetadataBatchLoader.KEY); return dataLoader.load(fileEntryMetadataId); }; }  @Reference(unbind = "-") void setDLFileEntryMetadataLocalService(DLFileEntryMetadataLocalService dlFileEntryMetadataLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<DLFileEntryMetadata>> getDLFileEntryMetadatasDataFetcher(); @Override DataFetcher<CompletableFuture<DLFileEntryMetadata>> getDLFileEntryMetadataDataFetcher();  }### Answer:
@Test public void getDLFileEntryMetadataDataFetcher_should_return_the_searched_object() throws Exception { DLFileEntryMetadata expectedResult = mock(DLFileEntryMetadata.class); expectedResult.setFileEntryMetadataId(FILE_ENTRY_METADATA_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("fileEntryMetadataId")) .thenReturn(FILE_ENTRY_METADATA_ID); when(dataLoader.load(FILE_ENTRY_METADATA_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<DLFileEntryMetadata> asyncResult = resolvers.getDLFileEntryMetadataDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); DLFileEntryMetadata result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getDLFileEntryMetadataDataFetcher_no_specified_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("fileEntryMetadataId")) .thenReturn(0L); CompletableFuture<DLFileEntryMetadata> asyncResult = resolvers.getDLFileEntryMetadataDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getDLFileEntryMetadataDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("fileEntryMetadataId")) .thenReturn(FILE_ENTRY_METADATA_ID); when(dataLoader.load(FILE_ENTRY_METADATA_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<DLFileEntryMetadata> asyncResult = resolvers.getDLFileEntryMetadataDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); DLFileEntryMetadata result = asyncResult.get(); assertNull(result); }