SecurityGroup { @SuppressWarnings("unchecked") public void fromJson(JSONObject jsonNode) { name = jsonNode.getString("name"); description = jsonNode.getString("description"); idSecurityGroup = jsonNode.getString("id"); JSONArray rulesjsonArray = jsonNode.getJSONArray("rules"); List<Rule> rules = new ArrayList<Rule>(); for (int i = 0; i < rulesjsonArray.size(); i++) { JSONObject object = rulesjsonArray.getJSONObject(i); Rule rule = new Rule(); rule.fromJson(object); rules.add(rule); } setRules(rules); } SecurityGroup();  SecurityGroup(String name, String description); void addRule(Rule rule); void deleteRule(Rule rule); @SuppressWarnings("unchecked") void fromJson(JSONObject jsonNode); String getDescription(); String getIdSecurityGroup(); String getName(); List<Rule> getRules(); void setDescription(String description); void setIdSecurityGroup(String idSecurityGroup); void setName(String name); void setRules(List<Rule> rules); Long getId(); List<Rule> cloneRules(); String toJSON(); String toString();  }
@Test public void testFromJson() throws Exception { securityGroup.fromJson(secGroupJson); assertEquals(securityGroup.getDescription(), "default"); assertEquals(securityGroup.getIdSecurityGroup(), "6"); assertEquals(securityGroup.getName(), "namedefault"); assertEquals(securityGroup.getRules().size(), 2); }