ModuleWatchingConsumer extends LoggingObject implements Consumer<Set<Resource>> { @Override public void accept(Set<Resource> resources) { if (generateFunctionMetadataCommand != null && commandContext != null && shouldFunctionMetadataBeGenerated(resources)) { try { logger.info("Generating function metadata for modules containing mapping functions"); generateFunctionMetadataCommand.execute(commandContext); } catch (Exception ex) { logger.error("Unable to generate function metadata, cause: " + ex.getMessage()); } } } ModuleWatchingConsumer(CommandContext commandContext, Command generateFunctionMetadataCommand); @Override void accept(Set<Resource> resources);  }
@Test public void generatingThrowsAnException() { TestCommand command = new TestCommand(); consumer = new ModuleWatchingConsumer(new CommandContext(null, null, null), command); Set<Resource> resources = new HashSet<>(); resources.add(new FileSystemResource("marklogic-data-hub/src/test/ml-modules/root/custom-modules/mapping-functions/custom-mapping-functions.sjs")); consumer.accept(resources); assertTrue(command.wasExecuted, "The command should have been executed, which means it threw an exception that " + "was logged and not rethrown, as we want mlWatch to keep running, even if function metadata cannot be generated."); }