ModuleWatchingConsumer extends LoggingObject implements Consumer<Set<Resource>> { protected boolean shouldFunctionMetadataBeGenerated(Set<Resource> resources) { if (resources != null && !resources.isEmpty()) { for (Resource r : resources) { try { if (r.getFile().getAbsolutePath().contains("mapping-functions")) { return true; } } catch (Exception ex) { logger.warn("Unable to read resource: " + r + "; cause: " + ex.getMessage()); } } } return false; } ModuleWatchingConsumer(CommandContext commandContext, Command generateFunctionMetadataCommand); @Override void accept(Set<Resource> resources);  }
@Test public void shouldGenerateFunctionMetadata() { 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")); assertTrue(consumer.shouldFunctionMetadataBeGenerated(resources)); }
@Test public void shouldNotGenerateFunctionMetadata() { Set<Resource> resources = new HashSet<>(); resources.add(new FileSystemResource("marklogic-data-hub/src/test/ml-modules/root/test/data-hub-test-helper.xqy")); assertFalse(consumer.shouldFunctionMetadataBeGenerated(resources)); }