use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.
the class ArendeServiceTest method createQuestionInvalidCertificateTypeTest.
@Test
public void createQuestionInvalidCertificateTypeTest() {
Utkast utkast = new Utkast();
utkast.setSignatur(new Signatur());
utkast.setIntygsTyp("fk7263");
when(utkastRepository.findOne(anyString())).thenReturn(utkast);
try {
service.createMessage(INTYG_ID, ArendeAmne.KONTKT, "rubrik", "meddelande");
fail("should throw exception");
} catch (WebCertServiceException e) {
assertEquals(WebCertServiceErrorCodeEnum.INVALID_STATE, e.getErrorCode());
verifyZeroInteractions(arendeRepository);
verifyZeroInteractions(notificationService);
verifyZeroInteractions(arendeDraftService);
}
}
use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.
the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntrySetsCancelledFirst.
@Test
public void testConvertUtkastToListIntygEntrySetsCancelledFirst() {
Signatur signatur = mock(Signatur.class);
Utkast utkast = createUtkast();
utkast.setStatus(UtkastStatus.SIGNED);
utkast.setSignatur(signatur);
utkast.setAterkalladDatum(LocalDateTime.now());
utkast.setSkickadTillMottagareDatum(LocalDateTime.now());
when(signatur.getSigneringsDatum()).thenReturn(LocalDateTime.now());
ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
assertNotNull(res);
assertEquals(CertificateState.CANCELLED.name(), res.getStatus());
}
use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.
the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntryResolvesSignedByNameReturnsSignaturHsaId.
@Test
public void testConvertUtkastToListIntygEntryResolvesSignedByNameReturnsSignaturHsaId() {
Signatur signatur = mock(Signatur.class);
Utkast utkast = createUtkast();
utkast.setStatus(UtkastStatus.SIGNED);
utkast.setSignatur(signatur);
when(signatur.getSigneradAv()).thenReturn(utkast.getSenastSparadAv().getNamn());
ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
assertNotNull(res);
assertEquals(utkast.getSenastSparadAv().getNamn(), res.getUpdatedSignedBy());
}
use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.
the class IntygResource method updateUtkastForSend.
private void updateUtkastForSend(@PathParam("id") String id) {
Utkast utkast = utkastRepository.findOne(id);
if (utkast != null) {
utkast.setStatus(UtkastStatus.SIGNED);
Utlatande utlatande = moduleFacade.getUtlatandeFromInternalModel(utkast.getIntygsTyp(), utkast.getModel());
utlatande.getGrundData().setSigneringsdatum(LocalDateTime.now());
try {
CustomObjectMapper mapper = new CustomObjectMapper();
StringWriter writer = new StringWriter();
mapper.writeValue(writer, utlatande);
utkast.setModel(writer.toString());
} catch (IOException e) {
LOG.error("Could not update the model of the utkast. Failed with message ", e.getMessage());
}
if (utkast.getSignatur() == null) {
Signatur sig = new Signatur(LocalDateTime.now(), "", id, "", "", "");
utkast.setSignatur(sig);
}
utkast.setSkickadTillMottagare("FKASSA");
utkast.setSkickadTillMottagareDatum(LocalDateTime.now());
utkastRepository.save(utkast);
}
}
use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.
the class IntygResource method updateUtkastForSign.
private void updateUtkastForSign(@PathParam("id") String id, String signeratAv) {
Utkast utkast = utkastRepository.findOne(id);
if (utkast != null) {
utkast.setStatus(UtkastStatus.SIGNED);
Signatur sig = new Signatur(LocalDateTime.now(), signeratAv != null ? signeratAv : "", id, "", "", "");
utkast.setSignatur(sig);
utkastRepository.save(utkast);
}
}
Aggregations