### Question:
RatingsEntryResolversImpl implements RatingsEntryResolvers { @Override public DataFetcher<CompletableFuture<RatingsEntry>> getRatingsEntryDataFetcher() { return environment -> { long entryId = util.getLongArg(environment, "entryId"); if (entryId <= 0) { return null; } DataLoader<Long, RatingsEntry> dataLoader = environment.getDataLoader(RatingsEntryBatchLoader.KEY); return dataLoader.load(entryId); }; }  @Reference(unbind = "-") void setRatingsEntryLocalService(RatingsEntryLocalService ratingsEntryLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<RatingsEntry>> getRatingsEntriesDataFetcher(); @Override DataFetcher<CompletableFuture<RatingsEntry>> getRatingsEntryDataFetcher(); @Override DataFetcher<RatingsEntry> createRatingsEntryDataFetcher(); @Override DataFetcher<RatingsEntry> deleteRatingsEntryDataFetcher();  }### Answer:
@Test public void getRatingsEntryDataFetcher_should_return_the_searched_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("entryId", ENTRY_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); RatingsEntry expectedResult = mock(RatingsEntry.class); expectedResult.setEntryId(ENTRY_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("entryId")) .thenReturn(ENTRY_ID); when(dataLoader.load(ENTRY_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<RatingsEntry> asyncResult = resolvers.getRatingsEntryDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); RatingsEntry result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getRatingsEntryDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("entryId")) .thenReturn(0L); CompletableFuture<RatingsEntry> asyncResult = resolvers.getRatingsEntryDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getRatingsEntryDataFetcher_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<RatingsEntry> asyncResult = resolvers.getRatingsEntryDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); RatingsEntry result = asyncResult.get(); assertNull(result); }