StringObjectFormatter extends ObjectFormatter implements IValueFormatter { @Override public Map<String, Object> getDefaultOptions() { Map<String, Object> options = new HashMap<>(); options.put(MAX_STRING_LENGTH_OPTION, DEFAULT_MAX_STRING_LENGTH); return options; } StringObjectFormatter(); @Override Map<String, Object> getDefaultOptions(); @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 MAX_STRING_LENGTH_OPTION; }
@Test public void testDefaultOptions() { Map<String, Object> options = formatter.getDefaultOptions(); assertNotNull("Default options should never be null.", options); assertEquals("Default options for numeric formatter should have two options.", 1, options.size()); assertTrue("Should contains max string length.", options.containsKey(StringObjectFormatter.MAX_STRING_LENGTH_OPTION)); }