AdhocQueryTransformHelper { public static CheckPolicyRequestType transformAdhocQueryToCheckPolicy(AdhocQueryRequestEventType event) { LOG.debug("begin transformAdhocQueryToCheckPolicy"); CheckPolicyRequestType result = null; if (event != null && InboundOutboundChecker.isInbound(event.getDirection())) { result = transformAdhocQueryInboundToCheckPolicy(event); } if (event != null && InboundOutboundChecker.isOutbound(event.getDirection())) { result = transformAdhocQueryOutboundToCheckPolicy(event); } LOG.debug("end transformAdhocQueryToCheckPolicy"); return result; }  static CheckPolicyRequestType transformAdhocQueryToCheckPolicy(AdhocQueryRequestEventType event); static CheckPolicyRequestType transformAdhocQueryResponseToCheckPolicy(AdhocQueryResultEventType event); static String extractPatientIdentifierId(AdhocQueryRequest docQuery); static String extractPatientIdentifierAssigningAuthority(AdhocQueryRequest docQuery);  }
@Test public void testTransformAdhocQueryToCheckPolicy_RequestInbound() { String direction = "DocumentQueryIn"; AdhocQueryRequestEventType eventA = new AdhocQueryRequestEventType(); eventA.setDirection("inbound"); AdhocQueryRequestMessageType msg = new AdhocQueryRequestMessageType(); AdhocQueryRequest adhocQueryRequest = new AdhocQueryRequest(); SlotType1 slotType1 = new SlotType1(); slotType1.setName("$XDSDocumentEntryPatientId"); ValueListType valueListType = new ValueListType(); valueListType.getValue().add("1111.4444^^^&amp;26.489.22&amp;ISO"); slotType1.setValueList(valueListType); AdhocQueryType adhocQueryType = new AdhocQueryType(); adhocQueryType.getSlot().add(slotType1); adhocQueryRequest.setAdhocQuery(adhocQueryType); msg.setAdhocQueryRequest(adhocQueryRequest); AssertionType assertionTypeTest = new AssertionType(); assertionTypeTest.setMessageId(MESSAGE_ID); HomeCommunityType homeCom = new HomeCommunityType(); homeCom.setHomeCommunityId(TEST_HC_VAL); assertionTypeTest.setHomeCommunity(homeCom); msg.setAssertion(assertionTypeTest); eventA.setMessage(msg); CheckPolicyRequestType result = adhocQueryTransformHelp.transformAdhocQueryToCheckPolicy(eventA); verifycheckPolicy_Request(result, direction); }
@Test public void testTransformAdhocQueryToCheckPolicy_RequestOutbound() { String direction = "DocumentQueryOut"; AdhocQueryRequestEventType eventA = new AdhocQueryRequestEventType(); eventA.setDirection("outbound"); AdhocQueryRequestMessageType msg = new AdhocQueryRequestMessageType(); AdhocQueryRequest adhocQueryRequest = new AdhocQueryRequest(); SlotType1 slotType1 = new SlotType1(); slotType1.setName("$XDSDocumentEntryPatientId"); ValueListType valueListType = new ValueListType(); valueListType.getValue().add("1111.4444^^^&amp;26.489.22&amp;ISO"); slotType1.setValueList(valueListType); AdhocQueryType adhocQueryType = new AdhocQueryType(); adhocQueryType.getSlot().add(slotType1); adhocQueryRequest.setAdhocQuery(adhocQueryType); msg.setAdhocQueryRequest(adhocQueryRequest); AssertionType assertionTypeTest = new AssertionType(); assertionTypeTest.setMessageId(MESSAGE_ID); HomeCommunityType homeCom = new HomeCommunityType(); homeCom.setHomeCommunityId(TEST_HC_VAL); assertionTypeTest.setHomeCommunity(homeCom); msg.setAssertion(assertionTypeTest); eventA.setMessage(msg); CheckPolicyRequestType result = adhocQueryTransformHelp.transformAdhocQueryToCheckPolicy(eventA); verifycheckPolicy_Request(result, direction); }
@Test public void testTransformAdhocQueryToCheckPolicy_InValidDirection() { AdhocQueryRequestEventType eventA = new AdhocQueryRequestEventType(); eventA.setDirection("in_outbound"); CheckPolicyRequestType result = adhocQueryTransformHelp.transformAdhocQueryToCheckPolicy(eventA); assertNull("We should expect null checkPolicyEngine ", result); eventA.setDirection(null); assertNull(adhocQueryTransformHelp.transformAdhocQueryToCheckPolicy(eventA)); }