RobotDryRunKeywordSourceCollector { public void collectFromMessageEvent(final MessageEvent event) { try { JsonMessageMapper.readValue(event, MESSAGE_KEY, MESSAGE_TYPE).ifPresent(keywordSources::add); } catch (final IOException e) { throw new JsonMessageMapperException("Problem with mapping message for key '" + MESSAGE_KEY + "'", e); } }  void collectFromMessageEvent(final MessageEvent event); List<RobotDryRunKeywordSource> getKeywordSources();  }
@Test public void keywordSourceEventMappingExceptionIsHandled() throws Exception { final RobotDryRunKeywordSourceCollector kwSourceCollector = new RobotDryRunKeywordSourceCollector(); final MessageEvent event = new MessageEvent("{\"keyword_source\":\"incorrect\"}", LogLevel.NONE, null); assertThatExceptionOfType(JsonMessageMapper.JsonMessageMapperException.class) .isThrownBy(() -> kwSourceCollector.collectFromMessageEvent(event)) .withMessage("Problem with mapping message for key 'keyword_source'") .withCauseInstanceOf(JsonMappingException.class); }