Attribute { public JsonObject toJsonObject() { JsonObjectBuilder ob = Json.createObjectBuilder(); ob.add("name", name); ob.add("value", value); if (ecert != null) { ob.add("ecert", ecert.booleanValue()); } return ob.build(); } Attribute(String name, String value);  Attribute(String name, String value, Boolean defaultAttribute); String getName(); String getValue(); JsonObject toJsonObject();  }
@Test public void testJsonBuild() { try { Attribute testAttribute = new Attribute(attrName, attrValue); JsonObject attrJson = testAttribute.toJsonObject(); Assert.assertNotNull(attrJson); Assert.assertEquals(attrJson.getString("name"), attrName); Assert.assertEquals(attrJson.getString("value"), attrValue); } catch (Exception e) { Assert.fail("Unexpected Exception " + e.getMessage()); } }