### Question:
WebsiteResolversImpl implements WebsiteResolvers { @Override public DataFetcher<CompletableFuture<Website>> getWebsiteDataFetcher() { return environment -> { long websiteId = util.getLongArg(environment, "websiteId"); if (websiteId <= 0) { return null; } DataLoader<Long, Website> dataLoader = environment.getDataLoader(WebsiteBatchLoader.KEY); return dataLoader.load(websiteId); }; }  @Reference(unbind = "-") void setWebsiteLocalService(WebsiteLocalService websiteLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<Website>> getWebsitesDataFetcher(); @Override DataFetcher<List<Website>> getWebsitesForEntityDataFetcher(); @Override DataFetcher<CompletableFuture<Website>> getWebsiteDataFetcher(); @Override DataFetcher<Website> createWebsiteDataFetcher(); @Override DataFetcher<Website> updateWebsiteDataFetcher(); @Override DataFetcher<Website> deleteWebsiteDataFetcher();  }### Answer:
@Test public void getWebsiteDataFetcher_should_return_the_searched_object() throws Exception { Website expectedResult = mock(Website.class); expectedResult.setWebsiteId(WEBSITE_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("websiteId")) .thenReturn(WEBSITE_ID); when(dataLoader.load(WEBSITE_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<Website> asyncResult = resolvers.getWebsiteDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); Website result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getWebsiteDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("websiteId")) .thenReturn(0L); CompletableFuture<Website> asyncResult = resolvers.getWebsiteDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getWebsiteDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("websiteId")) .thenReturn(WEBSITE_ID); when(dataLoader.load(WEBSITE_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<Website> asyncResult = resolvers.getWebsiteDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); Website result = asyncResult.get(); assertNull(result); }