/** * give a expected xml string and make sure it can be shortly deserialized * * @throws Exception */ @Test public void shouldPersonShortDeserialization() throws Exception { // prepare the necessary data /* * Because "XXXShortConverter.unmarshal(HierarchicalStreamReader, UnmarshallingContext)" has operations accessing data in database, * We also need to use the "PersonShortSerializationTest.xml" here */ initializeInMemoryDatabase(); executeDataSet("org/openmrs/module/xstream/include/PersonShortSerializationTest.xml"); authenticate(); StringBuilder xmlBuilder = new StringBuilder(); xmlBuilder.append( "<personAddress id=\"1\" uuid=\"3350d0b5-821c-4e5e-ad1d-a9bce331e118\" voided=\"false\">\n"); xmlBuilder.append(" <creator id=\"2\" uuid=\"6adb7c42-cfd2-4301-b53b-ff17c5654ff7\"/>\n"); xmlBuilder.append( " <dateCreated class=\"sql-timestamp\" id=\"3\">2005-09-22 00:00:00 CST</dateCreated>\n"); xmlBuilder.append(" <personAddressId>2</personAddressId>\n"); xmlBuilder.append(" <person id=\"4\" uuid=\"da7f524f-27ce-4bb2-86d6-6d1d05312bd5\"/>\n"); xmlBuilder.append(" <preferred>false</preferred>\n"); xmlBuilder.append(" <address1>1050 Wishard Blvd.</address1>\n"); xmlBuilder.append(" <address2>RG5</address2>\n"); xmlBuilder.append(" <cityVillage>Indianapolis</cityVillage>\n"); xmlBuilder.append(" <stateProvince>IN</stateProvince>\n"); xmlBuilder.append(" <country>USA</country>\n"); xmlBuilder.append(" <postalCode>46202</postalCode>\n"); xmlBuilder.append("</personAddress>\n"); PersonAddress pa = Context.getSerializationService() .deserialize(xmlBuilder.toString(), PersonAddress.class, XStreamShortSerializer.class); assertEquals("da7f524f-27ce-4bb2-86d6-6d1d05312bd5", pa.getPerson().getUuid()); }