Package com.volantis.shared.metadata.type.mutable

Examples of com.volantis.shared.metadata.type.mutable.MutableStringType


        // set up the type strucutre
        final Set fieldTypes = structureType.getMutableFields();

        MutableFieldDefinition fieldDefinition =
            TYPE_FACTORY.createFieldDefinition("foo");
        final MutableStringType stringType = TYPE_FACTORY.createStringType();
        fieldDefinition.setType(stringType);
        fieldTypes.add(fieldDefinition);

        fieldDefinition = TYPE_FACTORY.createFieldDefinition("bar");
        final MutableBooleanType booleanType = TYPE_FACTORY.createBooleanType();
View Full Code Here


        // set up the type strucutre
        final Set fieldTypes = structureType.getMutableFields();

        MutableFieldDefinition fieldDefinition =
            TYPE_FACTORY.createFieldDefinition("foo");
        final MutableStringType stringType = TYPE_FACTORY.createStringType();
        fieldDefinition.setType(stringType);
        fieldTypes.add(fieldDefinition);

        fieldDefinition = TYPE_FACTORY.createFieldDefinition("bar");
        final MutableBooleanType booleanType = TYPE_FACTORY.createBooleanType();
View Full Code Here

        // set up the type strucutre
        final Set choiceDefinitions = choiceType.getMutableChoiceDefinitions();

        MutableChoiceDefinition choiceDefinition =
            TYPE_FACTORY.createChoiceDefinition("foo");
        final MutableStringType stringType = TYPE_FACTORY.createStringType();
        choiceDefinition.setType(stringType);
        choiceDefinitions.add(choiceDefinition);

        // set up the value strucutre
        final MutableChoiceValue choiceValue =
View Full Code Here

        // set up the type strucutre
        final Set choiceDefinitions = choiceType.getMutableChoiceDefinitions();

        MutableChoiceDefinition choiceDefinition =
            TYPE_FACTORY.createChoiceDefinition("foo");
        final MutableStringType stringType = TYPE_FACTORY.createStringType();
        choiceDefinition.setType(stringType);
        choiceDefinitions.add(choiceDefinition);

        // set up the value strucutre
        final MutableChoiceValue choiceValue =
View Full Code Here

        // set up the type strucutre
        final Set choiceDefinitions = choiceType.getMutableChoiceDefinitions();

        MutableChoiceDefinition choiceDefinition =
            TYPE_FACTORY.createChoiceDefinition("foo");
        final MutableStringType stringType = TYPE_FACTORY.createStringType();
        choiceDefinition.setType(stringType);
        choiceDefinitions.add(choiceDefinition);

        // set up the value strucutre
        final MutableChoiceValue choiceValue =
View Full Code Here

        return new ImmutableStringTypeImpl();
    }

    // Javadoc inherited.
    public void testEqualsAndHashcodeImplementedCorrectly() {
        MutableStringType stringType1 =
                createStringTypeForTestEquals();
        MutableStringType stringType2 =
                createStringTypeForTestEquals();

        // test that both the values are equal and they have the same hash codes
        assertEquals("Object 1 should be equal to object 2", stringType1, stringType2);
        MetaDataTestCaseHelper.ensureHashcodesEqual(stringType1, stringType2);

        // now null the constraints and check that the objects are no longer equal
        // and ideally have different hashcodes
        stringType2.setEnumeratedConstraint(null);

        assertNotSame(stringType1, stringType2);
        MetaDataTestCaseHelper.ensureHashcodesNotEqual(stringType1, stringType2);

    }
