CountrySearchKeywords { public JSONObject toJSONObject(Locale locale) { return JSONUtil.put( "countryCode", _countryCode ).put( "countryName", _getCountryName(_countryCode, locale) ).put( "keywords", _getSearchKeywordsJSONArray() ); } CountrySearchKeywords();  CountrySearchKeywords(
		String countryCode, List<SearchKeyword> searchKeywords); @Override boolean equals(Object object); String getCountryCode(); @JsonProperty("keywords") List<SearchKeyword> getSearchKeywords(); @Override int hashCode(); void setCountryCode(String countryCode); void setSearchKeywords(List<SearchKeyword> searchKeywords); JSONObject toJSONObject(Locale locale);  }
@Test public void testToJSONObject() { CountrySearchKeywords countrySearchKeywords = new CountrySearchKeywords( "us", null); Assert.assertEquals( String.valueOf( JSONUtil.put( "countryCode", "us" ).put( "countryName", "United States" ).put( "keywords", JSONFactoryUtil.createJSONArray() )), String.valueOf(countrySearchKeywords.toJSONObject(LocaleUtil.US))); }
@Test public void testToJSONObjectWithSearchKeywords() { CountrySearchKeywords countrySearchKeywords = new CountrySearchKeywords( "us", Arrays.asList( new SearchKeyword("liferay", 1, 3600, 2882L), new SearchKeyword("liferay inc", 1, 755, 855L), new SearchKeyword("liferay portal", 1, 556, 850L), new SearchKeyword("what is liferay", 1, 390, 312L), new SearchKeyword("liferay india", 1, 390, 312L), new SearchKeyword( "liferay development services", 1, 390, 310L))); Assert.assertEquals( String.valueOf( JSONUtil.put( "countryCode", "us" ).put( "countryName", "United States" ).put( "keywords", JSONUtil.putAll( JSONUtil.put( "keyword", "liferay" ).put( "position", 1 ).put( "searchVolume", 3600 ).put( "traffic", 2882 ), JSONUtil.put( "keyword", "liferay inc" ).put( "position", 1 ).put( "searchVolume", 755 ).put( "traffic", 855 ), JSONUtil.put( "keyword", "liferay portal" ).put( "position", 1 ).put( "searchVolume", 556 ).put( "traffic", 850 ), JSONUtil.put( "keyword", "what is liferay" ).put( "position", 1 ).put( "searchVolume", 390 ).put( "traffic", 312 ), JSONUtil.put( "keyword", "liferay india" ).put( "position", 1 ).put( "searchVolume", 390 ).put( "traffic", 312 )) )), String.valueOf(countrySearchKeywords.toJSONObject(LocaleUtil.US))); }