@Test void paramResolutionToParent() throws Exception { final ConfigTypeNode node = load("param-resolution-to-parent.json", ConfigTypeNode.class); final Ui payload = service.convert("test", "en", node, null).toCompletableFuture().get(); final List<UiSchema> rootItems = List.class.cast(payload.getUiSchema().iterator().next().getItems()); final UiSchema.Trigger trigger = rootItems .stream() .filter(it -> "configuration.customObjectName".equals(it.getKey())) .findFirst() .orElseThrow(IllegalStateException::new) .getTriggers() .stream() .findFirst() .orElseThrow(IllegalStateException::new); assertEquals("CUSTOM_OBJECT_NAMES", trigger.getAction()); assertEquals("Marketo", trigger.getFamily()); assertEquals("suggestions", trigger.getType()); assertEquals("focus", trigger.getOnEvent()); assertEquals(1, trigger.getParameters().size()); final UiSchema.Parameter parameter = trigger.getParameters().iterator().next(); assertEquals("dataStore", parameter.getKey()); assertEquals("configuration.dataSet.dataStore", parameter.getPath()); }
public CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node, final T context) { final Collection<String> rootProperties = node.getProperties().stream().map(SimplePropertyDefinition::getPath).collect(toSet()); rootProperties .removeIf(path -> node.getProperties().stream().anyMatch(p -> path.startsWith(p.getPath() + '.'))); if (rootProperties.isEmpty()) { log.warn("No root properties for configuration node {} (family={})", node.getId(), family); } final Collection<SimplePropertyDefinition> props; final Predicate<SimplePropertyDefinition> isRootProperty; if (rootProperties.size() == 1 && rootProperties.iterator().next().startsWith("configuration.")) { final String root = rootProperties.iterator().next(); final SimplePropertyDefinition def = node.getProperties().stream().filter(prop -> prop.getPath().equals(root)).findFirst().get(); props = node .getProperties() .stream() .map(prop -> new SimplePropertyDefinition(def.getName() + prop.getPath().substring(root.length()), prop.getName(), prop.getDisplayName(), prop.getType(), prop.getDefaultValue(), prop.getValidation(), prop.getMetadata(), prop.getPlaceholder(), prop.getProposalDisplayNames())) .collect(toList()); isRootProperty = p -> p.getPath().equals(def.getName()); } else { props = node.getProperties(); isRootProperty = p -> rootProperties.contains(p.getPath()); } return convert(node::getDisplayName, () -> family, () -> props, node::getActions, isRootProperty, context, lang); }
UiSpecService implements AutoCloseable { public CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node, final T context) { final Collection<String> rootProperties = node.getProperties().stream().map(SimplePropertyDefinition::getPath).collect(toSet()); rootProperties .removeIf(path -> node.getProperties().stream().anyMatch(p -> path.startsWith(p.getPath() + '.'))); if (rootProperties.isEmpty()) { log.warn("No root properties for configuration node {} (family={})", node.getId(), family); } final Collection<SimplePropertyDefinition> props; final Predicate<SimplePropertyDefinition> isRootProperty; if (rootProperties.size() == 1 && rootProperties.iterator().next().startsWith("configuration.")) { final String root = rootProperties.iterator().next(); final SimplePropertyDefinition def = node.getProperties().stream().filter(prop -> prop.getPath().equals(root)).findFirst().get(); props = node .getProperties() .stream() .map(prop -> new SimplePropertyDefinition(def.getName() + prop.getPath().substring(root.length()), prop.getName(), prop.getDisplayName(), prop.getType(), prop.getDefaultValue(), prop.getValidation(), prop.getMetadata(), prop.getPlaceholder(), prop.getProposalDisplayNames())) .collect(toList()); isRootProperty = p -> p.getPath().equals(def.getName()); } else { props = node.getProperties(); isRootProperty = p -> rootProperties.contains(p.getPath()); } return convert(node::getDisplayName, () -> family, () -> props, node::getActions, isRootProperty, context, lang); } }
UiSpecService implements AutoCloseable { public CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node, final T context) { final Collection<String> rootProperties = node.getProperties().stream().map(SimplePropertyDefinition::getPath).collect(toSet()); rootProperties .removeIf(path -> node.getProperties().stream().anyMatch(p -> path.startsWith(p.getPath() + '.'))); if (rootProperties.isEmpty()) { log.warn("No root properties for configuration node {} (family={})", node.getId(), family); } final Collection<SimplePropertyDefinition> props; final Predicate<SimplePropertyDefinition> isRootProperty; if (rootProperties.size() == 1 && rootProperties.iterator().next().startsWith("configuration.")) { final String root = rootProperties.iterator().next(); final SimplePropertyDefinition def = node.getProperties().stream().filter(prop -> prop.getPath().equals(root)).findFirst().get(); props = node .getProperties() .stream() .map(prop -> new SimplePropertyDefinition(def.getName() + prop.getPath().substring(root.length()), prop.getName(), prop.getDisplayName(), prop.getType(), prop.getDefaultValue(), prop.getValidation(), prop.getMetadata(), prop.getPlaceholder(), prop.getProposalDisplayNames())) .collect(toList()); isRootProperty = p -> p.getPath().equals(def.getName()); } else { props = node.getProperties(); isRootProperty = p -> rootProperties.contains(p.getPath()); } return convert(node::getDisplayName, () -> family, () -> props, node::getActions, isRootProperty, context, lang); } UiSpecService(final Client client);  UiSpecService(final Client client, final Jsonb jsonb); }
UiSpecService implements AutoCloseable { public CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node, final T context) { final Collection<String> rootProperties = node.getProperties().stream().map(SimplePropertyDefinition::getPath).collect(toSet()); rootProperties .removeIf(path -> node.getProperties().stream().anyMatch(p -> path.startsWith(p.getPath() + '.'))); if (rootProperties.isEmpty()) { log.warn("No root properties for configuration node {} (family={})", node.getId(), family); } final Collection<SimplePropertyDefinition> props; final Predicate<SimplePropertyDefinition> isRootProperty; if (rootProperties.size() == 1 && rootProperties.iterator().next().startsWith("configuration.")) { final String root = rootProperties.iterator().next(); final SimplePropertyDefinition def = node.getProperties().stream().filter(prop -> prop.getPath().equals(root)).findFirst().get(); props = node .getProperties() .stream() .map(prop -> new SimplePropertyDefinition(def.getName() + prop.getPath().substring(root.length()), prop.getName(), prop.getDisplayName(), prop.getType(), prop.getDefaultValue(), prop.getValidation(), prop.getMetadata(), prop.getPlaceholder(), prop.getProposalDisplayNames())) .collect(toList()); isRootProperty = p -> p.getPath().equals(def.getName()); } else { props = node.getProperties(); isRootProperty = p -> rootProperties.contains(p.getPath()); } return convert(node::getDisplayName, () -> family, () -> props, node::getActions, isRootProperty, context, lang); } UiSpecService(final Client client);  UiSpecService(final Client client, final Jsonb jsonb); UiSpecService<T> withConverter(final CustomPropertyConverter converter); CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node,
            final T context); CompletionStage<Ui> convert(final ComponentDetail detail, final String lang, final T context); @Override void close(); }
