### Question:
CountryResolversImpl implements CountryResolvers { @Override public DataFetcher<Country> createCountryDataFetcher() { return environment -> { String name = util.getStringArg(environment, "name"); String a2 = util.getStringArg(environment, "a2"); String a3 = util.getStringArg(environment, "a3"); String number = util.getStringArg(environment, "number"); String idd = util.getStringArg(environment, "idd"); boolean active = util.getBooleanArg(environment, "active"); return countryService.addCountry( name, a2, a3, number, idd, active); }; }  @Reference(unbind = "-") void setCountryService(CountryService countryService); @Reference void setUtil(GraphQLUtil util); @Override DataFetcher<List<Country>> getCountriesDataFetcher(); @Override DataFetcher<Country> getCountryDataFetcher(); @Override DataFetcher<Country> getCountryByA2DataFetcher(); @Override DataFetcher<Country> getCountryByA3DataFetcher(); @Override DataFetcher<Country> getCountryByNameDataFetcher(); @Override DataFetcher<Country> createCountryDataFetcher();  }### Answer:
@Test public void createCountryDataFetcher_should_return_new_object() throws Exception { Map<String, Object> arguments = new HashMap<>(); arguments.put("name", NAME); arguments.put("a2", A2); arguments.put("a3", A3); arguments.put("number", NUMBER); arguments.put("idd", IDD); arguments.put("active", ACTIVE); DataFetchingEnvironment environment = getTestEnvironment(arguments); Country expectedResult = mock(Country.class); expectedResult.setCountryId(COUNTRY_ID); expectedResult.setName(NAME); expectedResult.setA2(A2); expectedResult.setA3(A3); expectedResult.setNumber(NUMBER); expectedResult.setIdd(IDD); expectedResult.setActive(ACTIVE); useMockGraphQLUtil(environment, true); when(localService.addCountry(eq(NAME), eq(A2), eq(A3), eq(NUMBER), eq(IDD), eq(ACTIVE))) .thenReturn(expectedResult); Country result = resolvers.createCountryDataFetcher() .get(environment); assertNotNull(result); assertEquals(expectedResult, result); }
@Test(expected = PortalException.class) public void createCountryDataFetcher_without_args_should_throw_validation_exception() throws Exception { DataFetchingEnvironment environment = getTestEnvironment(null); useMockGraphQLUtil(environment, false); when(localService.addCountry(anyString(), anyString(), anyString(), anyString(), anyString(), anyBoolean())) .thenThrow(PortalException.class); Country result = resolvers.createCountryDataFetcher() .get(environment); assertNull(result); }