ARP implements Serializable { public static ARP fromRestResponse(Map response) { ARP arp = new ARP(); arp.setNoArp(false); arp.setNoAttrArp(false); if (response.isEmpty()) { arp.setNoArp(true); return arp; } arp.setName((String) response.get("name")); arp.setDescription((String) response.get("description")); final Object attr = response.get("attributes"); if (attr instanceof Map) { arp.setAttributes((Map<String, List<Object>>) attr); } else { arp.setNoAttrArp(true); } return arp; }  String getName(); void setName(String name); String getDescription(); void setDescription(String description); Map<String, List<Object>> getAttributes(); void setAttributes(Map<String, List<Object>> attributes); static ARP fromRestResponse(Map response); @Override String toString(); boolean isNoArp(); boolean isNoAttrArp(); void setNoArp(boolean noArp); void setNoAttrArp(boolean noAttrArp);  }
@Test public void testFromRestResponse() throws Exception { String all = "*"; List<Object> attributeValues = new ArrayList<Object>(); attributeValues.add(all); Map<String, List<Object>> attributes = new LinkedHashMap<String, List<Object>>(); attributes.put("uuid", attributeValues); attributes.put("displayName", attributeValues); attributes.put("email", attributeValues); Map<String, Object> restResponse = new LinkedHashMap<String, Object>(); final String name = "ARP_123"; restResponse.put("name", name); final String description = "Attribute release policy 123"; restResponse.put("description", description); restResponse.put("attributes", attributes); ARP arp = ARP.fromRestResponse(restResponse); assertEquals(name, arp.getName()); assertEquals(description, arp.getDescription()); assertEquals(3, arp.getAttributes().size()); assertFalse(arp.isNoArp()); assertFalse(arp.isNoAttrArp()); }