View Full Code Here

        mutableBooleanType.setEnumeratedConstraint(enumeratedConstraint);
        return mutableBooleanType;
    }

    public void testVerify() {
        final MutableStringType stringType = TYPE_FACTORY.createStringType();

        // normal case
        MutableStringValue stringValue = VALUE_FACTORY.createStringValue();
        stringValue.setValue("Foo");
        Collection errors = stringType.verify(stringValue);
        assertEquals(0, errors.size());

        // null value
        stringValue = VALUE_FACTORY.createStringValue();
        errors = stringType.verify(stringValue);
        assertEquals(1, errors.size());
        VerificationError error =
            (VerificationError) errors.iterator().next();
        assertEquals(VerificationError.TYPE_NULL_VALUE,
            error.getType());
        assertEquals("", error.getLocation());
        assertEquals(stringValue, error.getInvalidValue());
        assertNull(error.getConstraint());

        // invalid type
        BooleanValue booleanValue = VALUE_FACTORY.createBooleanValue();
        errors = stringType.verify(booleanValue);
        assertEquals(1, errors.size());
        error = (VerificationError) errors.iterator().next();
        assertEquals(VerificationError.TYPE_INVALID_IMPLEMENTATION,
            error.getType());
        assertEquals("", error.getLocation());
        assertEquals(booleanValue, error.getInvalidValue());
        assertNull(error.getConstraint());

        // enumerated constraint
        final MutableEnumeratedConstraint enumeratedConstraint =
            CONSTRAINT_FACTORY.createEnumeratedConstraint();
        final List enumeratedValues =
            enumeratedConstraint.getMutableEnumeratedValues();
        final MutableStringValue constraintValue =
            VALUE_FACTORY.createStringValue();
        constraintValue.setValue("one");
        enumeratedValues.add(constraintValue.createImmutable());
        constraintValue.setValue("two");
        enumeratedValues.add(constraintValue.createImmutable());
        stringType.setEnumeratedConstraint(enumeratedConstraint);
        // check constraint with right value
        stringValue.setValue("two");
        errors = stringType.verify(stringValue);
        assertEquals(0, errors.size());
        // check constraint violation
        stringValue.setValue("three");
        errors = stringType.verify(stringValue);
        assertEquals(1, errors.size());
        error = (VerificationError) errors.iterator().next();
        assertEquals(VerificationError.TYPE_CONSTRAINT_VIOLATION,
            error.getType());
        assertEquals("", error.getLocation());
View Full Code Here

        assertEquals(enumeratedConstraint, error.getConstraint());
    }

    public void testVerifyMinimumLengthConstraint() {

        final MutableStringType stringType =
            (MutableStringType) getMutableInhibitor();

        final MutableMinimumLengthConstraint minimumLengthConstraint =
            CONSTRAINT_FACTORY.createMinimumLengthConstraint();
        minimumLengthConstraint.setLimit(5);
        stringType.setMinimumLengthConstraint(minimumLengthConstraint);

        // check constraint with right value
        final MutableStringValue stringValue = VALUE_FACTORY.createStringValue();
        stringValue.setValue("hello");
        Collection errors = stringType.verify(stringValue);
        assertEquals(0, errors.size());

        // check constraint violation
        minimumLengthConstraint.setLimit(6);
        stringType.setMinimumLengthConstraint(minimumLengthConstraint);
        errors = stringType.verify(stringValue);
        assertEquals(1, errors.size());
        final Iterator iter = errors.iterator();
        VerificationError error = (VerificationError) iter.next();
        assertEquals(VerificationError.TYPE_CONSTRAINT_VIOLATION,
            error.getType());
View Full Code Here

        assertEquals(minimumLengthConstraint, error.getConstraint());
    }

    public void testVerifyMaximumLengthConstraint() {

        final MutableStringType stringType =
            (MutableStringType) getMutableInhibitor();

        final MutableMaximumLengthConstraint maximumLengthConstraint =
            CONSTRAINT_FACTORY.createMaximumLengthConstraint();
        maximumLengthConstraint.setLimit(5);
        stringType.setMaximumLengthConstraint(maximumLengthConstraint);

        // check constraint with right value
        final MutableStringValue stringValue = VALUE_FACTORY.createStringValue();
        stringValue.setValue("hello");
        Collection errors = stringType.verify(stringValue);
        assertEquals(0, errors.size());

        // check constraint violation
        maximumLengthConstraint.setLimit(4);
        stringType.setMaximumLengthConstraint(maximumLengthConstraint);
        errors = stringType.verify(stringValue);
        assertEquals(1, errors.size());
        final Iterator iter = errors.iterator();
        VerificationError error = (VerificationError) iter.next();
        assertEquals(VerificationError.TYPE_CONSTRAINT_VIOLATION,
            error.getType());
View Full Code Here

    public ImmutableMetaDataType createMetaDataType() {
        ensureComplete();

        // Create a string type whose enumerated constraint contains the
        // keyword values.
        MutableStringType stringType = TYPE_FACTORY.createStringType();

        MutableEnumeratedConstraint enumeratedConstraint
                = CONSTRAINT_FACTORY.createEnumeratedConstraint();
        List allowableValues = enumeratedConstraint.getMutableEnumeratedValues();

        for (Iterator i = keywords.iterator(); i.hasNext();) {
            String keyword = (String) i.next();
            MutableStringValue value = VALUE_FACTORY.createStringValue();
            value.setValue(keyword);
            allowableValues.add(value);
        }

        // Add the constraint.
        stringType.setEnumeratedConstraint(enumeratedConstraint);

        return (ImmutableMetaDataType) stringType.createImmutable();
    }
View Full Code Here

TOP

Related Classes of com.volantis.shared.metadata.type.mutable.MutableStringType

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.