Package com.volantis.shared.metadata.value.immutable

Examples of com.volantis.shared.metadata.value.immutable.ImmutableStructureValue


    public void testMapRetrieval() throws Exception {
        ImmutableMetaDataValue value = createService().getCharacteristic("/key1");
        // we should have an ImmutableStructureValue of the form
        // keyA/a-string
        // keyB/11
        ImmutableStructureValue struct = assertImmutableStructure(value, 2);
        // check that there is a string "a-string" at keyA
        Map map = struct.getFieldValuesAsMap();
        assertImmutableStringValue((ImmutableMetaDataValue) map.get("keyA"),
                                   "a-string");

        // check that their is a nubmer 11 at keyB
        assertImmutableNumberValue((ImmutableMetaDataValue) map.get("keyB"),
View Full Code Here


        if (!(value instanceof ImmutableStructureValue)) {
            fail("Expected a ImmutableStructureValue but got a " +
                 value.getClass().toString());
        }

        ImmutableStructureValue struct = (ImmutableStructureValue) value;
        assertEquals("structure should have size of " + expectedSize,
                     expectedSize,
                     struct.getFieldValuesAsMap().size());
        return struct;
    }
View Full Code Here

* Tests to verify JiBX marshaller/unmarshaller.
*/
public class JiBXTestCase extends JiBXTestCaseAbstract {

    public void testStructureWithStrings() throws Exception {
        final ImmutableStructureValue structure = (ImmutableStructureValue)
            unmarshall(getResourceAsString("res/structure-with-strings.xml"),
               ImmutableStructureValueImpl.class);

        // check the created object
        final Map expectedFields = new HashMap();
        MutableStringValue value = new MutableStringValueImpl();
        value.setValue("First Value");
        expectedFields.put("first", value.createImmutable());
        value.setValue("Second Value");
        expectedFields.put("second", value.createImmutable());
        assertEquals(expectedFields, structure.getFieldValuesAsMap());

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

        final Object otherStructure = doRoundTrip(structure);
        assertEquals(structure, otherStructure);
    }

    public void testStructureWithBooleansAndStrings() throws Exception {
        final ImmutableStructureValue structure = (ImmutableStructureValue)
            unmarshall(
                getResourceAsString("res/structure-with-booleans-and-strings.xml"),
                ImmutableStructureValueImpl.class);

        // check the created object
        final Map expectedFields = new HashMap();
        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

        final Object otherStructure = doRoundTrip(structure);
        assertEquals(structure, otherStructure);
    }

    public void testNestedStructure() throws Exception {
        final ImmutableStructureValue structure = (ImmutableStructureValue)
            unmarshall(getResourceAsString("res/nested-structure.xml"),
               ImmutableStructureValueImpl.class);

        // check the created object
        final Map expectedFields = new HashMap();
        final MutableStructureValueImpl structureValue =
            new MutableStructureValueImpl();
        final MutableStringValue value = new MutableStringValueImpl();
        value.setValue("1/A Value");
        structureValue.addField(new StructureFieldValue("sub1",
            (MetaDataValue) value.createImmutable()));
        value.setValue("1/B Value");
        structureValue.addField(new StructureFieldValue("sub2",
            (MetaDataValue) value.createImmutable()));
        expectedFields.put("first", structureValue);
        value.setValue("Second Value");
        expectedFields.put("second", value.createImmutable());
        assertEquals(expectedFields, structure.getFieldValuesAsMap());

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

        final Object otherList = doRoundTrip(set);
        assertEquals(set, otherList);
    }

    public void testAddressValue() throws Exception {
        final ImmutableStructureValue structure = (ImmutableStructureValue)
            unmarshall(getResourceAsString("res/address-value.xml"),
               ImmutableStructureValueImpl.class);

        final Map fields = structure.getFieldValuesAsMap();
        assertEquals(1, fields.size());
        final ImmutableStructureValue addressValue =
            (ImmutableStructureValue) fields.get("address");

        // check the created object
        final Map addressFields = addressValue.getFieldValuesAsMap();
        assertEquals(2, addressFields.size());

        final ImmutableStringValue emailValue =
            (ImmutableStringValue) addressFields.get("email");
        assertEquals("foo-bar@example.com", emailValue.getValueAsString());

        final ImmutableStructureValue postalValue =
            (ImmutableStructureValue) addressFields.get("postal");

        final Map postalFields = postalValue.getFieldValuesAsMap();
        assertEquals(4, postalFields.size());

        final ImmutableNumberValue houseNumberValue =
            (ImmutableNumberValue) postalFields.get("house-number");
        assertEquals(new Integer(42), houseNumberValue.getValueAsNumber());
View Full Code Here

TOP

Related Classes of com.volantis.shared.metadata.value.immutable.ImmutableStructureValue

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.