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

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


        return new ImmutableNumberValueImpl(new Double(10.0));
    }

    // Javadoc inherited.
    public void testEqualsAndHashcodeImplementedCorrectly() {
        MutableNumberValue numberValue1 = getMutableNumberValueForTestEquals();
        MutableNumberValue numberValue2 = getMutableNumberValueForTestEquals();

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

        int booleanValue1Hashcode = numberValue1.hashCode();
        int booleanValue2Hashcode = numberValue2.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
        numberValue2.setValue(new Double(2.0));

        assertNotEquals(numberValue1, numberValue2);
        assertNotEquals(numberValue2, numberValue1);

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


            getResourceAsString("res/list-with-numbers.xml"),
            ImmutableListValueImpl.class);

        // check the created object
        final List expectedList = new LinkedList();
        MutableNumberValue value = new MutableNumberValueImpl();
        value.setValue(new Byte((byte) 42));
        expectedList.add(value.createImmutable());
        value.setValue(new Short((short) 1));
        expectedList.add(value.createImmutable());
        value.setValue(new Integer(2));
        expectedList.add(value.createImmutable());
        value.setValue(new Long(3));
        expectedList.add(value.createImmutable());
        value.setValue(new BigInteger("4"));
        expectedList.add(value.createImmutable());
        value.setValue(new BigDecimal("4.2"));
        expectedList.add(value.createImmutable());
        value.setValue(new Float(0.1f));
        expectedList.add(value.createImmutable());
        value.setValue(new Double(0.2d));
        expectedList.add(value.createImmutable());
        assertEquals(expectedList, list.getContentsAsList());

        final Object otherList = doRoundTrip(list);
        assertEquals(list, otherList);
    }
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.