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

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


        return new ImmutableStructureTypeImpl();
    }

    // Javadoc inherited.
    public void testEqualsAndHashcodeImplementedCorrectly() {
        MutableStructureType structureType1 = createStructureTypeForTests();
        MutableStructureType structureType2 = createStructureTypeForTests();

        // ensure that the two objects are equal
        assertEquals("Object 1 should  be equal to object 2",
                structureType1, structureType2);

        // ensure that they have the same hash code
        int structureType1Hashcode = structureType1.hashCode();
        int structureType2Hashcode = structureType2.hashCode();
        assertTrue("Objects which are equal should have the same hash codes. Were : "
                + structureType1Hashcode + " and " + structureType2Hashcode,
                structureType1Hashcode == structureType2Hashcode);

        // now change a single item in each list and ensure that they are different
        MutableFieldDefinitionImpl fieldDefinition = new MutableFieldDefinitionImpl();
        fieldDefinition.setType( new MutableBooleanTypeImpl() );
        structureType2.getMutableFields().add(fieldDefinition);
        assertNotEquals(structureType1, structureType2);

        // see if the hashcodes are different
        structureType1Hashcode = structureType1.hashCode();
        structureType2Hashcode = structureType2.hashCode();
        assertFalse("Objects which are not equal should ideally not have the same hash " +
                "codes. Were : " + structureType1Hashcode + " and "
                + structureType2Hashcode,
                structureType1Hashcode == structureType2Hashcode);
    }
View Full Code Here


     * {@link com.volantis.shared.metadata.type.StructureType#createMutable},
     * the two objects do not
     * share a common <code>List</code>.
     */
    public void testCreateMutableFromMutableDoesNotShareSet() throws Throwable {
        MutableStructureType listValueImpl1 = (MutableStructureType)
                getMutableInhibitor();

        MutableStructureType listValueImpl2 =
                (MutableStructureType) listValueImpl1.createMutable();

        Set internalSet1 = (Set) PrivateAccessor.getField(listValueImpl1,
                "fields");

View Full Code Here

        assertFalse("The two lists should have different sizes after adding an object " +
                "to one list", internalSet1.size() == internalSet2.size());
    }

    public void testVerifyImplementation() {
        final MutableStructureType structureType =
            TYPE_FACTORY.createStructureType();

        // normal case
        final MutableStructureValue structureValue =
            VALUE_FACTORY.createStructureValue();
        Collection errors = structureType.verify(structureValue);
        assertEquals(0, errors.size());

        // invalid type
        final BooleanValue booleanValue = VALUE_FACTORY.createBooleanValue();
        errors = structureType.verify(booleanValue);
        assertEquals(1, errors.size());
        VerificationError error =
            (VerificationError) errors.iterator().next();
        assertEquals(VerificationError.TYPE_INVALID_IMPLEMENTATION,
            error.getType());
View Full Code Here

        assertEquals(booleanValue, error.getInvalidValue());
        assertNull(error.getConstraint());
    }

    public void testVerifyFieldsOK() {
        final MutableStructureType structureType =
            TYPE_FACTORY.createStructureType();

        // 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();
        fieldDefinition.setType(booleanType);
        fieldTypes.add(fieldDefinition);

        final MutableFieldDefinition childDefinition =
            TYPE_FACTORY.createFieldDefinition("child");
        final MutableStructureType childStructureType =
            TYPE_FACTORY.createStructureType();

        fieldDefinition = TYPE_FACTORY.createFieldDefinition("baz");
        final MutableNumberType numberType =
            TYPE_FACTORY.createNumberType();
        fieldDefinition.setType(numberType);
        childStructureType.getMutableFields().add(fieldDefinition);

        childDefinition.setType(childStructureType);
        fieldTypes.add(childDefinition);

        // set up the value strucutre
View Full Code Here

        final Collection errors = structureType.verify(structureValue);
        assertEquals(0, errors.size());
    }

    public void testVerifyFieldsInvalidFields() {
        final MutableStructureType structureType =
            TYPE_FACTORY.createStructureType();

        // 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();
        fieldDefinition.setType(booleanType);
        fieldTypes.add(fieldDefinition);

        final MutableFieldDefinition childDefinition =
            TYPE_FACTORY.createFieldDefinition("child");
        final MutableStructureType childStructureType =
            TYPE_FACTORY.createStructureType();

        fieldDefinition = TYPE_FACTORY.createFieldDefinition("baz");
        final MutableNumberType numberType =
            TYPE_FACTORY.createNumberType();
        fieldDefinition.setType(numberType);
        childStructureType.getMutableFields().add(fieldDefinition);

        childDefinition.setType(childStructureType);
        fieldTypes.add(childDefinition);

        // set up the value strucutre
View Full Code Here

        assertEquals(expectedConstraint, error.getConstraint());

    }

    public void testPersistence2() throws Exception {
        MutableStructureType mdo = new MutableStructureTypeImpl();
        Set fields = mdo.getMutableFields();
        fields.add(new ImmutableFieldDefinitionImpl("hello"));
        fields.add(new ImmutableFieldDefinitionImpl("there"));

        MetaDataObject result = checkPersistence((MetaDataObject)mdo.createImmutable());
        assertEquals("The detached object is not equal to the object " +
            "before persistence", mdo, result);
        MetaDataObject result2 = checkPersistence(mdo);

    }
View Full Code Here

    // Javadoc inherited.
    public ImmutableMetaDataType createMetaDataType() {
        ensureComplete();

        MutableStructureType structureType = TYPE_FACTORY.createStructureType();
        Set fields = structureType.getMutableFields();

        for (Iterator i = fieldTypes.entrySet().iterator(); i.hasNext();) {
            Map.Entry field = (Map.Entry) i.next();
            String fieldName = (String) field.getKey();
            InternalPolicyType fieldType
                    = (InternalPolicyType) field.getValue();

            MutableFieldDefinition fieldDefinition =
                    TYPE_FACTORY.createFieldDefinition(fieldName);
            fieldDefinition.setType(fieldType.createMetaDataType());
            fields.add(fieldDefinition);
        }

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

TOP

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

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.