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

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


        return new ImmutableChoiceTypeImpl();
    }

    // Javadoc inherited.
    public void testEqualsAndHashcodeImplementedCorrectly() {
        MutableChoiceType choiceType1 = createChoiceTypeForTests();
        MutableChoiceType choiceType2 = createChoiceTypeForTests();

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

        // ensure that they have the same hash code
        int ChoiceType1Hashcode = choiceType1.hashCode();
        int ChoiceType2Hashcode = choiceType2.hashCode();
        assertTrue("Objects which are equal should have the same hash codes. Were : "
                + ChoiceType1Hashcode + " and " + ChoiceType2Hashcode,
                ChoiceType1Hashcode == ChoiceType2Hashcode);

        // now change a single item in each list and ensure that they are different
        MutableChoiceDefinitionImpl choiceDefinition = new MutableChoiceDefinitionImpl();
        choiceDefinition.setType( new MutableBooleanTypeImpl() );
        choiceType2.getMutableChoiceDefinitions().add(choiceDefinition);
        assertNotEquals(choiceType1, choiceType2);

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


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

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

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

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 MutableChoiceType choiceType =
            TYPE_FACTORY.createChoiceType();

        // normal case
        final MutableChoiceValue choiceValue =
            VALUE_FACTORY.createChoiceValue();
        Collection errors = choiceType.verify(choiceValue);
        assertEquals(0, errors.size());

        // invalid type
        final BooleanValue booleanValue = VALUE_FACTORY.createBooleanValue();
        errors = choiceType.verify(booleanValue);
        assertEquals(1, errors.size());
        checkError(errors, "", VerificationError.TYPE_INVALID_IMPLEMENTATION,
                booleanValue, null);
    }
View Full Code Here

        checkError(errors, "", VerificationError.TYPE_INVALID_IMPLEMENTATION,
                booleanValue, null);
    }

    public void testVerifyChoiceNameOK() {
        final MutableChoiceType choiceType = TYPE_FACTORY.createChoiceType();

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

        MutableChoiceDefinition choiceDefinition =
            TYPE_FACTORY.createChoiceDefinition("foo");
        choiceDefinition.setType(TYPE_FACTORY.createStringType());
        choiceDefinitions.add(choiceDefinition);       
   
        // 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

        final Collection errors = choiceType.verify(choiceValue);
        assertEquals(0, errors.size());
    }
   
    public void testVerifyChoiceNameInvalid() {
        final MutableChoiceType choiceType = TYPE_FACTORY.createChoiceType();

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

        MutableChoiceDefinition choiceDefinition =
            TYPE_FACTORY.createChoiceDefinition("foo");
        choiceDefinition.setType(TYPE_FACTORY.createStringType());
        choiceDefinitions.add(choiceDefinition);       
   
        // set up the value structure
        final MutableChoiceValue choiceValue =
            VALUE_FACTORY.createChoiceValue();
       
        choiceValue.setChoiceName("bar");

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

        final Collection errors = choiceType.verify(choiceValue);
        assertEquals(1, errors.size());
    }
   
    public void testVerifyChoiceNameNull() {
        final MutableChoiceType choiceType = TYPE_FACTORY.createChoiceType();

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

        MutableChoiceDefinition choiceDefinition =
            TYPE_FACTORY.createChoiceDefinition("foo");
        choiceDefinition.setType(TYPE_FACTORY.createStringType());
        choiceDefinitions.add(choiceDefinition);       
   
        // set up the value structure
        final MutableChoiceValue choiceValue =
            VALUE_FACTORY.createChoiceValue();
       
        final Collection errors = choiceType.verify(choiceValue);
        assertEquals(1, errors.size());
    }
View Full Code Here

        final Collection errors = choiceType.verify(choiceValue);
        assertEquals(1, errors.size());
    }
   
    public void testVerifyChoiceValueOK() {
        final MutableChoiceType choiceType =
            TYPE_FACTORY.createChoiceType();

        // 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 =
            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

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

    public void testVerifyChoiceValueInvalid() {
        final MutableChoiceType choiceType =
            TYPE_FACTORY.createChoiceType();

        // 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 =
            VALUE_FACTORY.createChoiceValue();
        choiceValue.setChoiceName("foo");
        final MutableNumberValue fooValue = VALUE_FACTORY.createNumberValue();
        fooValue.setValue(new Integer(1));
        choiceValue.setValue(fooValue);

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

        final Collection errors = choiceType.verify(choiceValue);
        assertEquals(1, errors.size());
    }

    public void testVerifyChoiceValueNull() {
        final MutableChoiceType choiceType =
            TYPE_FACTORY.createChoiceType();

        // 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 =
            VALUE_FACTORY.createChoiceValue();
        choiceValue.setChoiceName("foo");

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

TOP

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

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.