Package org.apache.turbine.services.intake.model

Examples of org.apache.turbine.services.intake.model.Field


            FieldReference ref = (FieldReference)i.next();
            boolean comp_true = true;

            try
            {
                Field refField = group.get(ref.getFieldName());
               
                if (refField.isSet())
                {
                    /*
                     * Fields are processed in sequence so that our
                     * reference field might have been set but not
                     * yet validated. We check this here.
                     */
                    if (!refField.isValidated())
                    {
                        refField.validate();
                    }
                   
                    if (refField.isValid())
                    {
                        try
                        {
                            comp_true = compareCallback.compareValues(ref.getCompare(),
                                    value,
                                    refField.getValue());
                        }
                        catch (ClassCastException e)
                        {
                            throw new IntakeException("Type mismatch comparing " +
                                    value + " with " + refField.getValue(), e);
                        }
                    }
                }
            }
            catch (IntakeException e)
View Full Code Here


        requiredTrueTestGroup = intakeService.getGroup("RequiredTrueTest");
    }

    public void testEmptyBooleanField() throws IntakeException
    {
        Field booleanField = booleanTestGroup.get("EmptyBooleanTestField");
        assertTrue("The Default Validator of an intake Field type boolean should be BooleanValidator", (booleanField.getValidator() instanceof BooleanValidator));
        assertFalse("An Empty intake Field type boolean should not be required", booleanField.isRequired());
    }
View Full Code Here

        assertFalse("An Empty intake Field type boolean should not be required", booleanField.isRequired());
    }

    public void testBooleanField() throws IntakeException
    {
        Field booleanField = booleanTestGroup.get("BooleanTestField");
        assertTrue("The Default Validator of an intake Field type boolean should be BooleanValidator", (booleanField.getValidator() instanceof BooleanValidator));
        assertFalse("An intake Field type boolean, which is not required, should not be required", booleanField.isRequired());
    }
View Full Code Here

        assertFalse("An intake Field type boolean, which is not required, should not be required", booleanField.isRequired());
    }

    public void testRequiredBooleanField() throws IntakeException
    {
        Field booleanField = booleanTestGroup.get("RequiredBooleanTestField");
        assertTrue("The Default Validator of an intake Field type boolean should be BooleanValidator", (booleanField.getValidator() instanceof BooleanValidator));
        assertTrue("An intake Field type boolean, which is required, should be required", booleanField.isRequired());
    }
View Full Code Here

        pp.add("rt_0dmin", "05/11/2007");
        pp.add("rt_0dmax", "05/12/2007");
        pp.add("rt_0dmax2", "05/11/2007");
        rangeTestGroup.init(Group.NEW, pp);

        Field dmax = rangeTestGroup.get("DateMax");
        Field dmax2 = rangeTestGroup.get("DateMax2");

        assertTrue("The Validator of the field DateMax should be a DateRangeValidator", (dmax.getValidator() instanceof DateRangeValidator));
        assertTrue("The date range should be valid", dmax.isValid());
        assertFalse("The date range should not be valid", dmax2.isValid());
    }
View Full Code Here

        pp.add("irt_0imin", "1");
        pp.add("irt_0imax", "3");
        pp.add("irt_0imax2", "2");
        integerRangeTestGroup.init(Group.NEW, pp);

        Field imax = integerRangeTestGroup.get("IntMax");
        Field imax2 = integerRangeTestGroup.get("IntMax2");

        assertTrue("The Validator of the field IntMax should be an IntegerRangeValidator", (imax.getValidator() instanceof IntegerRangeValidator));
        assertTrue("The integer range should be valid", imax.isValid());
        assertFalse("The integer range should not be valid", imax2.isValid());
    }
View Full Code Here

        pp.add("rft_0integerrf", "");
        pp.add("rft_0intrf", "");
        pp.add("rft_0daterf", "");
        requiredFalseTestGroup.init(Group.NEW, pp);

        Field stringRF = requiredFalseTestGroup.get("StringRF");
        Field integerRF = requiredFalseTestGroup.get("IntegerRF");
        Field intRF = requiredFalseTestGroup.get("IntRF");
        Field dateRF = requiredFalseTestGroup.get("DateRF");

        assertTrue("StringRF should be set", stringRF.isSet());
        assertTrue("StringRF should be valid", stringRF.isValid());
        assertNull(stringRF.getValue());
        assertTrue("IntegerRF should be set", integerRF.isSet());
        assertTrue("IntegerRF should be valid", integerRF.isValid());
        assertNull(integerRF.getValue());
        assertTrue("IntRF should be set", intRF.isSet());
        assertTrue("IntRF should be valid", intRF.isValid());
        assertNull(intRF.getValue()); // zero?
        assertTrue("DateRF should be set", dateRF.isSet());
        assertTrue("DateRF should be valid", dateRF.isValid());
        assertNull(dateRF.getValue());
    }
