### Question:
DDMTemplateResolversImpl implements DDMTemplateResolvers { @Override public DataFetcher<DDMTemplate> deleteDDMTemplateDataFetcher() { return environment -> { long templateId = util.getLongArg(environment, "templateId"); return ddmTemplateLocalService.deleteDDMTemplate(templateId); }; }  @Reference(unbind = "-") void setDDMTemplateLocalService(DDMTemplateLocalService ddmTemplateLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<DDMTemplate>> getDDMTemplatesDataFetcher(); @Override DataFetcher<CompletableFuture<DDMTemplate>> getDDMTemplateDataFetcher(); @Override DataFetcher<DDMTemplate> getDDMTemplateByKeyDataFetcher(); @Override DataFetcher<DDMTemplate> createDDMTemplateDataFetcher(); @Override DataFetcher<DDMTemplate> updateDDMTemplateDataFetcher(); @Override DataFetcher<DDMTemplate> deleteDDMTemplateDataFetcher();  }### Answer:
@Test public void deleteDDMTemplateDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("templateId", TEMPLATE_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); DDMTemplate expectedResult = mock(DDMTemplate.class); expectedResult.setTemplateId(TEMPLATE_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteDDMTemplate(eq(TEMPLATE_ID))) .thenReturn(expectedResult); DDMTemplate result = resolvers.deleteDDMTemplateDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchTemplateException.class) public void deleteDDMTemplateDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); DDMTemplate expectedResult = mock(DDMTemplate.class); expectedResult.setTemplateId(TEMPLATE_ID); useMockGraphQLUtil(environment, USER_ID, true); when(localService.deleteDDMTemplate(eq(TEMPLATE_ID))) .thenThrow(NoSuchTemplateException.class); DDMTemplate result = resolvers.deleteDDMTemplateDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchTemplateException.class) public void deleteDDMTemplateDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("templateId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); DDMTemplate expectedResult = mock(DDMTemplate.class); expectedResult.setTemplateId(TEMPLATE_ID); useMockGraphQLUtil(environment, USER_ID, false); when(graphQLUtil.getLongArg(eq(environment), eq("templateId"))) .thenReturn(789456L); when(localService.deleteDDMTemplate(eq(789456L))) .thenThrow(NoSuchTemplateException.class); DDMTemplate result = resolvers.deleteDDMTemplateDataFetcher() .get(environment); assertNull(result); }