use of org.estatio.canonical.party.v1.PartyDto in project estatio by estatio.
the class PartyDtoFactory method newDto.
@Programmatic
public PartyDto newDto(final Party party) {
PartyDto dto = new PartyDto();
dto.setSelf(mappingHelper.oidDtoFor(party));
dto.setName(party.getName());
dto.setReference(party.getReference());
final SortedSet<CommunicationChannel> postalAddresses = communicationChannelRepository.findByOwnerAndType(party, CommunicationChannelType.POSTAL_ADDRESS);
final Optional<CommunicationChannel> postalAddressIfAny = postalAddresses.stream().filter(x -> x.isLegal()).findFirst();
if (postalAddressIfAny.isPresent()) {
dto.setLegalPostalAddress(mappingHelper.oidDtoFor(postalAddressIfAny.get()));
}
return dto;
}
use of org.estatio.canonical.party.v1.PartyDto in project estatio by estatio.
the class PartyDtoFactory_Test method happy_case.
@Test
public void happy_case() throws Exception {
// given
final Party p = new Organisation();
p.setReference("12345678");
p.setName("New Company");
// expecting
final OidDto partyOidDto = new OidDto();
context.checking(new Expectations() {
{
oneOf(mockDtoMappingHelper).oidDtoFor(p);
will(returnValue(partyOidDto));
oneOf(mockCommunicationChannelRepository).findByOwnerAndType(p, CommunicationChannelType.POSTAL_ADDRESS);
will(returnValue(Collections.emptySortedSet()));
}
});
// when
PartyDto partyDto = partyDtoFactory.newDto(p);
// and when roundtrip
String xml = jaxbService.toXml(partyDto);
PartyDto partyDtoAfter = jaxbService.fromXml(PartyDto.class, xml);
// then
assertThat(partyDtoAfter.getName()).isEqualTo(p.getName());
assertThat(partyDtoAfter.getReference()).isEqualTo(p.getReference());
}
Aggregations