### Question:
BlogsEntryResolversImpl implements BlogsEntryResolvers { @Override public DataFetcher<CompletableFuture<BlogsEntry>> getBlogsEntryDataFetcher() { return environment -> { long entryId = util.getLongArg(environment, "entryId"); if (entryId <= 0) { return null; } DataLoader<Long, BlogsEntry> dataLoader = environment.getDataLoader(BlogsEntryBatchLoader.KEY); return dataLoader.load(entryId); }; }  @Reference(unbind = "-") void setBlogsEntryLocalService(BlogsEntryLocalService blogsEntryLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<BlogsEntry>> getBlogsEntriesDataFetcher(); @Override DataFetcher<CompletableFuture<BlogsEntry>> getBlogsEntryDataFetcher(); @Override DataFetcher<BlogsEntry> createBlogsEntryDataFetcher(); @Override DataFetcher<BlogsEntry> updateBlogsEntryDataFetcher(); @Override DataFetcher<BlogsEntry> deleteBlogsEntryDataFetcher();  }### Answer:
@Test public void getBlogsEntryDataFetcher_should_return_the_searched_object() throws Exception { BlogsEntry expectedResult = mock(BlogsEntry.class); expectedResult.setEntryId(ENTRY_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("entryId")) .thenReturn(ENTRY_ID); when(dataLoader.load(ENTRY_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<BlogsEntry> asyncResult = resolvers.getBlogsEntryDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); BlogsEntry result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getBlogsEntryDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("entryId")) .thenReturn(0L); CompletableFuture<BlogsEntry> asyncResult = resolvers.getBlogsEntryDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getBlogsEntryDataFetcher_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<BlogsEntry> asyncResult = resolvers.getBlogsEntryDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); BlogsEntry result = asyncResult.get(); assertNull(result); }