Search in sources :

Example 1 with SendCertificateToRecipientResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType in project webcert by sklintyg.

the class SendCertificateToRecipientResponderStub method sendCertificateToRecipient.

@Override
@StubLatencyAware
@StubModeAware
public SendCertificateToRecipientResponseType sendCertificateToRecipient(String logicalAddress, SendCertificateToRecipientType parameters) {
    CertificateHolder fromStore = intygStore.getIntygForCertificateId(parameters.getIntygsId().getExtension());
    SendCertificateToRecipientResponseType responseType = new SendCertificateToRecipientResponseType();
    if (fromStore == null) {
        ResultType resultOfCall = new ResultType();
        resultOfCall.setResultCode(ResultCodeType.ERROR);
        resultOfCall.setErrorId(ErrorIdType.APPLICATION_ERROR);
        responseType.setResult(resultOfCall);
        return responseType;
    }
    intygStore.addStatus(parameters.getIntygsId().getExtension(), new CertificateStateHolder("FKASSA", CertificateState.SENT, LocalDateTime.now()));
    ResultType resultType = new ResultType();
    resultType.setResultCode(ResultCodeType.OK);
    responseType.setResult(resultType);
    return responseType;
}
Also used : SendCertificateToRecipientResponseType(se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType) CertificateStateHolder(se.inera.intyg.common.support.modules.support.api.CertificateStateHolder) CertificateHolder(se.inera.intyg.common.support.modules.support.api.CertificateHolder) ResultType(se.riv.clinicalprocess.healthcond.certificate.v3.ResultType) StubModeAware(se.inera.intyg.webcert.intygstjanststub.mode.StubModeAware) StubLatencyAware(se.inera.intyg.webcert.intygstjanststub.mode.StubLatencyAware)

Example 2 with SendCertificateToRecipientResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType in project webcert by sklintyg.

the class CertificateSendProcessorTest method testSendCertificateThrowsTemporaryOnTechnicalError.

@Test(expected = TemporaryException.class)
public void testSendCertificateThrowsTemporaryOnTechnicalError() throws Exception {
    // Given
    SendCertificateToRecipientResponseType response = createResponse(ResultCodeType.ERROR, ErrorIdType.TECHNICAL_ERROR);
    when(sendServiceClient.sendCertificate(INTYGS_ID1, PERSON_ID1, SKICKAT_AV, RECIPIENT1, LOGICAL_ADDRESS1)).thenReturn(response);
    // When
    certificateSendProcessor.process(SKICKAT_AV, INTYGS_ID1, PERSON_ID1, RECIPIENT1, LOGICAL_ADDRESS1);
    // Then
    verify(sendServiceClient).sendCertificate(INTYGS_ID1, PERSON_ID1, SKICKAT_AV, RECIPIENT1, LOGICAL_ADDRESS1);
}
Also used : SendCertificateToRecipientResponseType(se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType) Test(org.junit.Test)

Example 3 with SendCertificateToRecipientResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType in project webcert by sklintyg.

the class CertificateSendProcessorTest method testSendCertificateThrowsPermanentOnRevokedError.

@Test(expected = PermanentException.class)
public void testSendCertificateThrowsPermanentOnRevokedError() throws Exception {
    // Given
    SendCertificateToRecipientResponseType response = createResponse(ResultCodeType.ERROR, ErrorIdType.REVOKED);
    when(sendServiceClient.sendCertificate(INTYGS_ID1, PERSON_ID1, SKICKAT_AV, RECIPIENT1, LOGICAL_ADDRESS1)).thenReturn(response);
    // When
    certificateSendProcessor.process(SKICKAT_AV, INTYGS_ID1, PERSON_ID1, RECIPIENT1, LOGICAL_ADDRESS1);
    // Then
    verify(sendServiceClient).sendCertificate(INTYGS_ID1, PERSON_ID1, SKICKAT_AV, RECIPIENT1, LOGICAL_ADDRESS1);
}
Also used : SendCertificateToRecipientResponseType(se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType) Test(org.junit.Test)

Example 4 with SendCertificateToRecipientResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType in project webcert by sklintyg.

the class SendCertificateServiceClientImpl method sendCertificate.

@Override
public SendCertificateToRecipientResponseType sendCertificate(String intygsId, String personId, String skickatAvJson, String recipient, String logicalAddress) {
    validateArgument(intygsId, "Cannot send certificate, argument 'intygsId' is null or empty.");
    validateArgument(personId, "Cannot send certificate, argument 'personId' is null or empty.");
    validateArgument(skickatAvJson, "Cannot send certificate, argument 'skickatAvJson' is null or empty.");
    validateArgument(recipient, "Cannot send certificate, argument 'recipient' is null or empty.");
    validateArgument(logicalAddress, "Cannot send certificate, argument 'logicalAddress' is null or empty.");
    HoSPersonal skickatAv = parseJson(skickatAvJson);
    SendCertificateToRecipientType request = SendCertificateToRecipientTypeConverter.convert(intygsId, personId, skickatAv, recipient);
    return sendService.sendCertificateToRecipient(logicalAddress, request);
}
Also used : HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) SendCertificateToRecipientType(se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientType)

Example 5 with SendCertificateToRecipientResponseType

use of se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType in project webcert by sklintyg.

the class SendCertificateServiceClientTest method testSendCertificateOk.

@Test
public void testSendCertificateOk() {
    when(response.getResult()).thenReturn(buildResultOfCall(ResultCodeType.OK));
    when(sendService.sendCertificateToRecipient(anyString(), any(SendCertificateToRecipientType.class))).thenReturn(response);
    SendCertificateToRecipientResponseType resp = testee.sendCertificate(INTYGS_ID, PERSON_ID, SKICKAT_AV_JSON, RECIPIENT, LOGICAL_ADDRESS);
    assertEquals(ResultCodeType.OK, resp.getResult().getResultCode());
}
Also used : SendCertificateToRecipientType(se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientType) SendCertificateToRecipientResponseType(se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType) Test(org.junit.Test)

Aggregations

SendCertificateToRecipientResponseType (se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientResponseType)12 Test (org.junit.Test)8 ResultType (se.riv.clinicalprocess.healthcond.certificate.v3.ResultType)4 SendCertificateToRecipientType (se.riv.clinicalprocess.healthcond.certificate.sendCertificateToRecipient.v2.SendCertificateToRecipientType)2 WebServiceException (javax.xml.ws.WebServiceException)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 Fk7263Utlatande (se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande)1 HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)1 Relation (se.inera.intyg.common.support.model.common.internal.Relation)1 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)1 CertificateHolder (se.inera.intyg.common.support.modules.support.api.CertificateHolder)1 CertificateStateHolder (se.inera.intyg.common.support.modules.support.api.CertificateStateHolder)1 Personnummer (se.inera.intyg.schemas.contract.Personnummer)1 WebcertCertificateRelation (se.inera.intyg.webcert.common.model.WebcertCertificateRelation)1 PermanentException (se.inera.intyg.webcert.common.sender.exception.PermanentException)1 TemporaryException (se.inera.intyg.webcert.common.sender.exception.TemporaryException)1 StubLatencyAware (se.inera.intyg.webcert.intygstjanststub.mode.StubLatencyAware)1 StubModeAware (se.inera.intyg.webcert.intygstjanststub.mode.StubModeAware)1 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)1 IntygServiceResult (se.inera.intyg.webcert.web.service.intyg.dto.IntygServiceResult)1