ObjectFormatter implements IValueFormatter { @Override public Value valueOf(String value, Type type, Map<String, Object> options) { if (value == null || NullObjectFormatter.NULL_STRING.equals(value)) { return null; } throw new UnsupportedOperationException(String.format("Set value is not supported yet for type %s.", type.name())); } ObjectFormatter(BiFunction<Type, Map<String, Object>, String> typeToStringFunction); @Override String toString(Object obj, Map<String, Object> options); @Override boolean acceptType(Type type, Map<String, Object> options); @Override Value valueOf(String value, Type type, Map<String, Object> options);  }
@Test public void testValueOfNull() throws Exception { ObjectReference or = this.getObjectReference("Foo"); assertNull("Should return null for evaluating \"null\".", formatter.valueOf("null", or.referenceType(), new HashMap<>())); assertNull("Should return null for evaluating null.", formatter.valueOf(null, or.referenceType(), new HashMap<>())); }
@Test(expected = UnsupportedOperationException.class) public void testValueOfNotUnsupported() { ObjectReference or = this.getObjectReference("Foo"); formatter.valueOf("new Foo()", or.referenceType(), new HashMap<>()); fail("Set value for object is not supported."); }