### Question:
DDMContentResolversImpl implements DDMContentResolvers { @Override public DataFetcher<DDMContent> deleteDDMContentDataFetcher() { return environment -> { long contentId = util.getLongArg(environment, "contentId"); return ddmContentLocalService.deleteDDMContent(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 deleteDDMContentDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("contentId", CONTENT_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); DDMContent expectedResult = mock(DDMContent.class); expectedResult.setContentId(CONTENT_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteDDMContent(eq(CONTENT_ID))) .thenReturn(expectedResult); DDMContent result = resolvers.deleteDDMContentDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchContentException.class) public void deleteDDMContentDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); DDMContent expectedResult = mock(DDMContent.class); expectedResult.setContentId(CONTENT_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteDDMContent(eq(CONTENT_ID))) .thenThrow(NoSuchContentException.class); DDMContent result = resolvers.deleteDDMContentDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchContentException.class) public void deleteDDMContentDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("contentId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); DDMContent expectedResult = mock(DDMContent.class); expectedResult.setContentId(CONTENT_ID); useMockGraphQLUtil(environment, USER_ID, false); when(graphQLUtil.getLongArg(eq(environment), eq("contentId"))) .thenReturn(789456L); when(localService.deleteDDMContent(eq(789456L))) .thenThrow(NoSuchContentException.class); DDMContent result = resolvers.deleteDDMContentDataFetcher() .get(environment); assertNull(result); }