Package org.araneaframework.uilib.form

Examples of org.araneaframework.uilib.form.FormWidget


  /**
   * Testing reading from invalid request.
   */
  public void testFormInvalidRequestReading() throws Exception {
    FormWidget testForm = makeUsualForm();

    MockHttpServletRequest invalidRequest = new MockHttpServletRequest();

    invalidRequest.addParameter("testForm.__present", "true");
    invalidRequest.addParameter("testForm.myCheckBox", "ksjf");
    invalidRequest.addParameter("testForm.myDateTime.date", "HA-HA");
    invalidRequest.addParameter("testForm.myDateTime.time", "BLAH");
    invalidRequest.addParameter("testForm.hierarchyTest.myTextarea", "");   

    //Testing that invalid requests are read right
    StandardServletInputData input = new StandardServletInputData(invalidRequest);
    input.pushScope("testForm");
    testForm._getWidget().update(input);
   
    assertTrue("Test form must not be valid after reading from request", !testForm.convertAndValidate());
  }
View Full Code Here


  /**
   * Testing reading from request with a mandatory element missing.
   */
  public void testFormMandatoryMissingRequestReading() throws Exception {

    FormWidget testForm = makeUsualForm();

    MockHttpServletRequest mandatoryMissingRequest = new MockHttpServletRequest();

    mandatoryMissingRequest.addParameter("testForm.__present", "true");
    mandatoryMissingRequest.addParameter("testForm.myCheckBox", "true");
    mandatoryMissingRequest.addParameter("testForm.myLongText", "108");
    mandatoryMissingRequest.addParameter("testForm.myDateTime.date", "11.10.2015");
    mandatoryMissingRequest.addParameter("testForm.myDateTime.time", "01:01");
    mandatoryMissingRequest.addParameter("testForm.hierarchyTest.mySelect", "2");

    //Testing that mandatory items are processed right
    StandardServletInputData input = new StandardServletInputData(mandatoryMissingRequest);
    input.pushScope("testForm");
    testForm._getWidget().update(input);
   
    assertTrue("Test form must not be valid after reading from request", !testForm.convertAndValidate());
  }
View Full Code Here

  /**
   * Testing reading from request with a not mandatory element missing.
   */
  public void testFormNotMandatoryMissingRequestReading() throws Exception {

    FormWidget testForm = makeUsualForm();

    MockHttpServletRequest notMandatoryMissingRequest = new MockHttpServletRequest();

    notMandatoryMissingRequest.addParameter("testForm.__present", "true");
    notMandatoryMissingRequest.addParameter("testForm.myCheckBox", (String) null);
    notMandatoryMissingRequest.addParameter("testForm.myLongText", "108");
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.myTextarea", "blah");
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.mySelect", "2");

    StandardServletInputData input = new StandardServletInputData(notMandatoryMissingRequest);
    input.pushScope("testForm");
    testForm._getWidget().update(input);
   
    assertTrue("Test form must be valid after reading from request", testForm.convertAndValidate());
  }
View Full Code Here

/**
   * Testing reading from request with a grouped constraint set.
   */
  public void testFormActiveGroupedConstraintInvalidates() throws Exception {

    FormWidget testForm = makeUsualForm();

    MockHttpServletRequest notMandatoryMissingRequest = new MockHttpServletRequest();

    notMandatoryMissingRequest.addParameter("testForm.__present", "true");
    notMandatoryMissingRequest.addParameter("testForm.myCheckBox", "true");
    notMandatoryMissingRequest.addParameter("testForm.myLongText", "108");
    notMandatoryMissingRequest.addParameter("testForm.myDateTime", (String) null);
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.myTextarea", "blah");
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.mySelect", "2");

    // create helper
    ConstraintGroupHelper groupHelper = new ConstraintGroupHelper();
    testForm.getElement("myDateTime").setConstraint(
        groupHelper.createGroupedConstraint(new NotEmptyConstraint(), "active"));

    StandardServletInputData input = new StandardServletInputData(notMandatoryMissingRequest);
    input.pushScope("testForm");
    testForm._getWidget().update(input);

    groupHelper.setActiveGroup("active");

    assertTrue("Test form must not be valid after reading from request", !testForm.convertAndValidate());       
  }
