### Question:
JournalFeedResolversImpl implements JournalFeedResolvers { @Override public DataFetcher<CompletableFuture<JournalFeed>> getJournalFeedDataFetcher() { return environment -> { long id = util.getLongArg(environment, "id"); if (id <= 0) { return null; } DataLoader<Long, JournalFeed> dataLoader = environment.getDataLoader(JournalFeedBatchLoader.KEY); return dataLoader.load(id); }; }  @Reference(unbind = "-") void setJournalFeedLocalService(JournalFeedLocalService journalFeedLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<JournalFeed>> getJournalFeedsDataFetcher(); @Override DataFetcher<CompletableFuture<JournalFeed>> getJournalFeedDataFetcher(); @Override DataFetcher<JournalFeed> createJournalFeedDataFetcher(); @Override DataFetcher<JournalFeed> updateJournalFeedDataFetcher(); @Override DataFetcher<JournalFeed> deleteJournalFeedDataFetcher();  }### Answer:
@Test public void getJournalFeedDataFetcher_should_return_the_searched_object() throws Exception { JournalFeed expectedResult = mock(JournalFeed.class); expectedResult.setId(ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("id")) .thenReturn(ID); when(dataLoader.load(ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<JournalFeed> asyncResult = resolvers.getJournalFeedDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); JournalFeed result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getJournalFeedDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("id")) .thenReturn(0L); CompletableFuture<JournalFeed> asyncResult = resolvers.getJournalFeedDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getJournalFeedDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("id")) .thenReturn(ID); when(dataLoader.load(ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<JournalFeed> asyncResult = resolvers.getJournalFeedDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); JournalFeed result = asyncResult.get(); assertNull(result); }