use of org.talend.sdk.component.form.model.Ui in project component-runtime by Talend.
the class UiSpecServiceTest method out.
/*
* just to log the output
*/
@Test
@Disabled("debug test to log the produced model")
void out() throws Exception {
final Ui payload = service.convert(load("jdbc.json")).toCompletableFuture().get();
System.out.println(JsonbBuilder.create(new JsonbConfig().withFormatting(true)).toJson(payload));
}
use of org.talend.sdk.component.form.model.Ui 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.form.model.Ui in project component-runtime by Talend.
the class UiSpecServiceTest method uiSchema.
@Test
void uiSchema() throws Exception {
final Ui payload = service.convert(load("jdbc.json")).toCompletableFuture().get();
final Collection<UiSchema> uiSchema = payload.getUiSchema();
assertNotNull(uiSchema);
assertEquals(1, uiSchema.size());
assertUiSchema(uiSchema.iterator().next(), "fieldset", "Configuration", "configuration", 2, schema -> {
final List<UiSchema> items = new ArrayList<>(schema.getItems());
items.sort(Comparator.comparing(UiSchema::getTitle));
final Iterator<UiSchema> it = items.iterator();
assertUiSchema(it.next(), "fieldset", "JDBC Connection", "configuration.connection", 5, connection -> {
final List<UiSchema> connectionItems = new ArrayList<>(connection.getItems());
connectionItems.sort(Comparator.comparing(UiSchema::getTitle));
final Iterator<UiSchema> connectionIt = connectionItems.iterator();
assertUiSchema(connectionIt.next(), "button", "Validate Datastore", "button_healthcheck_configuration.connection", 0, validateDataStore -> {
assertEquals(1, validateDataStore.getTriggers().size());
final UiSchema.Trigger trigger = validateDataStore.getTriggers().iterator().next();
assertEquals(4, trigger.getParameters().size());
assertEquals(Stream.of("driver", "password", "url", "username").map(p -> "configuration.connection." + p).collect(toSet()), trigger.getParameters().stream().map(UiSchema.Parameter::getPath).collect(toSet()));
assertEquals(Stream.of("driver", "password", "url", "username").map(p -> "datastore." + p).collect(toSet()), trigger.getParameters().stream().map(UiSchema.Parameter::getKey).collect(toSet()));
});
assertUiSchema(connectionIt.next(), "multiSelectTag", "driver", "configuration.connection.driver", 0, driver -> {
assertNotNull(driver.getTriggers());
assertEquals(1, driver.getTriggers().size());
final Collection<UiSchema.NameValue> titleMap = driver.getTitleMap();
assertEquals(1, titleMap.size());
final UiSchema.NameValue firstTitleMap = titleMap.iterator().next();
assertEquals("some.driver.Jdbc", firstTitleMap.getName());
assertEquals("Jdbc driver", firstTitleMap.getValue());
final UiSchema.Trigger trigger = driver.getTriggers().iterator().next();
assertEquals("driver", trigger.getAction());
assertEquals("jdbc", trigger.getFamily());
assertEquals("validation", trigger.getType());
assertEquals(1, trigger.getParameters().size());
final UiSchema.Parameter parameter = trigger.getParameters().iterator().next();
assertEquals("value", parameter.getKey());
assertEquals("configuration.connection.driver", parameter.getPath());
});
assertUiSchema(connectionIt.next(), "text", "password", "configuration.connection.password", 0, pwd -> {
assertEquals("password", pwd.getType());
});
assertUiSchema(connectionIt.next(), "text", "url", "configuration.connection.url", 0, url -> {
});
assertUiSchema(connectionIt.next(), "text", "username", "configuration.connection.username", 0, username -> {
});
assertFalse(connectionIt.hasNext());
});
assertUiSchema(it.next(), "fieldset", "query", "configuration.query", 2, query -> {
final List<UiSchema> queryItems = new ArrayList<>(query.getItems());
queryItems.sort(Comparator.comparing(UiSchema::getKey));
final Iterator<UiSchema> queryIt = queryItems.iterator();
assertUiSchema(queryIt.next(), "text", "query", "configuration.query.query", 0, q -> {
});
assertUiSchema(queryIt.next(), "text", "timeout", "configuration.query.timeout", 0, timeout -> {
});
assertFalse(queryIt.hasNext());
});
assertFalse(it.hasNext());
});
}
use of org.talend.sdk.component.form.model.Ui in project component-runtime by Talend.
the class UiSpecServiceTest method guessSchema.
@Test
void guessSchema() throws Exception {
final Ui payload = service.convert(load("rest-api.json")).toCompletableFuture().get();
final UiSchema root = payload.getUiSchema().iterator().next();
final UiSchema advanced = root.getItems().stream().filter(i -> i.getTitle().equals("Advanced")).findFirst().get();
final UiSchema commongConfig = advanced.getItems().stream().filter(i -> i.getTitle().equals("commonConfig")).findFirst().get();
assertTrue(commongConfig.getItems().stream().anyMatch(i -> i.getKey().equals("button_schema_tableDataSet.commonConfig")));
}
use of org.talend.sdk.component.form.model.Ui in project component-runtime by Talend.
the class UiSpecServiceTest method gridLayout.
@Test
void gridLayout() throws Exception {
final Ui payload = service.convert(load("rest-api.json")).toCompletableFuture().get();
final UiSchema tableDataSet = payload.getUiSchema().iterator().next();
assertEquals(2, tableDataSet.getItems().size());
final Iterator<UiSchema> tableDataSetIt = tableDataSet.getItems().iterator();
final UiSchema tableDataSetMain = tableDataSetIt.next();
assertEquals("Main", tableDataSetMain.getTitle());
assertEquals(5, tableDataSetMain.getItems().size());
assertEquals(asList("dataStore", "commonConfig", "Query", "Ordered", "Order"), tableDataSetMain.getItems().stream().map(UiSchema::getTitle).collect(toList()));
final Iterator<UiSchema> mainIt = tableDataSetMain.getItems().iterator();
final UiSchema dataStore = mainIt.next();
Iterator<UiSchema> dataStoreIt = dataStore.getItems().iterator();
dataStoreIt.next();
final UiSchema credentials = dataStoreIt.next();
assertEquals("columns", credentials.getWidget());
assertEquals(asList("Username", "Password"), credentials.getItems().stream().map(UiSchema::getTitle).collect(toList()));
final UiSchema tableDataSetAdvanced = tableDataSetIt.next();
assertEquals("Advanced", tableDataSetAdvanced.getTitle());
}
Aggregations