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

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


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


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

        // 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();
        bazValue.setValue(new Integer(123));
        childStructureValue.getFieldValuesAsMutableMap().put("baz", bazValue);
        fieldValues.put("child", childStructureValue);

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

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

        // 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();
        final MutableBooleanValue booleanValue =
            VALUE_FACTORY.createBooleanValue();
        childStructureValue.getFieldValuesAsMutableMap().put(
            "baz", booleanValue);
        fieldValues.put("child", childStructureValue);

        final Collection errors = structureType.verify(structureValue);
        assertEquals(2, errors.size());
View Full Code Here

        return fieldMap;
    }

    // Javadoc inherited
    public ImmutableMetaDataValue createMetaDataValue() {
        MutableStructureValue structureValue =
                VALUE_FACTORY.createStructureValue();
        Map fields =    structureValue.getFieldValuesAsMutableMap();

        for (Iterator i = fieldMap.entrySet().iterator(); i.hasNext();) {
            Map.Entry entry = (Map.Entry) i.next();
            String name = (String) entry.getKey();
            InternalPolicyValue value = (InternalPolicyValue) entry.getValue();
            fields.put(name, value == null ? null : value.createMetaDataValue());
        }

        return (ImmutableMetaDataValue) structureValue.createImmutable();
    }
View Full Code Here

     */
    private ImmutableStructureValue createStructure() {
        MetaDataValueFactory mdvFactory = META_DATA_VALUE_FACTORY;

        // create the top level structure
        MutableStructureValue structure =
                META_DATA_VALUE_FACTORY.createStructureValue();
        Map topMap = structure.getFieldValuesAsMutableMap();

        // create the
        // key1/keyA/a-string
        //     /keyB/11
        //
        // part
        MutableStructureValue subStructure =
                META_DATA_VALUE_FACTORY.createStructureValue();


        Map subMap = subStructure.getFieldValuesAsMutableMap();

        MutableStringValue aString = mdvFactory.createStringValue();
        aString.setValue("a-string");
        subMap.put("keyA", aString);

        MutableNumberValue eleven = mdvFactory.createNumberValue();
        eleven.setValue(new Integer(11));
        subMap.put("keyB", eleven);

        topMap.put("key1", subStructure.createImmutable());

        // create the
        // key2[0]/true
        //     [1]/false
        //
        // 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);
View Full Code Here

     * @throws Exception if an error occurs
     */
    public void testWhenCharacteristicIsStruct() throws Exception {
        // add a policy/policy value pair to the request
        String charateristic = "struct";
        MutableStructureValue value =
                META_DATA_VALUE_FACTORY.createStructureValue();
        Map map = value.getFieldValuesAsMutableMap();
        MutableStringValue strVal = META_DATA_VALUE_FACTORY.createStringValue();
        strVal.setValue("str");
        map.put("key", strVal.createImmutable());
        ImmutableMetaDataValue structVal = (ImmutableMetaDataValue)
                                                 value.createImmutable();

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

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

TOP

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

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.