RobotDryRunLibraryImportCollector { public void collectFromMessageEvent(final MessageEvent event) { try { JsonMessageMapper.readValue(event, MESSAGE_KEY, MESSAGE_TYPE).ifPresent(importError -> { final RobotDryRunLibraryImport libImport = RobotDryRunLibraryImport.createUnknown(importError.getName(), formatAdditionalInfo(importError.getError())); importedLibraries.add(libImport); erroneousLibraryNames.add(importError.getName()); }); } catch (final IOException e) { throw new JsonMessageMapperException("Problem with mapping message for key '" + MESSAGE_KEY + "'", e); } } RobotDryRunLibraryImportCollector(final Set<String> standardLibraryNames); void collectFromLibraryImportEvent(final LibraryImportEvent event); void collectFromMessageEvent(final MessageEvent event); List<RobotDryRunLibraryImport> getImportedLibraries();  }
@Test public void importErrorEventMappingExceptionIsHandled() throws Exception { final RobotDryRunLibraryImportCollector libImportCollector = new RobotDryRunLibraryImportCollector( Collections.emptySet()); final MessageEvent event = new MessageEvent("{\"import_error\":\"incorrect\"}", LogLevel.NONE, null); assertThatExceptionOfType(JsonMessageMapper.JsonMessageMapperException.class) .isThrownBy(() -> libImportCollector.collectFromMessageEvent(event)) .withMessage("Problem with mapping message for key 'import_error'") .withCauseInstanceOf(JsonMappingException.class); }