Package org.araneaframework.uilib.form.control

Examples of org.araneaframework.uilib.form.control.TextControl$ViewModel


   */
  public void testPersonalIdControlSimpleValidation() throws Exception {
    MockHttpServletRequest correctValueRequest = new MockHttpServletRequest();
    correctValueRequest.addParameter("myPersonalIdInput", "38304280235");
   
    TextControl pic = new TextControl(TextType.EST_PERSONAL_ID);
    pic._getComponent().init(new MockEnviroment());
    MockUiLibUtil.emulateHandleRequest(pic, "myPersonalIdInput", correctValueRequest);
    pic.convertAndValidate();
   
    assertTrue("Personal id control must be valid.", pic.isValid());
    assertTrue("Personal id control value must be a 'String'.", pic.getRawValue() instanceof String);
    assertTrue("Personal id control value must be '38304280235'.", ((String) pic.getRawValue()).equals("38304280235"));
    
    MockHttpServletRequest incorrectValueRequest = new MockHttpServletRequest();
    incorrectValueRequest.addParameter("myPersonalIdInput", "abcd");
   
    MockUiLibUtil.emulateHandleRequest(pic, "myPersonalIdInput", incorrectValueRequest);
    pic.convertAndValidate();   
   
    assertTrue("Personal id control mustn't be valid.", !pic.isValid());
   
    pic._getComponent().destroy();
  }
View Full Code Here


  public void testTextboxControlMinMaxValidation() throws Exception {
    //Basic
    MockHttpServletRequest correctValueRequest = new MockHttpServletRequest();
    correctValueRequest.addParameter("myTextBox", "i love me");
   
    TextControl tc = new TextControl();
    tc._getComponent().init(new MockEnviroment());
   
    tc.setMinLength(new Long(5));
    tc.setMaxLength(new Long(20));
   
    MockUiLibUtil.emulateHandleRequest(tc, "myTextBox", correctValueRequest);
    tc.convertAndValidate();
   
    assertTrue("Textbox control must be valid.", tc.isValid());   
    assertTrue("Textbox control value must be 'i love me'.", ((String) tc.getRawValue()).equals("i love me"));
    
    //Too short

    MockHttpServletRequest tooShortValueRequest = new MockHttpServletRequest();
    tooShortValueRequest.addParameter("myTextBox", "boo");
   
    MockUiLibUtil.emulateHandleRequest(tc, "myTextBox", tooShortValueRequest);
    tc.convertAndValidate();   
   
    assertTrue("Textbox control mustn't be valid.", !tc.isValid());
   
    //Too long
   
    MockHttpServletRequest tooLongValueRequest = new MockHttpServletRequest();
    tooLongValueRequest.addParameter("myTextBox", "i love myself and others very very much");
   
    MockUiLibUtil.emulateHandleRequest(tc, "myTextBox", tooLongValueRequest);  
    tc.convertAndValidate();   
   
    assertTrue("Textbox control mustn't be valid.", !tc.isValid())
         
    //min=max correct
   
    tc.setMinLength(new Long(10));
    tc.setMaxLength(new Long(10));

    correctValueRequest = new MockHttpServletRequest();
    correctValueRequest.addParameter("myTextBox", "1234567890");
   
    MockUiLibUtil.emulateHandleRequest(tc, "myTextBox", correctValueRequest);
    tc.convertAndValidate();
       
    assertTrue("Textbox control must be valid.", tc.isValid());   
    assertTrue("Textbox control value must be '1234567890'.", ((String) tc.getRawValue()).equals("1234567890"));
   
    //min=max too short

    tooShortValueRequest.addParameter("myTextBox", "123456789");
   
    MockUiLibUtil.emulateHandleRequest(tc, "myTextBox", tooShortValueRequest);
    tc.convertAndValidate();
       
    assertTrue("Textbox control mustn't be valid.", !tc.isValid());   
   
    //min=max too long

    tooShortValueRequest.addParameter("myTextBox", "12345678901");
   
    MockUiLibUtil.emulateHandleRequest(tc, "myTextBox", tooShortValueRequest);  
    tc.convertAndValidate();
       
    assertTrue("Textbox control mustn't be valid.", !tc.isValid())
   
    tc._getComponent().destroy();
 
View Full Code Here

    FormWidget testForm = new FormWidget();
    testForm._getComponent().init(new MockEnviroment());
   
    //Adding elements to form
    testForm.addElement("myCheckBox", "my checkbox", new CheckboxControl(), new BooleanData(), true);
    testForm.addElement("myLongText", "my long text", new TextControl(), new LongData(), true);
    testForm.addElement("myDateTime", "my date and time", new DateTimeControl(), new DateData(), false);
    testForm.addElement("myButton", "my button", new ButtonControl(), null, false);

    //Adding a composite element
    FormWidget hierarchyTest = testForm.addSubForm("hierarchyTest");
View Full Code Here

TOP

Related Classes of org.araneaframework.uilib.form.control.TextControl$ViewModel

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.