View Full Code Here

  /**
   * Testing reading from request with a grouped constraint set.
   */
  public void testFormActiveGroupedConstraintValidates() throws Exception {

    FormWidget testForm = makeUsualForm();

    MockHttpServletRequest notMandatoryMissingRequest = new MockHttpServletRequest();

    notMandatoryMissingRequest.addParameter("testForm.__present", "true");
    notMandatoryMissingRequest.addParameter("testForm.myCheckBox", "true");
    notMandatoryMissingRequest.addParameter("testForm.myLongText", "108");   
    notMandatoryMissingRequest.addParameter("testForm.myDateTime.date", "11.10.2015");
    notMandatoryMissingRequest.addParameter("testForm.myDateTime.time", "01:01")
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.myTextarea", "blah");
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.mySelect", "2");

    // create helper
    ConstraintGroupHelper groupHelper = new ConstraintGroupHelper();   
    testForm.getElement("myDateTime").setConstraint(groupHelper.createGroupedConstraint(new NotEmptyConstraint(), "active"));
   
    StandardServletInputData input = new StandardServletInputData(notMandatoryMissingRequest);
    input.pushScope("testForm");
    testForm._getWidget().update(input);
   
    groupHelper.setActiveGroup("active");
    assertTrue("Test form must be valid after reading from request", testForm.convertAndValidate());      
  }
View Full Code Here

  /**
   * Testing reading from request with a grouped constraint set.
   */
  public void testFormInactiveGroupedConstraintValidates() throws Exception {

    FormWidget testForm = makeUsualForm();

    MockHttpServletRequest notMandatoryMissingRequest = new MockHttpServletRequest();

    notMandatoryMissingRequest.addParameter("testForm.__present", "true");
    notMandatoryMissingRequest.addParameter("testForm.myCheckBox", "true");
    notMandatoryMissingRequest.addParameter("testForm.myLongText", "108");   
    notMandatoryMissingRequest.addParameter("testForm.myDateTime.date", "11.10.2015");
    notMandatoryMissingRequest.addParameter("testForm.myDateTime.time", "01:01")
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.myTextarea", "blah");
    notMandatoryMissingRequest.addParameter("testForm.hierarchyTest.mySelect", "2");

    // create helper
    ConstraintGroupHelper groupHelper = new ConstraintGroupHelper();   
    testForm.getElement("myDateTime").setConstraint(groupHelper.createGroupedConstraint(new NotEmptyConstraint(), "active"));
   
    StandardServletInputData input = new StandardServletInputData(notMandatoryMissingRequest);
    input.pushScope("testForm");
    testForm._getWidget().update(input);
   
    assertTrue("Test form must be valid after reading from request", testForm.convertAndValidate());      
  }
View Full Code Here

  /**
   * Testing events.
   */
  public void testFormEventProcessing() throws Exception {

    FormWidget testForm = makeUsualForm();

    //Simple event
     ((ButtonControl) ((FormElement) testForm.getElement("myButton")).getControl()).addOnClickEventListener(new TestOnClickEventHandler());
    
    testForm._getWidget().event(new StandardPath("myButton.onClicked"), new MockInputData());
   
    assertTrue("Event succeeded", eventsWork);
  }
View Full Code Here

  /**
   * Tests helper functions that access form parts by their full name.
   */
  public void testFormTraversal() throws Exception {
    FormWidget form = makeUsualForm();

    assertTrue("'myCheckBox' must contain a CheckboxControl!", form.getControlByFullName("myCheckBox") instanceof CheckboxControl);
    assertTrue("'hierarchyTest.myTextarea' must contain a TextareaControl!", form.getControlByFullName("hierarchyTest.myTextarea") instanceof TextareaControl);
   
    Control result = form.getControlByFullName("hierarchyTestm.yTextarea");
   
    assertTrue("An exception must be thrown if wrong element name is given!", result == null);
  }
View Full Code Here

  }

  private FormWidget makeUsualForm() throws Exception {

    //Creating form :-)
    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(), false);
    testForm.addElement("myDateTime", "my date and time", new DateTimeControl(), new DateData(), false);
    testForm.addElement("myButton", "my button", new ButtonControl(), null, false);

    return testForm;
  }
View Full Code Here

  /**
   * Testing reading from request with a primitive constraint set.
   */
  public void testFormPrimitiveConstraint() throws Exception {

    FormWidget testForm = makeUsualForm();

    MockHttpServletRequest request = new MockHttpServletRequest();

    request.addParameter("testForm.__present", "true");
    request.addParameter("testForm.myCheckBox", "true");
    request.addParameter("testForm.myLongText", "108");
  request.addParameter("testForm.myDateTime", (String) null);

    //Testing primitive constraint
    testForm.getElement("myDateTime").setConstraint(new NotEmptyConstraint());
   
    StandardServletInputData input = new StandardServletInputData(request);
    input.pushScope("testForm");
    testForm._getWidget().update(input);
    assertTrue("Test form must not be valid after reading from request", !testForm.convertAndValidate());
  }
View Full Code Here

TOP

Related Classes of org.araneaframework.uilib.form.FormWidget

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.