rollback();
}
public void testParseRootInheritance()
{
ObjectInput in;
TransferObject root;
// Parse Contact as Object_Inherit_Contact
in = new ObjectInput(m_contact);
root = m_parser.parse(in, m_contactMsg);
assertEquals("Object_Inherit_Contact", root.getClassName());
assertEquals("Joe", root.getValue("firstName"));
assertFalse(root.hasValue("lastName"));
// Parse Patient as Object_Inherit_Patient
in = new ObjectInput(m_patient);
root = m_parser.parse(in, m_patientMsg);
assertEquals("Object_Inherit_Patient", root.getClassName());
assertEquals("Sarah", root.getValue("firstName"));
assertEquals("Johnson", root.getValue("lastName"));
assertTrue(root.hasValue("middleName"));
assertNull(root.getValue("middleName"));
// Parse Patient as Object_Inherit_Contact (polymorphically becomes Object_Inherit_Patient)
in = new ObjectInput(m_patient);
root = m_parser.parse(in, m_contactMsg);
assertEquals("Object_Inherit_Patient", root.getClassName());
assertEquals("Sarah", root.getValue("firstName"));
assertEquals("Johnson", root.getValue("lastName"));
assertTrue(root.hasValue("middleName"));
assertNull(root.getValue("middleName"));
// Parse Surgeon as Object_Inherit_Contact (polymorphically becomes Object_Inherit_Surgeon)
in = new ObjectInput(m_surgeon);
root = m_parser.parse(in, m_contactMsg);
assertEquals("Object_Inherit_Surgeon", root.getClassName());
assertEquals("Joshua", root.getValue("firstName"));
assertEquals("Zig", root.getValue("lastName"));
assertEquals("ECG", root.getValue("speciality"));
assertFalse(root.hasValue("middleName"));
// Parse Doctor as Object_Inherit_Contact (stays as Object_Inherit_Contact)
in = new ObjectInput(m_doctor);
root = m_parser.parse(in, m_contactMsg);
assertEquals("Object_Inherit_Contact", root.getClassName());
assertEquals("Johan", root.getValue("firstName"));
assertFalse(root.hasValue("lastName"));
// Parse Doctor as Object_Inherit_Patient (fails)
in = new ObjectInput(m_doctor);
try
{
root = m_parser.parse(in, m_patientMsg);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
ex = (IntegrationException)ex.getCause();
assertEquals("err.integration.object.missingMapping", ex.getErrorCode());
}
// Parse Surgeon as Object_Inherit_Patient (fails)
in = new ObjectInput(m_surgeon);
try
{
root = m_parser.parse(in, m_patientMsg);
fail("Expected IntegrationException");
}
catch (IntegrationException ex)
{
ex = (IntegrationException)ex.getCause();
assertEquals("err.integration.object.missingMapping", ex.getErrorCode());
}
// Parse Patient as Object_Inherit_Contact_NonPoly (not polymorphic, so does not become Patient2)
in = new ObjectInput(m_patient);
root = m_parser.parse(in, m_contactNonPolyMsg);
assertEquals("Object_Inherit_Contact_NonPoly", root.getClassName());
assertEquals("Sarah", root.getValue("firstName"));
assertFalse(root.hasValue("lastName"));
// Parse Patient as Object_Inherit_Patient2
in = new ObjectInput(m_patient);
root = m_parser.parse(in, m_patient2Msg);
assertEquals("Object_Inherit_Patient2", root.getClassName());
assertEquals("Sarah", root.getValue("firstName"));
assertEquals("Johnson", root.getValue("lastName"));