use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class ArendeServiceTest method testProcessIncomingMessageSendsNotificationForAnswerRecieved.
@Test
public void testProcessIncomingMessageSendsNotificationForAnswerRecieved() throws WebCertServiceException {
final String frageid = "frageid";
Arende fragearende = new Arende();
Arende svararende = new Arende();
svararende.setIntygsId(INTYG_ID);
svararende.setSvarPaId(frageid);
Utkast utkast = buildUtkast();
when(utkastRepository.findOne(INTYG_ID)).thenReturn(utkast);
when(arendeRepository.findOneByMeddelandeId(eq(frageid))).thenReturn(fragearende);
Arende res = service.processIncomingMessage(svararende);
assertNotNull(res);
assertEquals(INTYG_ID, res.getIntygsId());
verify(arendeRepository).findOneByMeddelandeId(eq(frageid));
verify(arendeRepository, times(2)).save(any(Arende.class));
verify(notificationService).sendNotificationForAnswerRecieved(any(Arende.class));
verifyZeroInteractions(arendeDraftService);
}
use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class ArendeServiceTest method testCreateQuestionIfCertificateIsRevoked.
@Test
public void testCreateQuestionIfCertificateIsRevoked() throws WebCertServiceException {
Utkast utkast = buildUtkast();
utkast.setAterkalladDatum(LocalDateTime.now());
when(utkastRepository.findOne(anyString())).thenReturn(utkast);
try {
service.createMessage(INTYG_ID, ArendeAmne.KONTKT, "rubrik", "meddelande");
fail("Should throw");
} catch (WebCertServiceException e) {
assertEquals(WebCertServiceErrorCodeEnum.CERTIFICATE_REVOKED, e.getErrorCode());
verify(arendeRepository, never()).save(any(Arende.class));
verifyZeroInteractions(notificationService);
verifyZeroInteractions(arendeDraftService);
}
}
use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class ArendeServiceTest method createQuestionTest.
@Test
public void createQuestionTest() throws CertificateSenderException {
LocalDateTime now = LocalDateTime.now();
Utkast utkast = buildUtkast();
doReturn(utkast).when(utkastRepository).findOne(anyString());
when(webcertUserService.isAuthorizedForUnit(isNull(), anyBoolean())).thenReturn(true);
when(webcertUserService.getUser()).thenReturn(new WebCertUser());
Arende arende = new Arende();
arende.setSenasteHandelse(now);
ArendeConversationView result = service.createMessage(INTYG_ID, ArendeAmne.KONTKT, "rubrik", "meddelande");
assertNotNull(result.getFraga());
assertNull(result.getSvar());
assertEquals(FIXED_TIME_INSTANT, result.getSenasteHandelse().toInstant(ZoneId.systemDefault().getRules().getOffset(FIXED_TIME_INSTANT)));
verify(webcertUserService).isAuthorizedForUnit(isNull(), anyBoolean());
verify(arendeRepository).save(any(Arende.class));
verify(monitoringLog).logArendeCreated(anyString(), isNull(), isNull(), any(ArendeAmne.class), anyBoolean());
verify(certificateSenderService).sendMessageToRecipient(anyString(), anyString());
verify(notificationService).sendNotificationForQAs(INTYG_ID, NotificationEvent.NEW_QUESTION_FROM_CARE);
verify(arendeDraftService).delete(INTYG_ID, null);
}
use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class ArendeServiceTest method testProcessIncomingMessageCertificateNotSigned.
@Test
public void testProcessIncomingMessageCertificateNotSigned() {
when(utkastRepository.findOne(isNull())).thenReturn(new Utkast());
try {
service.processIncomingMessage(new Arende());
fail("Should throw");
} catch (WebCertServiceException e) {
assertEquals(WebCertServiceErrorCodeEnum.INVALID_STATE, e.getErrorCode());
verify(arendeRepository, never()).save(any(Arende.class));
verifyZeroInteractions(notificationService);
verifyZeroInteractions(arendeDraftService);
}
}
use of se.inera.intyg.webcert.persistence.utkast.model.Utkast in project webcert by sklintyg.
the class ArendeServiceTest method testProcessIncomingMessageSendsNotificationForQuestionReceived.
@Test
public void testProcessIncomingMessageSendsNotificationForQuestionReceived() throws WebCertServiceException {
Arende arende = new Arende();
arende.setIntygsId(INTYG_ID);
Utkast utkast = buildUtkast();
when(utkastRepository.findOne(INTYG_ID)).thenReturn(utkast);
Arende res = service.processIncomingMessage(arende);
assertNotNull(res);
assertEquals(INTYG_ID, res.getIntygsId());
verify(utkastRepository).findOne(INTYG_ID);
verify(notificationService).sendNotificationForQuestionReceived(any(Arende.class));
verifyZeroInteractions(arendeDraftService);
}
Aggregations