View Full Code Here

        pp.add("rft_0integerrf", new Integer(10));
        pp.add("rft_0intrf", 11);
        pp.add("rft_0daterf", testDateString);
        requiredFalseTestGroup.init(Group.NEW, pp);

        Field stringRF = requiredFalseTestGroup.get("StringRF");
        Field integerRF = requiredFalseTestGroup.get("IntegerRF");
        Field intRF = requiredFalseTestGroup.get("IntRF");
        Field dateRF = requiredFalseTestGroup.get("DateRF");

        assertTrue("StringRF should be set", stringRF.isSet());
        assertTrue("StringRF should be valid", stringRF.isValid());
        assertEquals("ABC", stringRF.getValue());
        assertTrue("IntegerRF should be set", integerRF.isSet());
        assertTrue("IntegerRF should be valid", integerRF.isValid());
        assertEquals(new Integer(10), integerRF.getValue());
        assertTrue("IntRF should be set", intRF.isSet());
        assertTrue("IntRF should be valid", intRF.isValid());
        assertEquals(11, ((Integer) intRF.getValue()).intValue());
        assertTrue("DateRF should be set", dateRF.isSet());
        assertTrue("DateRF should be valid", dateRF.isValid());
        assertEquals(testDate, dateRF.getValue());

        RequiredFalseGroupTestObject rfgto = new RequiredFalseGroupTestObject();
        requiredFalseTestGroup.setProperties(rfgto);
        assertEquals("ABC", rfgto.getStringRF());
        assertEquals(new Integer(10), rfgto.getIntegerRF());
View Full Code Here

    {
        ParameterParser pp = new DefaultParameterParser();
        pp.add("rtt_0stringrt", "");
        requiredTrueTestGroup.init(Group.NEW, pp);

        Field stringRT = requiredTrueTestGroup.get("StringRT");

        assertTrue("StringRT should be set", stringRT.isSet());
        assertFalse("StringRT should not be valid", stringRT.isValid());
        assertEquals("", stringRT.getValue());
    }
View Full Code Here

    public void testInitialErrorState() throws IntakeException
    {
        ParameterParser pp = new DefaultParameterParser();
        requiredFalseTestGroup.init(Group.NEW, pp);

        Field stringRF = requiredFalseTestGroup.get("StringRF");
        Field integerRF = requiredFalseTestGroup.get("IntegerRF");
        Field intRF = requiredFalseTestGroup.get("IntRF");
        Field dateRF = requiredFalseTestGroup.get("DateRF");

        assertFalse("StringRF should not be set", stringRF.isSet());
        assertTrue("StringRF should be valid", stringRF.isValid());
        assertEquals("StringRF should have no messages.", "", stringRF.getMessage());
        assertNull(stringRF.getValue());
        assertFalse("IntegerRF should not be set", integerRF.isSet());
        assertTrue("IntegerRF should be valid", integerRF.isValid());
        assertEquals("IntegerRF should have no messages", "", integerRF.getMessage());
        assertNull(integerRF.getValue());
        assertFalse("IntRF should not be set", intRF.isSet());
        assertTrue("IntRF should be valid", intRF.isValid());
        assertEquals("IntRF should have no messages", "", intRF.getMessage());
        assertNull(intRF.getValue());
        assertFalse("DateRF should not be set", dateRF.isSet());
        assertTrue("DateRF should be valid", dateRF.isValid());
        assertEquals("DateRF should have no messages", "", dateRF.getMessage());
        assertNull(dateRF.getValue());

        requiredTrueTestGroup.init(Group.NEW, pp);
        Field stringRT = requiredTrueTestGroup.get("StringRT");

        assertFalse("StringRT should not be set", stringRT.isSet());
        assertTrue("StringRT should be valid", stringRT.isValid());
        assertEquals("StringRT should have no messages.", "", stringRT.getMessage());
        assertNull(stringRT.getValue());
    }
View Full Code Here

TOP

Related Classes of org.apache.turbine.services.intake.model.Field

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.