RecipientTransformer { public String toEbXML(Recipient recipient) { if (recipient == null) { return null; } String person = Hl7v2Based.render(recipient.getPerson()); String organization = Hl7v2Based.render(recipient.getOrganization()); String telecom = Hl7v2Based.render(recipient.getTelecom()); if ((person == null) && (organization == null) && (telecom == null)) { return null; } StringBuilder sb = new StringBuilder(); if (organization != null) { sb.append(organization); } if ((person != null) || (telecom != null)) { sb.append('|'); if (person != null) { sb.append(person); } if (telecom != null) { sb.append('|').append(telecom); } } return sb.toString(); }  String toEbXML(Recipient recipient); Recipient fromEbXML(String slotValue);  }
@Test public void testToEbXML() { String ebXML = transformer.toEbXML(recipient); assertNotNull(ebXML); assertEquals("orgName^^^^^&uni1&uniType1^^^^orgId|personId^familyName^givenName^second^suffix^prefix^degree^^&uni2&uniType2|^^Fidonet^2:465/193.8", ebXML); }
@Test public void testToEbXMLNoPerson() { recipient.setPerson(null); String ebXML = transformer.toEbXML(recipient); assertNotNull(ebXML); assertEquals("orgName^^^^^&uni1&uniType1^^^^orgId||^^Fidonet^2:465/193.8", ebXML); }
@Test public void testToEbXMLNoOrganization() { recipient.setOrganization(null); String ebXML = transformer.toEbXML(recipient); assertNotNull(ebXML); assertEquals("|personId^familyName^givenName^second^suffix^prefix^degree^^&uni2&uniType2|^^Fidonet^2:465/193.8", ebXML); }
@Test public void testToEbXMLNoTelecom() { recipient.setTelecom(null); String ebXML = transformer.toEbXML(recipient); assertNotNull(ebXML); assertEquals("orgName^^^^^&uni1&uniType1^^^^orgId|personId^familyName^givenName^second^suffix^prefix^degree^^&uni2&uniType2", ebXML); }
@Test public void testToEbXMLEmpty() { assertNull(transformer.toEbXML(new Recipient())); }
@Test public void testToEbXMLNull() { assertNull(transformer.toEbXML(null)); }