VerifyMode implements ResponseMode { @Override public PRPAIN201306UV02 processResponse(ResponseParams params) { PRPAIN201306UV02 response = params.response; AssertionType assertion = params.assertion; PRPAIN201305UV02 requestMsg = params.origRequest.getPRPAIN201305UV02(); return processResponse(requestMsg, response, assertion, params.origRequest.getNhinTargetSystem()); } VerifyMode(); @Override PRPAIN201306UV02 processResponse(ResponseParams params); @Override PRPAIN201306UV02 processResponse(PRPAIN201306UV02 response, AssertionType assertion, II localPatientId); PRPAIN201306UV02 processResponse(PRPAIN201305UV02 requestMsg, PRPAIN201306UV02 response,
        AssertionType assertion, NhinTargetSystemType target);  }
@Test public void testProcessResponse_ResponseParams() { JAXBElement<PRPAMT201301UV02Person> person = HL7PatientTransforms.create201301PatientPerson("Joe", "Smith", "M", null, null); PRPAMT201301UV02Patient patient = HL7PatientTransforms.create201301Patient(person, "1234", "1.1.1"); PRPAIN201305UV02 request = HL7PRPA201305Transforms.createPRPA201305(patient, "1.1", "2.2", "1.1.1"); ProxyPRPAIN201305UVProxySecuredRequestType prpainRequest = new ProxyPRPAIN201305UVProxySecuredRequestType(); prpainRequest.setPRPAIN201305UV02(request); prpainRequest.setNhinTargetSystem(null); PRPAIN201306UV02 response = HL7PRPA201306Transforms.createPRPA201306(patient, "2.2", "1.1.1", "1.1", "2.2.2", request); AssertionType assertion = new AssertionType(); ResponseParams params = new ResponseParams(); params.origRequest = prpainRequest; params.assertion = assertion; params.response = response; VerifyMode verifyMode = new VerifyMode() { @Override protected II patientExistsLocally(List<II> localPatientIds, AssertionType assertion, PRPAIN201306UV02 response, NhinTargetSystemType target) { return null; } }; PRPAIN201306UV02 verifyResponse = verifyMode.processResponse(params); assertEquals(response, verifyResponse); verifyMode = new VerifyMode() { @Override protected II patientExistsLocally(List<II> localPatientIds, AssertionType assertion, PRPAIN201306UV02 response, NhinTargetSystemType target) { II ii = new II(); ii.setExtension("extension"); ii.setRoot("root"); return ii; } @Override protected TrustMode getTrustMode() { return mockTrustMode; } }; context.checking(new Expectations() { { exactly(1).of(mockTrustMode).processResponse(with(any(PRPAIN201306UV02.class)), with(any(AssertionType.class)), with(any(II.class))); } }); verifyResponse = verifyMode.processResponse(params); assertEquals(response, verifyResponse); }
@Test public void testProcessResponse_LocalPatientId() { PRPAIN201306UV02 response = null; AssertionType assertion = null; II localPatId = new II(); VerifyMode verifyMode = new VerifyMode() { @Override protected II patientExistsLocally(List<II> localPatientIds, AssertionType assertion, PRPAIN201306UV02 response, NhinTargetSystemType target) { II ii = new II(); ii.setExtension("extension"); ii.setRoot("root"); return ii; } @Override protected TrustMode getTrustMode() { return mockTrustMode; } }; context.checking(new Expectations() { { exactly(1).of(mockTrustMode).processResponse(with(aNull(PRPAIN201306UV02.class)), with(aNull(AssertionType.class)), with(any(II.class))); } }); PRPAIN201306UV02 result = verifyMode.processResponse(response, assertion, localPatId); assertEquals(null, result); }