Package javango.forms.fields

Examples of javango.forms.fields.PercentField


import javango.forms.widgets.Widget;

public class PercentFieldTest extends InjectedTestCaseBase {

  public void testRequired() throws Exception {
    PercentField field = injector.getInstance(PercentField.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


    assertTrue(errors.containsKey(field.getName()));
    assertEquals(AbstractField.REQUIRED_ERROR, errors.get(field.getName()));
  }
 
  public void testNotRequired() throws Exception {
    PercentField field = injector.getInstance(PercentField.class);
    field.setName("fieldName");
    field.setRequired(false);
   
    Map<String, String> errors = new HashMap<String, String>();
   
    Double value = field.clean(new String[]{""}, errors);
    assertTrue(errors.isEmpty());
  }
View Full Code Here

    Double value = field.clean(new String[]{""}, errors);
    assertTrue(errors.isEmpty());
  }

  public void testInvalid() throws Exception {
    PercentField field = injector.getInstance(PercentField.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(PercentField.ERROR_NUMBER_NOT_VALID, errors.get("fieldName"));
  }
View Full Code Here

    assertTrue(errors.containsKey("fieldName"));
    assertEquals(PercentField.ERROR_NUMBER_NOT_VALID, errors.get("fieldName"));
  }

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

TOP

Related Classes of javango.forms.fields.PercentField

Copyright © 2018 www.massapicom. 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.