### Question:
SlackNotifications extends BufferedNotificationMethod { @Override protected void sendNotification (ChaosNotification chaosNotification) throws IOException { SlackMessage slackMessage = SlackMessage.builder() .withAttachment(createAttachmentFromChaosNotification(chaosNotification)) .build(); sendSlackMessage(slackMessage); } @Autowired  SlackNotifications(@Value("${slack_webhookuri}") @NotNull String webhookUri); @Override void logNotification(ChaosNotification notification);  }### Answer:
@Test(expected = IOException.class) public void slackIOExceptionTest () throws IOException { try { responseCode = 500; slackNotifications.sendNotification(chaosExperimentEvent); } finally { responseCode = 200; } }
@Test public void sendNotification () throws IOException { slackNotifications.sendNotification(chaosExperimentEvent); ArgumentCaptor<SlackMessage> slackMessageArgumentCaptor = ArgumentCaptor.forClass(SlackMessage.class); verify(slackNotifications, times(1)).sendSlackMessage(slackMessageArgumentCaptor.capture()); SlackMessage actualSlackMessage = slackMessageArgumentCaptor.getValue(); String expectedPayload = mapper.writeValueAsString(expectedSlackEvent); String actualPayload = mapper.writeValueAsString(actualSlackMessage); assertEquals(expectedPayload, actualPayload); }