@Test
    @SuppressWarnings("deprecation")
    public void testCompareToDoesNotMutateStateBug6394548() {
        StructDataType type = new StructDataType("test");
        // NOTE: non-increasing ID order!
        type.addField(new Field("int", 2, DataType.INT));
        type.addField(new Field("flt", 1, DataType.FLOAT));
        type.addField(new Field("str", 0, DataType.STRING));

        Struct a = new Struct(type);
        a.setFieldValue("int", new IntegerFieldValue(123));
        a.setFieldValue("flt", new DoubleFieldValue(45.6));
        a.setFieldValue("str", new StringFieldValue("hello world"));
        Struct b = new Struct(type);
        b.setFieldValue("int", new IntegerFieldValue(100));
        b.setFieldValue("flt", new DoubleFieldValue(45.6));
        b.setFieldValue("str", new StringFieldValue("hello world"));

        String xmlBefore = a.toXml();
        int hashBefore = a.hashCode();

        assertEquals(1, a.compareTo(b));

        assertEquals(xmlBefore, a.toXml());
        assertEquals(hashBefore, a.hashCode());
    }
@author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a>
document/src/test/java/com/yahoo/document/datatypes/StructTestCase.java