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

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


        return new ImmutableBooleanTypeImpl();
    }

    // Javadoc inherited.
    public void testEqualsAndHashcodeImplementedCorrectly() {
        MutableBooleanType booleanType1 =
                createBooleanTypeForTestEquals();
        MutableBooleanType booleanType2 =
                createBooleanTypeForTestEquals();

        // test that both the values are equal and they have the same hash codes
        assertEquals("Object 1 should be equal to object 2", booleanType1, booleanType2);
        assertEquals("Object 2 should be equal to object 1", booleanType2, booleanType1);

        int booleanType1Hashcode = booleanType1.hashCode();
        int booleanType2Hashcode = booleanType2.hashCode();
        assertTrue("Objects which are equal should have the same hash codes. Were : "
                + booleanType1Hashcode + " and " + booleanType2Hashcode,
                booleanType1Hashcode == booleanType2Hashcode);

        // change a property in one of the objects and ensure they are not equal
        booleanType2.setEnumeratedConstraint(null);

        assertNotEquals(booleanType1, booleanType2);
        assertNotEquals(booleanType2, booleanType1);

        // ensure that the hashcodes are different for these two objects
        booleanType1Hashcode = booleanType1.hashCode();
        booleanType2Hashcode = booleanType2.hashCode();
        assertFalse("Objects which are not equal should ideally have different hash codes",
                booleanType1Hashcode == booleanType2Hashcode);
    }
View Full Code Here


        mutableBooleanType.setEnumeratedConstraint(enumeratedConstraint);
        return mutableBooleanType;
    }

    public void testVerify() {
        final MutableBooleanType booleanType = TYPE_FACTORY.createBooleanType();

        // normal case
        MutableBooleanValue booleanValue = VALUE_FACTORY.createBooleanValue();
        Collection errors = booleanType.verify(booleanValue);
        assertEquals(0, errors.size());

        // invalid type
        StringValue stringValue = VALUE_FACTORY.createStringValue();
        errors = booleanType.verify(stringValue);
        assertEquals(1, errors.size());
        VerificationError error = (VerificationError) errors.iterator().next();
        assertEquals(VerificationError.TYPE_INVALID_IMPLEMENTATION,
            error.getType());
        assertEquals("", error.getLocation());
        assertEquals(stringValue, error.getInvalidValue());
        assertNull(error.getConstraint());

        // enumerated constraint
        final MutableEnumeratedConstraint enumeratedConstraint =
            CONSTRAINT_FACTORY.createEnumeratedConstraint();
        final List enumeratedValues =
            enumeratedConstraint.getMutableEnumeratedValues();
        final MutableBooleanValue constraintValue =
            VALUE_FACTORY.createBooleanValue();
        constraintValue.setValue(Boolean.FALSE);
        enumeratedValues.add(constraintValue);
        booleanType.setEnumeratedConstraint(enumeratedConstraint);
        // check constraint with right value
        booleanValue.setValue(Boolean.FALSE);
        errors = booleanType.verify(booleanValue);
        assertEquals(0, errors.size());
        // check constraint violation
        booleanValue.setValue(Boolean.TRUE);
        errors = booleanType.verify(booleanValue);
        assertEquals(1, errors.size());
        error = (VerificationError) errors.iterator().next();
        assertEquals(VerificationError.TYPE_CONSTRAINT_VIOLATION,
            error.getType());
        assertEquals("", error.getLocation());
View Full Code Here

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

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

     * testing.
     * @return a mutable number type.
     */
    private MutableFieldDefinition createFieldDefinitionForTestingEquals() {
        MutableFieldDefinition fieldDefinition = new MutableFieldDefinitionImpl("tom");
        MutableBooleanType booleanType = new MutableBooleanTypeImpl();
        MutableEnumeratedConstraint constraint = MetaDataFactory.getDefaultInstance().
                getTypeFactory().getConstraintFactory().createEnumeratedConstraint();
        booleanType.setEnumeratedConstraint(constraint);
        fieldDefinition.setType(booleanType);
        return fieldDefinition;
    }
View Full Code Here

TOP

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

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.