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

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


     */
    public void testIteratorOnlySetsAllowableTypes() {
       ImmutableGeneratingTypedList typedList =
                new ImmutableGeneratingTypedList(new ArrayList(), BooleanValue.class);

        MutableBooleanValue booleanValue1 = MetaDataFactory.getDefaultInstance().
                getValueFactory().createBooleanValue();
        // create a second value which is not equal to the first value
        MutableBooleanValue booleanValue2 = MetaDataFactory.getDefaultInstance().
                getValueFactory().createBooleanValue();
        booleanValue2.setValue(Boolean.TRUE);

        typedList.add(booleanValue1);

        ListIterator iterator = typedList.listIterator();

View Full Code Here


    /**
     * Tests that the typed list only accepts allowable types.
     */
    public void testListOnlyStoresAllowableTypes() {
        MetaDataFactory f = MetaDataFactory.getDefaultInstance();
        MutableBooleanValue allowableObject = (MutableBooleanValue) f.getValueFactory()
            .createBooleanValue().createMutable();
        allowableObject.setValue(Boolean.TRUE);

        NumberValue unallowableObject = (NumberValue) f.getValueFactory()
            .createNumberValue();

        TypedList typedList = new TypedList(new ArrayList(), BooleanValue.class);

        try {
            typedList.add(allowableObject);
        } catch (IllegalArgumentException e) {
            fail("Adding a " + allowableObject.getClass() + " should be permitted.");
        }

        // check that the mutable list will not allow a forbiden type
        try {
            typedList.add(unallowableObject);
            fail("Adding any thing other than a " + allowableObject.getClass() +
                    " should throw an IllegalArgumentException.");
        } catch (IllegalArgumentException e) {
            // expected.
        }
    }
View Full Code Here

     * allowed to add objects of the correct type on the <code>ListIterator</code>
     * provided by {@link TypedList#iterator}.
     */
    public void testIteratorOnlyAddsAllowableTypes() {
        MetaDataFactory f = MetaDataFactory.getDefaultInstance();
        MutableBooleanValue allowableObject = (MutableBooleanValue) f.getValueFactory()
            .createBooleanValue().createMutable();
        allowableObject.setValue(Boolean.TRUE);

        NumberValue unallowableObject = (NumberValue) f.getValueFactory()
            .createNumberValue();
        TypedList typedList = new TypedList(new ArrayList(), BooleanValue.class);
        ListIterator iterator = typedList.listIterator();

        // check that the list iterator will allow an permitted type to be added
        try {
            iterator.add(allowableObject);
        } catch (IllegalArgumentException e) {
            fail("Adding a " + allowableObject.getClass() + " should be permitted.");
        }

        // check that the list iterator will not allow a forbiden type to be added
        try {
            iterator.add(unallowableObject);
            fail("Adding any thing other than a " + allowableObject.getClass() +
                    " should throw an IllegalArgumentException.");
        } catch (IllegalArgumentException e) {
            // expected.
        }
    }
View Full Code Here

        //
        // part
        MutableListValue metaList = META_DATA_VALUE_FACTORY.createListValue();
        List list = metaList.getContentsAsMutableList();

        MutableBooleanValue trueBool =
                META_DATA_VALUE_FACTORY.createBooleanValue();
        trueBool.setValue(Boolean.TRUE);
        list.add(trueBool);

        MutableBooleanValue falseBool =
                META_DATA_VALUE_FACTORY.createBooleanValue();
        falseBool.setValue(Boolean.FALSE);
        list.add(falseBool);

        topMap.put("key2", metaList.createImmutable());

        // create the
        // key3/set[0]/keyX/b-string
        //            /keyY/c-string
        //     /set[1]/true
        //     /set[2]/x-string
        MutableSetValue metaSet = META_DATA_VALUE_FACTORY.createSetValue();
        Set set = metaSet.getContentsAsMutableSet();

        MutableStructureValue setsStruct =
                META_DATA_VALUE_FACTORY.createStructureValue();

        Map setsStructMap = setsStruct.getFieldValuesAsMutableMap();
        MutableStringValue bString = mdvFactory.createStringValue();
        bString.setValue("b-string");
        setsStructMap.put("keyX", bString);

        MutableStringValue cString = mdvFactory.createStringValue();
        cString.setValue("c-string");
        setsStructMap.put("keyY", cString);

        set.add(setsStruct.createImmutable());


        MutableBooleanValue tBool =
                META_DATA_VALUE_FACTORY.createBooleanValue();
        tBool.setValue(Boolean.TRUE);
        set.add(tBool);

        MutableStringValue xString = mdvFactory.createStringValue();
        xString.setValue("x-string");
        set.add(xString);
View Full Code Here

        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
        MutableBooleanValue booleanValue = MetaDataFactory.getDefaultInstance().
                getValueFactory().createBooleanValue();

        enumeratedConstraint2.getMutableEnumeratedValues().add(booleanValue);

        assertNotEquals(enumeratedConstraint1, enumeratedConstraint2);
View Full Code Here

     */
    private MutableEnumeratedConstraint createEnumeratedConstraintForTestEquals() {
        MutableEnumeratedConstraintImpl mutableEnumeratedConstraint =
                new MutableEnumeratedConstraintImpl();

        MutableBooleanValue booleanValue = MetaDataFactory.getDefaultInstance().
                getValueFactory().createBooleanValue();
        booleanValue.setValue(Boolean.TRUE);

        mutableEnumeratedConstraint.getMutableEnumeratedValues().add(booleanValue);
        return mutableEnumeratedConstraint;
    }
View Full Code Here

     * @throws Exception if an error occurs
     */
    public void testWhenCharacteristicIsBool() throws Exception {
        // add a policy/policy value pair to the request
        String charateristic = "bool";
        MutableBooleanValue value = META_DATA_VALUE_FACTORY.createBooleanValue();
        value.setValue(Boolean.FALSE);
        ImmutableMetaDataValue boolVal = (ImmutableMetaDataValue)
                                              value.createImmutable();

        serviceDefMock.expects.getCharacteristic(charateristic).returns(boolVal);

        // invoke the function
        Expression expression = parser.parse(getFunctionQName() +
View Full Code Here

        return new ImmutableBooleanValueImpl();
    }

    // Javadoc inherited.
    public void testEqualsAndHashcodeImplementedCorrectly() {
        MutableBooleanValue booleanValue1 =
                createBooleanValueForTestEquals();
        MutableBooleanValue booleanValue2 =
                createBooleanValueForTestEquals();

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

        int booleanValue1Hashcode = booleanValue1.hashCode();
        int booleanValue2Hashcode = booleanValue2.hashCode();
        assertTrue("Objects which are equal should have the same hash codes. Were : "
                + booleanValue1Hashcode + " and " + booleanValue2Hashcode,
                booleanValue1Hashcode == booleanValue2Hashcode);

        // change a property in one of the objects and ensure they are not equal
        booleanValue2.setValue(Boolean.FALSE);

        assertNotEquals(booleanValue1, booleanValue2);
        assertNotEquals(booleanValue2, booleanValue1);

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

        MutableStringValue stringValue = new MutableStringValueImpl();
        stringValue.setValue("First Value");
        expectedFields.put("first", stringValue.createImmutable());
        stringValue.setValue("Fourth Value");
        expectedFields.put("fourth", stringValue.createImmutable());
        MutableBooleanValue booleanValue = new MutableBooleanValueImpl();
        booleanValue.setValue(Boolean.TRUE);
        expectedFields.put("second", booleanValue.createImmutable());
        booleanValue.setValue(Boolean.FALSE);
        expectedFields.put("third", booleanValue.createImmutable());
        assertEquals(expectedFields, structure.getFieldValuesAsMap());

        final Object otherStructure = doRoundTrip(structure);
        assertEquals(structure, otherStructure);
    }
View Full Code Here

        // check the created object
        final List expectedList = new LinkedList();
        MutableStringValue stringValue = new MutableStringValueImpl();
        stringValue.setValue("First Value");
        expectedList.add(stringValue.createImmutable());
        MutableBooleanValue booleanValue = new MutableBooleanValueImpl();
        booleanValue.setValue(Boolean.TRUE);
        expectedList.add(booleanValue.createImmutable());
        booleanValue.setValue(Boolean.FALSE);
        expectedList.add(booleanValue.createImmutable());
        stringValue.setValue("Fourth Value");
        expectedList.add(stringValue.createImmutable());
        assertEquals(expectedList, list.getContentsAsList());

        final Object otherList = doRoundTrip(list);
View Full Code Here

TOP

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

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.