use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.
the class SendMessageToCareResponderImplTest method testSendRequestToServiceFailedNotFound.
@Test
public void testSendRequestToServiceFailedNotFound() throws WebCertServiceException {
when(arendeService.processIncomingMessage(any())).thenThrow(new WebCertServiceException(WebCertServiceErrorCodeEnum.DATA_NOT_FOUND, ""));
SendMessageToCareResponseType response = responder.sendMessageToCare(DEFAULT_LOGICAL_ADDRESS, createNewRequest());
assertNotNull(response.getResult());
assertEquals(ResultCodeType.ERROR, response.getResult().getResultCode());
assertEquals(ErrorIdType.VALIDATION_ERROR, response.getResult().getErrorId());
}
use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.
the class SendMessageToCareResponderImplTest method testSendRequestToServiceFailedNotSigned.
@Test
public void testSendRequestToServiceFailedNotSigned() throws WebCertServiceException {
when(arendeService.processIncomingMessage(any())).thenThrow(new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, ""));
SendMessageToCareResponseType response = responder.sendMessageToCare(DEFAULT_LOGICAL_ADDRESS, createNewRequest());
assertNotNull(response.getResult());
assertEquals(ResultCodeType.ERROR, response.getResult().getResultCode());
assertEquals(ErrorIdType.VALIDATION_ERROR, response.getResult().getErrorId());
}
use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.
the class ArendeConverterTest method testDecorateArendeFromUtkastHsaNotResponding.
@Test
public void testDecorateArendeFromUtkastHsaNotResponding() {
Utkast utkast = new Utkast();
utkast.setIntygsTyp("intygstyp");
utkast.setEnhetsId("enhetsid");
utkast.setSignatur(mock(Signatur.class));
when(utkast.getSignatur().getSigneradAv()).thenReturn("signeratav");
when(hsaEmployeeService.getEmployee(anyString(), eq(null))).thenThrow(new WebServiceException());
try {
ArendeConverter.decorateArendeFromUtkast(new Arende(), utkast, LocalDateTime.now(), hsaEmployeeService);
fail("Should throw");
} catch (WebCertServiceException e) {
assertEquals(WebCertServiceErrorCodeEnum.EXTERNAL_SYSTEM_PROBLEM, e.getErrorCode());
}
}
use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.
the class IntygModuleApiController method revokeSignedIntyg.
/**
* Issues a request to Intygstjanst to revoke the signed intyg.
*
* @param intygsId The id of the intyg to revoke
* @param param A JSON struct containing an optional message
*/
@POST
@Path("/{intygsTyp}/{intygsId}/aterkalla")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response revokeSignedIntyg(@PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String intygsId, RevokeSignedIntygParameter param) {
validateRevokeAuthority(intygsTyp);
if (authoritiesValidator.given(getWebCertUserService().getUser(), intygsTyp).features(AuthoritiesConstants.FEATURE_MAKULERA_INTYG_KRAVER_ANLEDNING).isVerified() && !param.isValid()) {
LOG.warn("Request to revoke '{}' is not valid", intygsId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload");
}
IntygServiceResult result = revokeIntyg(intygsTyp, intygsId, param);
return Response.ok(result).build();
}
use of se.inera.intyg.webcert.common.service.exception.WebCertServiceException in project webcert by sklintyg.
the class IntygModuleApiController method createReplacement.
/**
* Create a copy that is a replacement (ersättning) of an existing certificate.
*/
@POST
@Path("/{intygsTyp}/{intygsId}/ersatt")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON + UTF_8_CHARSET)
public Response createReplacement(CopyIntygRequest request, @PathParam("intygsTyp") String intygsTyp, @PathParam("intygsId") String orgIntygsId) {
validateReplaceAuthority(intygsTyp);
LOG.debug("Attempting to create a replacement of {} with id '{}'", intygsTyp, orgIntygsId);
if (!request.isValid()) {
LOG.error("Request to create replacement of '{}' is not valid", orgIntygsId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INTERNAL_PROBLEM, "Missing vital arguments in payload");
}
CreateReplacementCopyRequest serviceRequest = createReplacementCopyRequest(orgIntygsId, intygsTyp, request);
CreateReplacementCopyResponse serviceResponse = copyUtkastService.createReplacementCopy(serviceRequest);
LOG.debug("Created a new replacement draft with id: '{}' and type: {}, replacing certificate with id '{}'.", serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType(), orgIntygsId);
CopyIntygResponse response = new CopyIntygResponse(serviceResponse.getNewDraftIntygId(), serviceResponse.getNewDraftIntygType());
return Response.ok().entity(response).build();
}
Aggregations