@Test public void testCreateAndSendNotification() throws Exception { ArgumentCaptor<MessageCreator> messageCreatorCaptor = ArgumentCaptor.forClass(MessageCreator.class); when(mockSendNotificationStrategy.decideNotificationForIntyg(any(Utkast.class))).thenReturn(Optional.of(SchemaVersion.VERSION_1)); NotificationMessage notMsg = createNotificationMessage(HandelsekodEnum.ANDRAT, INTYG_JSON); when(mockNotificationMessageFactory.createNotificationMessage( any(Utkast.class), eq(HandelsekodEnum.ANDRAT), eq(SchemaVersion.VERSION_1), anyString(), or(isNull(), any(Amneskod.class)), or(isNull(), any(LocalDate.class)))).thenReturn(notMsg); Utkast utkast = createUtkast(); notificationService.createAndSendNotification(utkast, HandelsekodEnum.ANDRAT); verify(template, only()).send(messageCreatorCaptor.capture()); TextMessage textMessage = mock(TextMessage.class); Session session = mock(Session.class); ArgumentCaptor<String> stringArgumentCaptor = ArgumentCaptor.forClass(String.class); when(session.createTextMessage(stringArgumentCaptor.capture())).thenReturn(textMessage); MessageCreator messageCreator = messageCreatorCaptor.getValue(); messageCreator.createMessage(session); NotificationMessage captNotMsg = objectMapper.readValue(stringArgumentCaptor.getValue(), NotificationMessage.class); assertNotNull(captNotMsg); assertEquals(INTYG_ID, captNotMsg.getIntygsId()); assertEquals(HandelsekodEnum.ANDRAT, captNotMsg.getHandelse()); assertEquals(INTYG_JSON, captNotMsg.getUtkast()); assertEquals(SchemaVersion.VERSION_1, captNotMsg.getVersion()); assertNull(captNotMsg.getReference()); verify(mockNotificationMessageFactory).createNotificationMessage( any(Utkast.class), eq(HandelsekodEnum.ANDRAT), eq(SchemaVersion.VERSION_1), anyString(), or(isNull(), any(Amneskod.class)), or(isNull(), any(LocalDate.class))); verify(handelseRepository).save(any(Handelse.class)); }
void createAndSendNotification(Utkast utkast, HandelsekodEnum handelse) { createAndSendNotification(utkast, handelse, null, null); }
NotificationServiceImpl implements NotificationService { void createAndSendNotification(Utkast utkast, HandelsekodEnum handelse) { createAndSendNotification(utkast, handelse, null, null); } }
NotificationServiceImpl implements NotificationService { void createAndSendNotification(Utkast utkast, HandelsekodEnum handelse) { createAndSendNotification(utkast, handelse, null, null); }  }
NotificationServiceImpl implements NotificationService { void createAndSendNotification(Utkast utkast, HandelsekodEnum handelse) { createAndSendNotification(utkast, handelse, null, null); }  @PostConstruct void checkJmsTemplate(); @Override void sendNotificationForDraftCreated(Utkast utkast); @Override void sendNotificationForDraftSigned(Utkast utkast); @Override void sendNotificationForDraftChanged(Utkast utkast); @Override void sendNotificationForDraftDeleted(Utkast utkast); @Override void sendNotificationForDraftRevoked(Utkast utkast); @Override void sendNotificationForDraftReadyToSign(Utkast utkast); @Override void sendNotificationForIntygSent(String intygsId); @Override void sendNotificationForIntygRevoked(String intygsId); @Override void sendNotificationForQuestionReceived(FragaSvar fragaSvar); @Override void sendNotificationForAnswerRecieved(FragaSvar fragaSvar); @Override void sendNotificationForQuestionReceived(Arende arende); @Override void sendNotificationForAnswerRecieved(Arende arende); @Override List<Handelse> getNotifications(String intygsId); @Override void sendNotificationForQAs(String intygsId, NotificationEvent event); @Override void forwardInternalNotification(final String intygsId, final String intygstyp, final Utlatande utlatande,
        final HandelsekodEnum handelse); @Override List<Handelse> findNotifications(IntygWithNotificationsRequest request); }
NotificationServiceImpl implements NotificationService { void createAndSendNotification(Utkast utkast, HandelsekodEnum handelse) { createAndSendNotification(utkast, handelse, null, null); }  @PostConstruct void checkJmsTemplate(); @Override void sendNotificationForDraftCreated(Utkast utkast); @Override void sendNotificationForDraftSigned(Utkast utkast); @Override void sendNotificationForDraftChanged(Utkast utkast); @Override void sendNotificationForDraftDeleted(Utkast utkast); @Override void sendNotificationForDraftRevoked(Utkast utkast); @Override void sendNotificationForDraftReadyToSign(Utkast utkast); @Override void sendNotificationForIntygSent(String intygsId); @Override void sendNotificationForIntygRevoked(String intygsId); @Override void sendNotificationForQuestionReceived(FragaSvar fragaSvar); @Override void sendNotificationForAnswerRecieved(FragaSvar fragaSvar); @Override void sendNotificationForQuestionReceived(Arende arende); @Override void sendNotificationForAnswerRecieved(Arende arende); @Override List<Handelse> getNotifications(String intygsId); @Override void sendNotificationForQAs(String intygsId, NotificationEvent event); @Override void forwardInternalNotification(final String intygsId, final String intygstyp, final Utlatande utlatande,
        final HandelsekodEnum handelse); @Override List<Handelse> findNotifications(IntygWithNotificationsRequest request);  }