RecipientTransformer { public Recipient fromEbXML(String slotValue) { if (slotValue == null || slotValue.isEmpty()) { return null; } Recipient recipient = new Recipient(); String[] parts = slotValue.split("\\|"); recipient.setOrganization(Hl7v2Based.parse(parts[0], Organization.class)); if (parts.length > 1) { recipient.setPerson(Hl7v2Based.parse(parts[1], Person.class)); } if (parts.length > 2) { recipient.setTelecom(Hl7v2Based.parse(parts[2], Telecom.class)); } return recipient; }  String toEbXML(Recipient recipient); Recipient fromEbXML(String slotValue);  }
@Test public void testFromEbXML() { assertEquals(recipient, transformer.fromEbXML("orgName^^^^^namespace1&uni1&uniType1^^^^orgId|personId^familyName^givenName^second^suffix^prefix^degree^^namespace2&uni2&uniType2|^^Fidonet^2:465/193.8")); }
@Test public void testFromEbXMLNoPerson() { recipient.setPerson(null); assertEquals(recipient, transformer.fromEbXML("orgName^^^^^namespace1&uni1&uniType1^^^^orgId||^^Fidonet^2:465/193.8")); }
@Test public void testFromEbXMLNoOrganization() { recipient.setOrganization(null); assertEquals(recipient, transformer.fromEbXML("|personId^familyName^givenName^second^suffix^prefix^degree^^namespace2&uni2&uniType2|^^Fidonet^2:465/193.8")); }
@Test public void testFromEbXMLNoTelecom() { recipient.setTelecom(null); assertEquals(recipient, transformer.fromEbXML("orgName^^^^^namespace1&uni1&uniType1^^^^orgId|personId^familyName^givenName^second^suffix^prefix^degree^^namespace2&uni2&uniType2")); }
@Test public void testFromEbXMLEmpty() { assertNull(transformer.fromEbXML("")); }
@Test public void testFromEbXMLNull() { assertNull(transformer.fromEbXML(null)); }