use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01PlayingEntity in project integration-adaptor-111 by nhsconnect.
the class LocationMapperTest method shouldMapRoleToLocation.
@Test
public void shouldMapRoleToLocation() {
POCDMT000002UK01ParticipantRole participantRole = mock(POCDMT000002UK01ParticipantRole.class);
POCDMT000002UK01PlayingEntity playingEntity = mock(POCDMT000002UK01PlayingEntity.class);
AD itkAddress = mock(AD.class);
PN personName = mock(PN.class);
when(participantRole.sizeOfAddrArray()).thenReturn(1);
when(participantRole.isSetPlayingEntity()).thenReturn(true);
when(participantRole.getAddrArray(anyInt())).thenReturn(itkAddress);
when(participantRole.getPlayingEntity()).thenReturn(playingEntity);
when(playingEntity.getNameArray(anyInt())).thenReturn(personName);
when(humanNameMapper.mapHumanName(isA(PN.class))).thenReturn(humanName);
when(addressMapper.mapAddress(isA(AD.class))).thenReturn(address);
when(humanName.getText()).thenReturn(NAME);
when(nodeUtil.getNodeValueString(playingEntity.getDesc())).thenReturn(DESCRIPTION);
when(resourceUtil.newRandomUuid()).thenReturn(new IdType(RANDOM_UUID));
Location location = locationMapper.mapRoleToLocation(participantRole);
assertThat(location.getAddress()).isEqualTo(address);
assertThat(location.getName()).isEqualTo(NAME);
assertThat(location.getDescription()).isEqualTo(DESCRIPTION);
assertThat(location.getIdElement().getValue()).isEqualTo(RANDOM_UUID);
}
use of uk.nhs.connect.iucds.cda.ucr.POCDMT000002UK01PlayingEntity in project integration-adaptor-111 by nhsconnect.
the class LocationMapper method mapRoleToLocation.
public Location mapRoleToLocation(POCDMT000002UK01ParticipantRole role) {
Location location = new Location();
location.setIdElement(resourceUtil.newRandomUuid());
if (role.sizeOfAddrArray() > 0) {
location.setAddress(addressMapper.mapAddress(role.getAddrArray(0)));
}
if (role.isSetPlayingEntity()) {
POCDMT000002UK01PlayingEntity playingEntity = role.getPlayingEntity();
location.setName(humanNameMapper.mapHumanName(playingEntity.getNameArray(0)).getText());
location.setDescription(nodeUtil.getNodeValueString(playingEntity.getDesc()));
}
return location;
}
Aggregations