AckBuilder { public static MCCIIN000002UV01 buildAck(PRPAIN201301UV02 originalMessage) { II receiverId = null; II senderId; String acknowledgementTypeCode = "CA"; II originalMessageId = null; if (originalMessage != null) { if (originalMessage.getSender() != null && originalMessage.getSender().getDevice() != null && CollectionUtils.isNotEmpty(originalMessage.getSender().getDevice().getId())) { receiverId = originalMessage.getSender().getDevice().getId().get(0); } originalMessageId = originalMessage.getId(); } senderId = IIHelper.IIFactory(Configuration.getMyCommunityId(), null); return buildAck(receiverId, senderId, acknowledgementTypeCode, originalMessageId); }  static MCCIIN000002UV01 buildAck(PRPAIN201301UV02 originalMessage); static MCCIIN000002UV01 buildAck(II receiverId, II senderId, String acknowledgementTypeCode,
        II originalMessageId);  }
@Test public void testBuildAck() { AckBuilder ackBuilder = new AckBuilder(); MCCIIN000002UV01 ack = ackBuilder.buildAck(createPRPAIN201301UV02Message()); assertEquals(ack.getReceiver().get(0).getDevice().getId().get(0).getAssigningAuthorityName(),"CONNECT"); assertEquals(ack.getReceiver().get(0).getDevice().getId().get(0).getExtension(), "1.16.17.19"); }
@Test public void testBuildAckWhenMessageNull() { AckBuilder ackBuilder = new AckBuilder(); PRPAIN201301UV02 originalMessage = null; MCCIIN000002UV01 ack = ackBuilder.buildAck(originalMessage); assertNull(ack.getReceiver().get(0).getDevice().getId().get(0)); }
@Test public void testBuildAckWhenSenderDeviceNull() { AckBuilder ackBuilder = new AckBuilder(); PRPAIN201301UV02 originalMessage = new PRPAIN201301UV02(); MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender(); MCCIMT000100UV01Device senderDevice = null; sender.setDevice(senderDevice); originalMessage.setSender(sender); MCCIIN000002UV01 ack = ackBuilder.buildAck(originalMessage); assertNull(ack.getReceiver().get(0).getDevice().getId().get(0)); }
@Test public void testBuildAckWhenSenderNull() { AckBuilder ackBuilder = new AckBuilder(); PRPAIN201301UV02 originalMessage = new PRPAIN201301UV02(); MCCIIN000002UV01 ack = ackBuilder.buildAck(originalMessage); assertNull(ack.getReceiver().get(0).getDevice().getId().get(0)); }
@Test public void testBuildAckWhenSenderDeviceIdNull() { AckBuilder ackBuilder = new AckBuilder(); PRPAIN201301UV02 originalMessage = new PRPAIN201301UV02(); MCCIMT000100UV01Sender sender = new MCCIMT000100UV01Sender(); MCCIMT000100UV01Device senderDevice = new MCCIMT000100UV01Device(); sender.setDevice(senderDevice); originalMessage.setSender(sender); MCCIIN000002UV01 ack = ackBuilder.buildAck(originalMessage); assertNull(ack.getReceiver().get(0).getDevice().getId().get(0)); }