UiSpecService implements AutoCloseable { public CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node, final T context) { final Collection<String> rootProperties = node.getProperties().stream().map(SimplePropertyDefinition::getPath).collect(toSet()); rootProperties .removeIf(path -> node.getProperties().stream().anyMatch(p -> path.startsWith(p.getPath() + '.'))); if (rootProperties.isEmpty()) { log.warn("No root properties for configuration node {} (family={})", node.getId(), family); } final Collection<SimplePropertyDefinition> props; final Predicate<SimplePropertyDefinition> isRootProperty; if (rootProperties.size() == 1 && rootProperties.iterator().next().startsWith("configuration.")) { final String root = rootProperties.iterator().next(); final SimplePropertyDefinition def = node.getProperties().stream().filter(prop -> prop.getPath().equals(root)).findFirst().get(); props = node .getProperties() .stream() .map(prop -> new SimplePropertyDefinition(def.getName() + prop.getPath().substring(root.length()), prop.getName(), prop.getDisplayName(), prop.getType(), prop.getDefaultValue(), prop.getValidation(), prop.getMetadata(), prop.getPlaceholder(), prop.getProposalDisplayNames())) .collect(toList()); isRootProperty = p -> p.getPath().equals(def.getName()); } else { props = node.getProperties(); isRootProperty = p -> rootProperties.contains(p.getPath()); } return convert(node::getDisplayName, () -> family, () -> props, node::getActions, isRootProperty, context, lang); } UiSpecService(final Client client);  UiSpecService(final Client client, final Jsonb jsonb); UiSpecService<T> withConverter(final CustomPropertyConverter converter); CompletionStage<Ui> convert(final String family, final String lang, final ConfigTypeNode node,
            final T context); CompletionStage<Ui> convert(final ComponentDetail detail, final String lang, final T context); @Override void close();  }