Package javango.forms.fields

Examples of javango.forms.fields.DoubleField.clean()


    DoubleField field = injector.getInstance(DoubleField.class);
    field.setName("fieldName");

    Map<String, String> errors = new HashMap<String, String>();
   
    Double value = field.clean(new String[]{""}, errors);
    assertFalse(errors.isEmpty());
    assertTrue(errors.containsKey(field.getName()));
    assertEquals(AbstractField.REQUIRED_ERROR, errors.get(field.getName()));
  }
 
View Full Code Here


    field.setName("fieldName");
    field.setRequired(false);
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Double value = field.clean(new String[]{""}, errors);
    assertTrue(errors.isEmpty());
  }

  public void testInvalid() throws Exception {
    DoubleField field = injector.getInstance(DoubleField.class);
View Full Code Here

    DoubleField field = injector.getInstance(DoubleField.class);
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Double value = field.clean(new String[]{"qwert"}, errors);
    assertFalse(errors.isEmpty());
    assertTrue(errors.containsKey("fieldName"));
    assertEquals(DoubleField.ERROR_NUMBER_NOT_VALID, errors.get("fieldName"));
  }
View Full Code Here

    DoubleField field = injector.getInstance(DoubleField.class);
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Double value = field.clean(new String[]{"1234.56"}, errors);
    assertTrue(errors.isEmpty());
    assertEquals(new Double(1234.56), value);
  }

  public void testDecimalPlaces() throws Exception {
View Full Code Here

    field.setDecimalPlaces(2);
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Double value = field.clean(new String[]{"1234.56"}, errors);
    assertTrue(errors.isEmpty());
  }

  public void testTooFewDecimalPlaces() throws Exception {
    DoubleField field = injector.getInstance(DoubleField.class);
View Full Code Here

    field.setDecimalPlaces(2);
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Double value = field.clean(new String[]{"1234.5"}, errors);
    assertTrue(errors.isEmpty());
  }
 
  public void testTooManyDecimalPlaces() throws Exception {
    DoubleField field = injector.getInstance(DoubleField.class);
View Full Code Here

    field.setDecimalPlaces(2);
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Double value = field.clean(new String[]{"1234.567"}, errors);
    assertFalse(errors.isEmpty());
    assertEquals(String.format(DoubleField.ERROR_MAX_DECIMAL_PLACES, 2), errors.get("fieldName"));
  }

  public void testNoDecimalEntered() throws Exception {
View Full Code Here

    field.setDecimalPlaces(2);
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Double value = field.clean(new String[]{"1234"}, errors);
    assertTrue(errors.isEmpty());
    assertEquals(new Double(1234), value)}
 
  public void testAnyDecimalPlaces() throws Exception {
    DoubleField field = injector.getInstance(DoubleField.class);
View Full Code Here

    DoubleField field = injector.getInstance(DoubleField.class);
    field.setName("fieldName");
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Double value = field.clean(new String[]{"1234.567"}, errors);
    assertTrue(errors.isEmpty());
    assertEquals(new Double(1234.567), value);
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.