use of org.talend.sdk.component.server.front.model.ConfigTypeNodes in project component-runtime by Talend.
the class ConfigurationTypeResourceTest method webSocketGetIndex.
@Test
void webSocketGetIndex() {
final ConfigTypeNodes index = ws.read(ConfigTypeNodes.class, "get", "/configurationtype/index", "");
assertIndex(index);
validateJdbcHierarchy(index);
}
use of org.talend.sdk.component.server.front.model.ConfigTypeNodes in project component-runtime by Talend.
the class ConfigurationTypeResource method toNodes.
private ConfigTypeNodes toNodes(final String language, final Predicate<String> filter, final boolean lightPayload) {
final Locale locale = localeMapper.mapLocale(language);
return manager.find(Stream::of).filter(c -> c.get(RepositoryModel.class) != null).map(c -> c.get(RepositoryModel.class).getFamilies().stream().filter(f -> !f.getConfigs().isEmpty()).flatMap(family -> {
final FamilyBundle resourcesBundle = family.getMeta().findBundle(c.getLoader(), locale);
final Stream<ConfigTypeNode> familyNode;
if (filter.test(family.getId())) {
final ConfigTypeNode node = new ConfigTypeNode();
node.setId(family.getId());
node.setName(family.getMeta().getName());
node.setDisplayName(resourcesBundle.displayName().orElse(family.getMeta().getName()));
node.setEdges(family.getConfigs().stream().map(Config::getId).collect(toSet()));
familyNode = Stream.of(node);
} else {
familyNode = Stream.empty();
}
return Stream.concat(familyNode, createNode(family.getId(), family.getMeta().getName(), family.getConfigs().stream(), resourcesBundle, c, locale, filter, lightPayload));
})).collect(() -> {
final ConfigTypeNodes nodes = new ConfigTypeNodes();
nodes.setNodes(new HashMap<>());
return nodes;
}, (root, children) -> root.getNodes().putAll(children.collect(toMap(ConfigTypeNode::getId, identity()))), (first, second) -> first.getNodes().putAll(second.getNodes()));
}
use of org.talend.sdk.component.server.front.model.ConfigTypeNodes in project component-runtime by Talend.
the class UiSpecServiceTest method configuration.
@Test
void configuration() throws Exception {
final ConfigTypeNodes load = load("config.json", ConfigTypeNodes.class);
final String family = load.getNodes().entrySet().stream().filter(e -> e.getValue().getParentId() == null).map(e -> e.getValue().getId()).findFirst().orElseThrow(() -> new IllegalArgumentException("No family"));
final Ui payload = service.convert(family, load.getNodes().values().stream().filter(e -> "amRiYyNkYXRhc3RvcmUjamRiYw".equals(e.getId())).findFirst().orElseThrow(() -> new IllegalArgumentException("No amRiYyNkYXRhc3RvcmUjamRiYw config"))).toCompletableFuture().get();
assertTrue(payload.getJsonSchema().getProperties().containsKey("connection"), "connection");
assertEquals(4, payload.getUiSchema().iterator().next().getItems().size());
}
use of org.talend.sdk.component.server.front.model.ConfigTypeNodes in project component-runtime by Talend.
the class ConfigurationTypeResourceTest method webSocketDetail.
@Test
void webSocketDetail() {
final ConfigTypeNodes index = ws.read(ConfigTypeNodes.class, "get", "/configurationtype/details?identifiers=amRiYyNkYXRhc3RvcmUjamRiYw", "");
assertEquals(1, index.getNodes().size());
final ConfigTypeNode jdbcConnection = index.getNodes().get("amRiYyNkYXRhc3RvcmUjamRiYw");
assertNotNull(jdbcConnection);
assertEquals("[{\"description\":\"D1\",\"driver\":\"d1\"},{\"description\":\"D2\",\"driver\":\"d2\"}]", jdbcConnection.getProperties().stream().filter(p -> "configuration.configurations".equals(p.getPath())).findFirst().get().getDefaultValue());
}
Aggregations