### Question:
CompanyResolversImpl implements CompanyResolvers { @Override public DataFetcher<Company> deleteCompanyDataFetcher() { return environment -> { long companyId = util.getLongArg(environment, "companyId"); return companyLocalService.deleteCompany(companyId); }; }  @Reference(unbind = "-") void setCompanyLocalService(CompanyLocalService companyLocalService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<Company>> getCompaniesDataFetcher(); @Override DataFetcher<CompletableFuture<Company>> getCompanyDataFetcher(); @Override DataFetcher<Company> getCompanyByWebIdDataFetcher(); @Override DataFetcher<Company> createCompanyDataFetcher(); @Override DataFetcher<Company> updateCompanyDataFetcher(); @Override DataFetcher<Company> deleteCompanyDataFetcher();  }### Answer:
@Test public void deleteCompanyDataFetcher_should_return_deleted_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("companyId", COMPANY_ID); DataFetchingEnvironment environment = getTestEnvironment(arguments); Company expectedResult = mock(Company.class); expectedResult.setCompanyId(COMPANY_ID); useMockGraphQLUtil(environment, true); when(localService.deleteCompany(eq(COMPANY_ID))) .thenReturn(expectedResult); Company result = resolvers.deleteCompanyDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = NoSuchCompanyException.class) public void deleteCompanyDataFetcher_without_args_should_return_null_with_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); Company expectedResult = mock(Company.class); expectedResult.setCompanyId(COMPANY_ID); useMockGraphQLUtil(environment, true); when(localService.deleteCompany(eq(COMPANY_ID))) .thenThrow(NoSuchCompanyException.class); Company result = resolvers.deleteCompanyDataFetcher() .get(environment); assertNull(result); }
@Test(expected = NoSuchCompanyException.class) public void deleteCompanyDataFetcher_with_invalid_id_should_return_null_with_exception() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("companyId", 789456L); DataFetchingEnvironment environment = getTestEnvironment(arguments); Company expectedResult = mock(Company.class); expectedResult.setCompanyId(COMPANY_ID); useMockGraphQLUtil(environment, false); when(graphQLUtil.getLongArg(eq(environment), eq("companyId"))) .thenReturn(789456L); when(localService.deleteCompany(eq(789456L))) .thenThrow(NoSuchCompanyException.class); Company result = resolvers.deleteCompanyDataFetcher() .get(environment); assertNull(result); }