### Question:
AssetEntryResolversImpl implements AssetEntryResolvers { @Override public DataFetcher<CompletableFuture<AssetEntry>> getAssetEntryDataFetcher() { return environment -> { long entryId = getEntryId(environment); if (entryId <= 0) { return null; } DataLoader<Long, AssetEntry> dataLoader = environment.getDataLoader(AssetEntryBatchLoader.KEY); return dataLoader.load(entryId); }; }  @Reference(unbind = "-") void setAssetEntryLocalService(AssetEntryLocalService assetEntryLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<AssetEntry>> getAssetEntriesDataFetcher(); @Override DataFetcher<List<AssetEntry>> getAssetEntriesWithCategoryDataFetcher(); @Override DataFetcher<List<AssetEntry>> getAssetEntriesWithTagDataFetcher(); @Override DataFetcher<CompletableFuture<AssetEntry>> getAssetEntryDataFetcher(); @Override DataFetcher<AssetEntry> associateAssetEntryWithCategoryDataFetcher(); @Override DataFetcher<AssetEntry> dissociateAssetEntryFromCategoryDataFetcher(); @Override DataFetcher<AssetEntry> associateAssetEntryWithTagDataFetcher(); @Override DataFetcher<AssetEntry> dissociateAssetEntryFromTagDataFetcher();  }### Answer:
@Test public void getAssetEntryDataFetcher_should_return_the_searched_object() throws Exception { AssetEntry expectedResult = mock(AssetEntry.class); expectedResult.setEntryId(ENTRY_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("entryId")) .thenReturn(ENTRY_ID); when(dataLoader.load(ENTRY_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<AssetEntry> asyncResult = resolvers.getAssetEntryDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); AssetEntry result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getAssetEntryDataFetcher_no_specified_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("entryId")) .thenReturn(0L); CompletableFuture<AssetEntry> asyncResult = resolvers.getAssetEntryDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getAssetEntryDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("entryId")) .thenReturn(ENTRY_ID); when(dataLoader.load(ENTRY_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<AssetEntry> asyncResult = resolvers.getAssetEntryDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); AssetEntry result = asyncResult.get(); assertNull(result); }