use of se.inera.intyg.webcert.common.model.WebcertCertificateRelation in project webcert by sklintyg.
the class IntygRelationHelperImplTest method buildWebcertRelationsWithParent.
private Relations buildWebcertRelationsWithParent() {
Relations relations = new Relations();
Relations.FrontendRelations fr = relations.getLatestChildRelations();
fr.setReplacedByUtkast(new WebcertCertificateRelation(OTHER_INTYG_ID_2, RelationKod.ERSATT, LocalDateTime.now().minusDays(1), UtkastStatus.DRAFT_COMPLETE));
fr.setComplementedByIntyg(new WebcertCertificateRelation(OTHER_INTYG_ID_3, RelationKod.KOMPLT, LocalDateTime.now().minusDays(2), UtkastStatus.SIGNED));
relations.setParent(new WebcertCertificateRelation(PARENT_INTYG_1, RelationKod.KOMPLT, LocalDateTime.now().minusDays(3), UtkastStatus.SIGNED));
return relations;
}
use of se.inera.intyg.webcert.common.model.WebcertCertificateRelation in project webcert by sklintyg.
the class IntygRelationHelperImpl method applyRelation.
/*
* In this context, all (draft) statuses are SIGNED.
*/
private void applyRelation(String intygId, Relations certificateRelations, Relation r) {
if (r.getTillIntygsId().getExtension().equals(intygId)) {
Relations.FrontendRelations latest = certificateRelations.getLatestChildRelations();
WebcertCertificateRelation wcr = createWebcertCertificateRelation(r, true);
switch(wcr.getRelationKod()) {
case ERSATT:
if (firstSkapadLaterDateThanSecond(wcr, latest.getReplacedByIntyg())) {
latest.setReplacedByIntyg(wcr);
} else if (firstSkapadLaterDateThanSecond(wcr, latest.getReplacedByUtkast())) {
latest.setReplacedByUtkast(wcr);
}
break;
case KOMPLT:
if (firstSkapadLaterDateThanSecond(wcr, latest.getComplementedByIntyg())) {
latest.setComplementedByIntyg(wcr);
} else if (firstSkapadLaterDateThanSecond(wcr, latest.getComplementedByUtkast())) {
latest.setComplementedByUtkast(wcr);
}
break;
case FRLANG:
break;
}
} else if (r.getFranIntygsId().getExtension().equals(intygId)) {
certificateRelations.setParent(createWebcertCertificateRelation(r, false));
}
}
use of se.inera.intyg.webcert.common.model.WebcertCertificateRelation in project webcert by sklintyg.
the class CertificateRelationServiceImpl method getRelations.
@Override
public Relations getRelations(String intygsId) {
Relations relations = new Relations();
Optional<WebcertCertificateRelation> parentRelation = findParentRelation(intygsId);
parentRelation.ifPresent(relations::setParent);
List<WebcertCertificateRelation> childRelations = findChildRelations(intygsId);
relations.setLatestChildRelations(prepareChildRelationDataForFrontend(childRelations));
return relations;
}
use of se.inera.intyg.webcert.common.model.WebcertCertificateRelation in project webcert by sklintyg.
the class CopyUtkastServiceImplTest method testCreateRenewalFailsWhenReplacedBySignedIntyg.
@Test(expected = WebCertServiceException.class)
public void testCreateRenewalFailsWhenReplacedBySignedIntyg() throws Exception {
final String reference = "ref";
WebCertUser user = new WebCertUser();
user.setParameters(new IntegrationParameters(reference, "", "", "", "", "", "", "", "", false, false, false, true));
when(userService.getUser()).thenReturn(user);
WebcertCertificateRelation ersattRelation = new WebcertCertificateRelation(INTYG_ID, RelationKod.ERSATT, LocalDateTime.now(), UtkastStatus.SIGNED);
when(certificateRelationService.getNewestRelationOfType(INTYG_ID, RelationKod.ERSATT, Arrays.asList(UtkastStatus.SIGNED))).thenReturn(Optional.of(ersattRelation));
CreateRenewalCopyRequest copyReq = buildRenewalRequest();
try {
copyService.createRenewalCopy(copyReq);
fail("An exception should have been thrown.");
} catch (Exception e) {
verifyZeroInteractions(mockUtkastRepository);
verifyZeroInteractions(mockNotificationService);
verify(intygService).isRevoked(INTYG_ID, INTYG_TYPE, false);
// Assert no pdl logging
verifyZeroInteractions(logService);
throw e;
}
}
Aggregations