@Test public void testReceiveAnswerOK() { FragaSvar fragaSvar = buildFraga(QUESTION_ID, "That is the question", Amne.ARBETSTIDSFORLAGGNING, LocalDateTime.now(), INTEGRERAD_ENHET, Status.PENDING_INTERNAL_ACTION); when(mockFragaSvarService.processIncomingAnswer(anyLong(), anyString(), any(LocalDateTime.class))).thenReturn(fragaSvar); ReceiveMedicalCertificateAnswerType request = createRequest("RecieveQuestionAnswerResponders/answer-from-fk-integrated.xml"); ReceiveMedicalCertificateAnswerResponseType response = receiveAnswerResponder.receiveMedicalCertificateAnswer(null, request); verify(mockNotificationService).sendNotificationForAnswerRecieved(any(FragaSvar.class)); verify(certificateEventService) .createCertificateEvent(anyString(), anyString(), eq(EventCode.NYSVFM), anyString()); assertNotNull(response); assertEquals(ResultCodeEnum.OK, response.getResult().getResultCode()); }
@Override public ReceiveMedicalCertificateAnswerResponseType receiveMedicalCertificateAnswer( AttributedURIType logicalAddress, ReceiveMedicalCertificateAnswerType request) { ReceiveMedicalCertificateAnswerResponseType response = new ReceiveMedicalCertificateAnswerResponseType(); List<String> validationMessages = QuestionAnswerValidator.validate(request); if (!validationMessages.isEmpty()) { response.setResult(ResultOfCallUtil.failResult(Joiner.on(",").join(validationMessages))); return response; } AnswerFromFkType answerType = request.getAnswer(); Long referensId; try { referensId = Long.parseLong(answerType.getVardReferensId()); } catch (NumberFormatException e) { throw new IllegalArgumentException("No question found with internal ID " + request.getAnswer().getVardReferensId(), e); } response.setResult(ResultOfCallUtil.okResult()); sendNotification(processAnswer(referensId, answerType.getSvar())); certificateEventService.createCertificateEvent(referensId.toString(), "FK", EventCode.NYSVFM, String.format("received medical certificate answer: %s}", answerType.getSvar())); return response; }
ReceiveAnswerResponderImpl implements ReceiveMedicalCertificateAnswerResponderInterface { @Override public ReceiveMedicalCertificateAnswerResponseType receiveMedicalCertificateAnswer( AttributedURIType logicalAddress, ReceiveMedicalCertificateAnswerType request) { ReceiveMedicalCertificateAnswerResponseType response = new ReceiveMedicalCertificateAnswerResponseType(); List<String> validationMessages = QuestionAnswerValidator.validate(request); if (!validationMessages.isEmpty()) { response.setResult(ResultOfCallUtil.failResult(Joiner.on(",").join(validationMessages))); return response; } AnswerFromFkType answerType = request.getAnswer(); Long referensId; try { referensId = Long.parseLong(answerType.getVardReferensId()); } catch (NumberFormatException e) { throw new IllegalArgumentException("No question found with internal ID " + request.getAnswer().getVardReferensId(), e); } response.setResult(ResultOfCallUtil.okResult()); sendNotification(processAnswer(referensId, answerType.getSvar())); certificateEventService.createCertificateEvent(referensId.toString(), "FK", EventCode.NYSVFM, String.format("received medical certificate answer: %s}", answerType.getSvar())); return response; } }
ReceiveAnswerResponderImpl implements ReceiveMedicalCertificateAnswerResponderInterface { @Override public ReceiveMedicalCertificateAnswerResponseType receiveMedicalCertificateAnswer( AttributedURIType logicalAddress, ReceiveMedicalCertificateAnswerType request) { ReceiveMedicalCertificateAnswerResponseType response = new ReceiveMedicalCertificateAnswerResponseType(); List<String> validationMessages = QuestionAnswerValidator.validate(request); if (!validationMessages.isEmpty()) { response.setResult(ResultOfCallUtil.failResult(Joiner.on(",").join(validationMessages))); return response; } AnswerFromFkType answerType = request.getAnswer(); Long referensId; try { referensId = Long.parseLong(answerType.getVardReferensId()); } catch (NumberFormatException e) { throw new IllegalArgumentException("No question found with internal ID " + request.getAnswer().getVardReferensId(), e); } response.setResult(ResultOfCallUtil.okResult()); sendNotification(processAnswer(referensId, answerType.getSvar())); certificateEventService.createCertificateEvent(referensId.toString(), "FK", EventCode.NYSVFM, String.format("received medical certificate answer: %s}", answerType.getSvar())); return response; }  }
ReceiveAnswerResponderImpl implements ReceiveMedicalCertificateAnswerResponderInterface { @Override public ReceiveMedicalCertificateAnswerResponseType receiveMedicalCertificateAnswer( AttributedURIType logicalAddress, ReceiveMedicalCertificateAnswerType request) { ReceiveMedicalCertificateAnswerResponseType response = new ReceiveMedicalCertificateAnswerResponseType(); List<String> validationMessages = QuestionAnswerValidator.validate(request); if (!validationMessages.isEmpty()) { response.setResult(ResultOfCallUtil.failResult(Joiner.on(",").join(validationMessages))); return response; } AnswerFromFkType answerType = request.getAnswer(); Long referensId; try { referensId = Long.parseLong(answerType.getVardReferensId()); } catch (NumberFormatException e) { throw new IllegalArgumentException("No question found with internal ID " + request.getAnswer().getVardReferensId(), e); } response.setResult(ResultOfCallUtil.okResult()); sendNotification(processAnswer(referensId, answerType.getSvar())); certificateEventService.createCertificateEvent(referensId.toString(), "FK", EventCode.NYSVFM, String.format("received medical certificate answer: %s}", answerType.getSvar())); return response; }  @Override ReceiveMedicalCertificateAnswerResponseType receiveMedicalCertificateAnswer(
        AttributedURIType logicalAddress, ReceiveMedicalCertificateAnswerType request); }
ReceiveAnswerResponderImpl implements ReceiveMedicalCertificateAnswerResponderInterface { @Override public ReceiveMedicalCertificateAnswerResponseType receiveMedicalCertificateAnswer( AttributedURIType logicalAddress, ReceiveMedicalCertificateAnswerType request) { ReceiveMedicalCertificateAnswerResponseType response = new ReceiveMedicalCertificateAnswerResponseType(); List<String> validationMessages = QuestionAnswerValidator.validate(request); if (!validationMessages.isEmpty()) { response.setResult(ResultOfCallUtil.failResult(Joiner.on(",").join(validationMessages))); return response; } AnswerFromFkType answerType = request.getAnswer(); Long referensId; try { referensId = Long.parseLong(answerType.getVardReferensId()); } catch (NumberFormatException e) { throw new IllegalArgumentException("No question found with internal ID " + request.getAnswer().getVardReferensId(), e); } response.setResult(ResultOfCallUtil.okResult()); sendNotification(processAnswer(referensId, answerType.getSvar())); certificateEventService.createCertificateEvent(referensId.toString(), "FK", EventCode.NYSVFM, String.format("received medical certificate answer: %s}", answerType.getSvar())); return response; }  @Override ReceiveMedicalCertificateAnswerResponseType receiveMedicalCertificateAnswer(
        AttributedURIType logicalAddress, ReceiveMedicalCertificateAnswerType request);  }