use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.
the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntryResolvesSignedByNameFromSkapadAv.
@Test
public void testConvertUtkastToListIntygEntryResolvesSignedByNameFromSkapadAv() {
Signatur signatur = mock(Signatur.class);
final String skapadAvName = "Bengt Bengtsson";
final String skapadAvHsaId = "BengtsHsaId";
Utkast utkast = createUtkast();
utkast.setStatus(UtkastStatus.SIGNED);
utkast.getSkapadAv().setNamn(skapadAvName);
utkast.setSignatur(signatur);
when(signatur.getSigneradAv()).thenReturn(skapadAvHsaId);
ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
assertNotNull(res);
assertEquals(skapadAvHsaId, res.getUpdatedSignedBy());
}
use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.
the class IntygDraftsConverterTest method createUtkast.
private Utkast createUtkast() {
final String sparadAvNamn = "namn efternamn";
final String sparadAvHsaId = "hsaid";
final String skapadAvHsaId = "hsaid";
VardpersonReferens vardpersonReferens = new VardpersonReferens();
Utkast utkast = new Utkast();
utkast.setStatus(UtkastStatus.DRAFT_INCOMPLETE);
utkast.setSenastSparadAv(vardpersonReferens);
utkast.getSenastSparadAv().setNamn(sparadAvNamn);
utkast.getSenastSparadAv().setHsaId(sparadAvHsaId);
utkast.setSkapadAv(vardpersonReferens);
utkast.getSkapadAv().setHsaId(skapadAvHsaId);
utkast.setPatientPersonnummer(Personnummer.createPersonnummer("20121212-1211").get());
Signatur signatur = mock(Signatur.class);
utkast.setSignatur(signatur);
when(signatur.getSigneradAv()).thenReturn(sparadAvHsaId);
return utkast;
}
use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.
the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntrySetsStatusReceivedIfApplicable.
@Test
public void testConvertUtkastToListIntygEntrySetsStatusReceivedIfApplicable() {
Signatur signatur = mock(Signatur.class);
Utkast utkast = createUtkast();
utkast.setStatus(UtkastStatus.SIGNED);
utkast.setSignatur(signatur);
when(signatur.getSigneringsDatum()).thenReturn(LocalDateTime.now());
ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
assertNotNull(res);
assertEquals(CertificateState.RECEIVED.name(), res.getStatus());
}
use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.
the class IntygDraftsConverterTest method testConvertUtkastToListIntygEntrySetsSentBeforeReceived.
@Test
public void testConvertUtkastToListIntygEntrySetsSentBeforeReceived() {
Signatur signatur = mock(Signatur.class);
Utkast utkast = createUtkast();
utkast.setStatus(UtkastStatus.SIGNED);
utkast.setSignatur(signatur);
utkast.setSkickadTillMottagareDatum(LocalDateTime.now());
when(signatur.getSigneringsDatum()).thenReturn(LocalDateTime.now());
ListIntygEntry res = IntygDraftsConverter.convertUtkastToListIntygEntry(utkast);
assertNotNull(res);
assertEquals(CertificateState.SENT.name(), res.getStatus());
}
use of se.inera.intyg.webcert.persistence.utkast.model.Signatur in project webcert by sklintyg.
the class ArendeServiceTest method createQuestionUnauthorizedTest.
@Test
public void createQuestionUnauthorizedTest() {
Utkast utkast = new Utkast();
utkast.setSignatur(new Signatur());
when(utkastRepository.findOne(anyString())).thenReturn(utkast);
try {
service.createMessage(INTYG_ID, ArendeAmne.KONTKT, "rubrik", "meddelande");
fail("should throw exception");
} catch (WebCertServiceException e) {
assertEquals(WebCertServiceErrorCodeEnum.AUTHORIZATION_PROBLEM, e.getErrorCode());
verifyZeroInteractions(arendeRepository);
verifyZeroInteractions(notificationService);
verifyZeroInteractions(arendeDraftService);
}
}
Aggregations