Package com.volantis.shared.metadata.value.mutable

Examples of com.volantis.shared.metadata.value.mutable.MutableStringValue


        // set up the value strucutre
        final MutableStructureValue structureValue =
            VALUE_FACTORY.createStructureValue();
        final Map fieldValues = structureValue.getFieldValuesAsMutableMap();

        final MutableStringValue fooValue = VALUE_FACTORY.createStringValue();
        fooValue.setValue("Foo");
        fieldValues.put("foo", fooValue);
        fieldValues.put("bar", VALUE_FACTORY.createBooleanValue());
        final MutableStructureValue childStructureValue =
            VALUE_FACTORY.createStructureValue();
        final MutableNumberValue bazValue = VALUE_FACTORY.createNumberValue();
View Full Code Here


        // set up the value strucutre
        final MutableStructureValue structureValue =
            VALUE_FACTORY.createStructureValue();
        final Map fieldValues = structureValue.getFieldValuesAsMutableMap();

        final MutableStringValue fooValue = VALUE_FACTORY.createStringValue();
        fooValue.setValue("Foo");
        fieldValues.put("foo", fooValue);
        final MutableNumberValue numberValue = VALUE_FACTORY.createNumberValue();
        fieldValues.put("bar", numberValue);
        final MutableStructureValue childStructureValue =
            VALUE_FACTORY.createStructureValue();
View Full Code Here

        // set up the value structure
        final MutableChoiceValue choiceValue =
            VALUE_FACTORY.createChoiceValue();
       
        choiceValue.setChoiceName("foo");
        final MutableStringValue fooValue = VALUE_FACTORY.createStringValue();
        fooValue.setValue("Foo");
        choiceValue.setValue(fooValue);

        final Collection errors = choiceType.verify(choiceValue);
        assertEquals(0, errors.size());
    }
View Full Code Here

        // set up the value strucutre
        final MutableChoiceValue choiceValue =
            VALUE_FACTORY.createChoiceValue();
        choiceValue.setChoiceName("foo");
        final MutableStringValue fooValue = VALUE_FACTORY.createStringValue();
        fooValue.setValue("Foo");
        choiceValue.setValue(fooValue);

        final Collection errors = choiceType.verify(choiceValue);
        assertEquals(0, errors.size());
    }
View Full Code Here

    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());
View Full Code Here

            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);
View Full Code Here

            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);
View Full Code Here

        memberTypeConstraint.setMemberType(TYPE_FACTORY.createBooleanType());
        collectionType.setMemberTypeConstraint(memberTypeConstraint);
        errors = collectionType.verify(collectionValue);
        assertEquals(4, errors.size());

        MutableStringValue stringValue = VALUE_FACTORY.createStringValue();
        stringValue.setValue("one");

        // build a set of the expected errors.
        List expectedErrors = new ArrayList();
        expectedErrors.add(new ExpectedError(
            VerificationError.TYPE_CONSTRAINT_VIOLATION, stringValue, memberTypeConstraint));
        expectedErrors.add(new ExpectedError(
            VerificationError.TYPE_INVALID_IMPLEMENTATION, stringValue, null));
        stringValue = VALUE_FACTORY.createStringValue();
        stringValue.setValue("two");
        expectedErrors.add(new ExpectedError(
            VerificationError.TYPE_CONSTRAINT_VIOLATION, stringValue, memberTypeConstraint));
        expectedErrors.add(new ExpectedError(
            VerificationError.TYPE_INVALID_IMPLEMENTATION, stringValue, null));
View Full Code Here

    protected MutableCollectionValue createCollectionValue(final String[] values) {
        MutableCollectionValue collectionValue = createEmptyValue();
        final Collection contents =
            collectionValue.getContentsAsMutableCollection();
        for (int i = 0; i < values.length; i++) {
            final MutableStringValue stringValue =
                VALUE_FACTORY.createStringValue();
            stringValue.setValue(values[i]);
            contents.add(stringValue);
        }
        return collectionValue;
    }
View Full Code Here

        // check constraint violation
        listValue =
            (MutableListValue) createCollectionValue(new String[]{"one", "one"});
        errors = listType.verify(listValue);
        assertEquals(1, errors.size());
        final MutableStringValue stringValue = VALUE_FACTORY.createStringValue();
        stringValue.setValue("one");
        final VerificationError error =
            (VerificationError) errors.iterator().next();
        assertEquals(VerificationError.TYPE_CONSTRAINT_VIOLATION,
            error.getType());
        assertEquals("[2]", error.getLocation());
View Full Code Here

TOP

Related Classes of com.volantis.shared.metadata.value.mutable.MutableStringValue

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.