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

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


        unitType.setEnumeratedConstraint(enumeratedConstraint);
        quantityType.setUnitType(unitType);

        // normal case
        MutableQuantityValue quantityValue = VALUE_FACTORY.createQuantityValue();
        final MutableNumberValue magnitudeValue =
            VALUE_FACTORY.createNumberValue();
        magnitudeValue.setValue(new Integer(123));
        quantityValue.setMagnitudeValue(magnitudeValue);
        quantityValue.setUnitValue(QuantityUnits.CENTIMETERS);
        Collection errors = quantityType.verify(quantityValue);
        assertEquals(0, errors.size());

        // invalid magnitude type
        magnitudeValue.setValue(new Byte((byte) 42));
        quantityValue.setMagnitudeValue(magnitudeValue);
        errors = quantityType.verify(quantityValue);
        assertEquals(1, errors.size());
        VerificationError error = (VerificationError) errors.iterator().next();
        assertEquals(VerificationError.TYPE_CONSTRAINT_VIOLATION,
            error.getType());
        assertEquals("[@magnitude]", error.getLocation());
        assertEquals(magnitudeValue, error.getInvalidValue());
        assertEquals(subTypeConstraint, error.getConstraint());

        // invalid unit type
        magnitudeValue.setValue(new Integer(42));
        quantityValue.setMagnitudeValue(magnitudeValue);
        quantityValue.setUnitValue(QuantityUnits.PIXELS);
        errors = quantityType.verify(quantityValue);
        assertEquals(1, errors.size());
        error = (VerificationError) errors.iterator().next();
View Full Code Here


        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

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

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

    public void testVerify() {
        final MutableNumberType numberType = TYPE_FACTORY.createNumberType();

        // normal case
        MutableNumberValue numberValue = VALUE_FACTORY.createNumberValue();
        numberValue.setValue(new Integer(5));
        Collection errors = numberType.verify(numberValue);
        assertEquals(0, errors.size());

        // null value
        numberValue = VALUE_FACTORY.createNumberValue();
        errors = numberType.verify(numberValue);
        assertEquals(1, errors.size());
        VerificationError error =
            (VerificationError) errors.iterator().next();
        assertEquals(VerificationError.TYPE_NULL_VALUE,
            error.getType());
        assertEquals("", error.getLocation());
        assertEquals(numberValue, error.getInvalidValue());
        assertNull(error.getConstraint());

        // invalid type
        BooleanValue booleanValue = VALUE_FACTORY.createBooleanValue();
        errors = numberType.verify(booleanValue);
        assertEquals(1, errors.size());
        error = (VerificationError) errors.iterator().next();
        assertEquals(VerificationError.TYPE_INVALID_IMPLEMENTATION,
            error.getType());
        assertEquals("", error.getLocation());
        assertEquals(booleanValue, error.getInvalidValue());
        assertNull(error.getConstraint());

        // enumerated constraint
        final MutableEnumeratedConstraint enumeratedConstraint =
            CONSTRAINT_FACTORY.createEnumeratedConstraint();
        final List enumeratedValues =
            enumeratedConstraint.getMutableEnumeratedValues();
        final MutableNumberValue constraintValue =
            VALUE_FACTORY.createNumberValue();
        constraintValue.setValue(new Integer(6));
        enumeratedValues.add(constraintValue.createImmutable());
        constraintValue.setValue(new Integer(7));
        enumeratedValues.add(constraintValue.createImmutable());
        numberType.setEnumeratedConstraint(enumeratedConstraint);
        // check constraint with right value
        numberValue.setValue(new Integer(6));
        errors = numberType.verify(numberValue);
        assertEquals(0, errors.size());
View Full Code Here

        return value;
    }

    // Javadoc inherited
    public ImmutableMetaDataValue createMetaDataValue() {
        MutableNumberValue numberValue = VALUE_FACTORY.createNumberValue();
        numberValue.setValue(value);

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

        return value;
    }

    // Javadoc inherited
    public ImmutableMetaDataValue createMetaDataValue() {
        MutableNumberValue numberValue = VALUE_FACTORY.createNumberValue();
        numberValue.setValue(value);

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

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

     * @throws Exception if an error occurs
     */
    public void testWhenCharacteristicIsNumber() throws Exception {
        // add a policy/policy value pair to the request
        String charateristic = "num";
        MutableNumberValue value = META_DATA_VALUE_FACTORY.createNumberValue();
        value.setValue(new Double(11));
        ImmutableMetaDataValue numVal = (ImmutableMetaDataValue)
                                              value.createImmutable();

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

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

        super(name);
    }

    // Javadoc inherited.
    protected MutableInhibitor getMutableInhibitor() {
        MutableNumberValue mnv = new MutableNumberValueImpl();
        mnv.setValue(new Double(10.0));
        return mnv;
    }
View Full Code Here

TOP

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

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.