### Question:
DDMContentResolversImpl implements DDMContentResolvers { @Override public DataFetcher<CompletableFuture<DDMContent>> getDDMContentDataFetcher() { return environment -> { long contentId = util.getLongArg(environment, "contentId"); if (contentId <= 0) { return null; } DataLoader<Long, DDMContent> dataLoader = environment.getDataLoader(DDMContentBatchLoader.KEY); return dataLoader.load(contentId); }; }  @Reference(unbind = "-") void setDDMContentLocalService(DDMContentLocalService ddmContentLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<DDMContent>> getDDMContentsDataFetcher(); @Override DataFetcher<CompletableFuture<DDMContent>> getDDMContentDataFetcher(); @Override DataFetcher<DDMContent> createDDMContentDataFetcher(); @Override DataFetcher<DDMContent> updateDDMContentDataFetcher(); @Override DataFetcher<DDMContent> deleteDDMContentDataFetcher();  }### Answer:
@Test public void getDDMContentDataFetcher_should_return_the_searched_object() throws Exception { DDMContent expectedResult = mock(DDMContent.class); expectedResult.setContentId(CONTENT_ID); useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("contentId")) .thenReturn(CONTENT_ID); when(dataLoader.load(CONTENT_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> expectedResult)); CompletableFuture<DDMContent> asyncResult = resolvers.getDDMContentDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); DDMContent result = asyncResult.get(); assertNotNull(result); assertEquals(expectedResult, result); }
@Test public void getDDMContentDataFetcher_no_specified_id_should_return_null() throws Exception { when(mockEnvironment.getArgument("contentId")) .thenReturn(0L); CompletableFuture<DDMContent> asyncResult = resolvers.getDDMContentDataFetcher() .get(mockEnvironment); assertNull(asyncResult); }
@Test public void getDDMContentDataFetcher_with_unknown_id_should_return_null() throws Exception { useSimpleGraphQLUtil(); when(mockEnvironment.getArgument("contentId")) .thenReturn(CONTENT_ID); when(dataLoader.load(CONTENT_ID)) .thenReturn(CompletableFuture.supplyAsync(() -> null)); CompletableFuture<DDMContent> asyncResult = resolvers.getDDMContentDataFetcher() .get(mockEnvironment); assertNotNull(asyncResult); DDMContent result = asyncResult.get(); assertNull(result); }