use of se.inera.intyg.common.support.modules.support.api.exception.ModuleException in project webcert by sklintyg.
the class RouteTest method testTransformationException.
@Test
public void testTransformationException() throws Exception {
// Given
when(mockInternalToNotification.createCertificateStatusUpdateForCareType(any())).thenThrow(new ModuleException("Testing runtime exception"));
notificationWSClient.expectedMessageCount(0);
notificationWSClientV3.expectedMessageCount(0);
permanentErrorHandlerEndpoint.expectedMessageCount(1);
temporaryErrorHandlerEndpoint.expectedMessageCount(0);
// When
producerTemplate.sendBody(createNotificationMessage(null));
// Then
assertIsSatisfied(notificationWSClient);
assertIsSatisfied(notificationWSClientV3);
assertIsSatisfied(permanentErrorHandlerEndpoint);
assertIsSatisfied(temporaryErrorHandlerEndpoint);
}
use of se.inera.intyg.common.support.modules.support.api.exception.ModuleException in project webcert by sklintyg.
the class CertificateStoreProcessorTest method testStoreCertificateThrowsPermanentOnModuleException.
@Test(expected = PermanentException.class)
public void testStoreCertificateThrowsPermanentOnModuleException() throws Exception {
// Given
doThrow(new ModuleException()).when(moduleApi).registerCertificate(anyString(), anyString());
// When
certificateStoreProcessor.process(BODY, "fk7263", LOGICAL_ADDRESS1);
}
use of se.inera.intyg.common.support.modules.support.api.exception.ModuleException in project webcert by sklintyg.
the class CopyUtkastServiceImpl method createReplacementCopy.
@Override
@Transactional("jpaTransactionManager")
public CreateReplacementCopyResponse createReplacementCopy(CreateReplacementCopyRequest replacementRequest) {
String originalIntygId = replacementRequest.getOriginalIntygId();
WebCertUser user = userService.getUser();
LOG.debug("Creating replacement copy of intyg '{}'", originalIntygId);
try {
if (intygService.isRevoked(replacementRequest.getOriginalIntygId(), replacementRequest.getTyp(), replacementRequest.isCoherentJournaling())) {
LOG.debug("Cannot create replacement certificate for id '{}', the certificate is revoked", originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "Can not create replacement copy - Original certificate is revoked");
}
verifyNotReplaced(replacementRequest.getOriginalIntygId(), "create replacement");
verifyNotComplementedWithSigned(replacementRequest.getOriginalIntygId(), "create replacement");
CopyUtkastBuilderResponse builderResponse = buildReplacementUtkastBuilderResponse(replacementRequest, originalIntygId);
if (replacementRequest.isDjupintegrerad()) {
checkIntegreradEnhet(builderResponse);
}
Utkast savedUtkast = saveAndNotify(builderResponse, user);
monitoringService.logIntygCopiedReplacement(savedUtkast.getIntygsId(), originalIntygId);
return new CreateReplacementCopyResponse(savedUtkast.getIntygsTyp(), savedUtkast.getIntygsId(), originalIntygId);
} catch (ModuleException | ModuleNotFoundException me) {
LOG.error("Module exception occured when trying to make a copy of " + originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, me);
}
}
use of se.inera.intyg.common.support.modules.support.api.exception.ModuleException in project webcert by sklintyg.
the class CopyUtkastServiceImpl method createCompletion.
/*
* (non-Javadoc)
*
* @see
* se.inera.intyg.webcert.web.service.utkast.CopyUtkastService#createCopy(se.inera.intyg.webcert.web.service.utkast.
* dto.
* CreateNewDraftCopyRequest)
*/
@Override
public CreateCompletionCopyResponse createCompletion(CreateCompletionCopyRequest copyRequest) {
String originalIntygId = copyRequest.getOriginalIntygId();
LOG.debug("Creating completion to intyg '{}'", originalIntygId);
WebCertUser user = userService.getUser();
try {
if (intygService.isRevoked(copyRequest.getOriginalIntygId(), copyRequest.getTyp(), false)) {
LOG.debug("Cannot create completion copy of certificate with id '{}', the certificate is revoked", originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "Original certificate is revoked");
}
CopyUtkastBuilderResponse builderResponse = buildCompletionUtkastBuilderResponse(copyRequest, originalIntygId, true);
if (copyRequest.isDjupintegrerad()) {
checkIntegreradEnhet(builderResponse);
}
Utkast savedUtkast = saveAndNotify(builderResponse, user);
monitoringService.logIntygCopiedCompletion(savedUtkast.getIntygsId(), originalIntygId);
return new CreateCompletionCopyResponse(savedUtkast.getIntygsTyp(), savedUtkast.getIntygsId(), originalIntygId);
} catch (ModuleException | ModuleNotFoundException me) {
LOG.error("Module exception occured when trying to make a copy of " + originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, me);
}
}
use of se.inera.intyg.common.support.modules.support.api.exception.ModuleException in project webcert by sklintyg.
the class CopyUtkastServiceImpl method createRenewalCopy.
/*
* (non-Javadoc)
*
* @see
* se.inera.intyg.webcert.web.service.utkast.CopyUtkastService#createCopy(se.inera.intyg.webcert.web.service.utkast.
* dto.
* CreateRenewalCopyRequest)
*/
@Override
public CreateRenewalCopyResponse createRenewalCopy(CreateRenewalCopyRequest copyRequest) {
String originalIntygId = copyRequest.getOriginalIntygId();
LOG.debug("Creating renewal for intyg '{}'", originalIntygId);
WebCertUser user = userService.getUser();
boolean coherentJournaling = user != null && user.getParameters() != null && user.getParameters().isSjf();
try {
if (intygService.isRevoked(copyRequest.getOriginalIntygId(), copyRequest.getOriginalIntygTyp(), coherentJournaling)) {
LOG.debug("Cannot renew certificate with id '{}', the certificate is revoked", originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "Original certificate is revoked");
}
verifyNotReplacedWithSigned(copyRequest.getOriginalIntygId(), "create renewal");
verifyNotComplementedWithSigned(copyRequest.getOriginalIntygId(), "create renewal");
CopyUtkastBuilderResponse builderResponse = buildRenewalUtkastBuilderResponse(copyRequest, originalIntygId, coherentJournaling);
if (copyRequest.isDjupintegrerad()) {
checkIntegreradEnhet(builderResponse);
}
Utkast savedUtkast = saveAndNotify(builderResponse, user);
monitoringService.logIntygCopiedRenewal(savedUtkast.getIntygsId(), originalIntygId);
return new CreateRenewalCopyResponse(savedUtkast.getIntygsTyp(), savedUtkast.getIntygsId(), originalIntygId);
} catch (ModuleException | ModuleNotFoundException me) {
LOG.error("Module exception occured when trying to make a copy of " + originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, me);
}
}
Aggregations