### Question:
CompanyResolversImpl implements CompanyResolvers { @Override public DataFetcher<Company> createCompanyDataFetcher() { return environment -> { String webId = util.getStringArg(environment, "webId"); String virtualHostname = util.getStringArg(environment, "virtualHostname"); String mx = util.getStringArg(environment, "mx"); boolean system = util.getBooleanArg(environment, "system"); int maxUsers = util.getIntArg(environment, "maxUsers"); boolean active = util.getBooleanArg(environment, "active", true); return companyLocalService.addCompany( webId, virtualHostname, mx, system, maxUsers, active); }; }  @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 createCompanyDataFetcher_should_return_new_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("webId", WEB_ID); arguments.put("virtualHostname", VIRTUAL_HOSTNAME); arguments.put("mx", MX); arguments.put("system", SYSTEM); arguments.put("maxUsers", MAX_USERS); arguments.put("active", ACTIVE); DataFetchingEnvironment environment = getTestEnvironment(arguments); Company expectedResult = mock(Company.class); expectedResult.setCompanyId(COMPANY_ID); expectedResult.setWebId(WEB_ID); expectedResult.setVirtualHostname(VIRTUAL_HOSTNAME); expectedResult.setMx(MX); expectedResult.setSystem(SYSTEM); expectedResult.setMaxUsers(MAX_USERS); expectedResult.setActive(ACTIVE); useMockGraphQLUtil(environment, true); when(localService.addCompany(eq(WEB_ID), eq(VIRTUAL_HOSTNAME), eq(MX), eq(SYSTEM), eq(MAX_USERS), eq(ACTIVE))) .thenReturn(expectedResult); Company result = resolvers.createCompanyDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = PortalException.class) public void createCompanyDataFetcher_without_args_should_throw_validation_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); useMockGraphQLUtil(environment, false); when(localService.addCompany(anyString(), anyString(), anyString(), anyBoolean(), anyInt(), anyBoolean())) .thenThrow(PortalException.class); Company result = resolvers.createCompanyDataFetcher() .get(environment); assertNull(result); }