@Test public void testReceiveAnswerValidationError() { ReceiveMedicalCertificateAnswerType request = createRequest("RecieveQuestionAnswerResponders/answer-from-fk-integrated.xml"); request.getAnswer().setSvar(null); ReceiveMedicalCertificateAnswerResponseType response = receiveAnswerResponder.receiveMedicalCertificateAnswer(null, request); verifyNoInteractions(mockNotificationService); verifyNoInteractions(mockFragaSvarService); assertNotNull(response); assertEquals(ResultCodeEnum.ERROR, response.getResult().getResultCode()); assertEquals(ErrorIdEnum.VALIDATION_ERROR, response.getResult().getErrorId()); assertEquals("Missing svar element.", response.getResult().getErrorText()); }
@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);  }