NullObjectFormatter implements IValueFormatter { @Override public Value valueOf(String value, Type type, Map<String, Object> options) { if (value == null || NULL_STRING.equals(value)) { return null; } throw new UnsupportedOperationException("Set value is not supported by NullObjectFormatter."); }  @Override String toString(Object value, Map<String, Object> options); @Override boolean acceptType(Type type, Map<String, Object> options); @Override Value valueOf(String value, Type type, Map<String, Object> options); static final String NULL_STRING; }
@Test public void testValueOf() throws Exception { Map<String, Object> options = formatter.getDefaultOptions(); assertNull("Should return null for null formatter", formatter.valueOf("null", null, options)); assertNull("Should return null for null formatter", formatter.valueOf(null, null, options)); }
@Test(expected = UnsupportedOperationException.class) public void testValueOfNotSupported() { ObjectReference or = this.getObjectReference("Foo"); formatter.valueOf("new Foo()", or.referenceType(), new HashMap<>()); }