SearchKeyword { public JSONObject toJSONObject() { return JSONUtil.put( "keyword", getKeyword() ).put( "position", getPosition() ).put( "searchVolume", getSearchVolume() ).put( "traffic", Math.toIntExact(getTraffic()) ); } SearchKeyword();  SearchKeyword(
		String keyword, int position, int searchVolume, long traffic); @Override boolean equals(Object object); String getKeyword(); int getPosition(); int getSearchVolume(); long getTraffic(); @Override int hashCode(); void setKeyword(String keyword); void setPosition(int position); void setSearchVolume(int searchVolume); void setTraffic(long traffic); JSONObject toJSONObject();  }
@Test public void testToJSONObject() { SearchKeyword searchKeyword = new SearchKeyword( RandomTestUtil.randomString(), RandomTestUtil.randomInt(), RandomTestUtil.randomInt(), RandomTestUtil.randomInt()); Assert.assertEquals( JSONUtil.put( "keyword", searchKeyword.getKeyword() ).put( "position", searchKeyword.getPosition() ).put( "searchVolume", searchKeyword.getSearchVolume() ).put( "traffic", Math.toIntExact(searchKeyword.getTraffic()) ).toString(), String.valueOf(searchKeyword.toJSONObject())); }
@Test(expected = ArithmeticException.class) public void testToJSONObjectWithLongTraffic() { SearchKeyword searchKeyword = new SearchKeyword( RandomTestUtil.randomString(), RandomTestUtil.randomInt(), RandomTestUtil.randomInt(), Long.MAX_VALUE); searchKeyword.toJSONObject(); }