JsonHandler extends HandlerBase { protected JsonObjectBuilder showScalarProperty(Property property) { JsonObjectBuilder propBuilder = Json.createObjectBuilder(); PropertyType propType = property.getType(); switch (propType) { case BOOLEAN: Boolean b = (Boolean) property.getValue(); propBuilder.add(property.getName(), b.booleanValue()); break; case BYTE: case CHARACTER: case OBJECT: propBuilder.add(property.getName(), property.getValue().toString()); break; case DATE: Date dt = (Date) property.getValue(); propBuilder.add(property.getName(), toDateTime(dt)); break; case DOUBLE: Double d = (Double) property.getValue(); propBuilder.add(property.getName(), d.doubleValue()); break; case FLOAT: Float f = (Float) property.getValue(); propBuilder.add(property.getName(), f.floatValue()); break; case INTEGER: Integer i = (Integer) property.getValue(); propBuilder.add(property.getName(), i.intValue()); break; case LONG: Long l = (Long) property.getValue(); propBuilder.add(property.getName(), l.longValue()); break; case AESAUDIOMETADATA: propBuilder.add(property.getName(), showAESAudioMetadata((AESAudioMetadata) property.getValue())); break; case NISOIMAGEMETADATA: propBuilder.add(property.getName(), showNisoImageMetadata((NisoImageMetadata) property.getValue())); break; case TEXTMDMETADATA: propBuilder.add(property.getName(), showTextMDMetadata((TextMDMetadata) property.getValue())); break; case SHORT: Short s = (Short) property.getValue(); propBuilder.add(property.getName(), s.shortValue()); break; case STRING: propBuilder.add(property.getName(), (String) property.getValue()); break; case RATIONAL: propBuilder.add(property.getName(), showRational((Rational) property.getValue())); break; case PROPERTY: Property property2 = (Property) property.getValue(); propBuilder.add(property.getName(), showProperty(property2)); break; default: propBuilder.add(property.getName(), property.getValue().toString()); break; } return propBuilder; } JsonHandler();  JsonHandler(String name, String release, int[] date, String note, String rights); @Override void show(); @Override void show(App app); @Override void show(OutputHandler handler); @Override void show(Module module); @Override void show(RepInfo info); @Override void showFooter(); @Override void showHeader();  }
@Test public void testShowScalarProperty() throws IOException { final Property prop = new Property("test", PropertyType.INTEGER, PropertyArity.SCALAR, 2); JsonObjectBuilder b = this.handler.showScalarProperty(prop); buildJson(b); handler.close(); String result = outString.toString(); LOGGER.info(FIND + result); final String expected = "{\"test\":2}"; assertEquals(expected, result); }