StringConstructorProducer extends BaseTypeProducer { @Override protected Object createValue(String value) throws Exception { if (value == null) { return null; } return constructor.newInstance(value); } StringConstructorProducer(Constructor<?> constructor);   }
@Test public void createsInstanceAndUsesSingleValueFromMap() throws Exception { MultivaluedMap<String, String> values = new MultivaluedMapImpl(); values.putSingle("number", "2147483647"); Object result = producer.createValue("number", values, null); assertEquals(new Integer("2147483647"), result); }
@Test public void createsInstanceAndUsesFirstValueFromMap() throws Exception { MultivaluedMap<String, String> values = new MultivaluedMapImpl(); values.addAll("number", "2147483647", "746384741"); Object result = producer.createValue("number", values, null); assertEquals(new Integer("2147483647"), result); }
@Test public void createsInstanceAndUsesDefault() throws Exception { MultivaluedMap<String, String> values = new MultivaluedMapImpl(); Object result = producer.createValue("number", values, "-777"); assertEquals(new Integer("-777"), result); }
@Test public void returnsNullWhenMapDoesNotContainRequiredValueAndDefaultValueIsNull() throws Exception { MultivaluedMap<String, String> values = new MultivaluedMapImpl(); Object result = producer.createValue("number", values, null); assertNull(result); }