use of org.talend.sdk.component.server.front.model.Link in project component-runtime by Talend.
the class ComponentResourceTest method assertComponent.
private void assertComponent(final String plugin, final String family, final String name, final String displayName, final Iterator<ComponentIndex> component, final int version) {
assertTrue(component.hasNext());
final ComponentIndex data = component.next();
assertEquals(family, data.getId().getFamily());
assertEquals(name, data.getId().getName());
assertEquals(plugin, data.getId().getPlugin());
assertEquals(displayName, data.getDisplayName());
assertEquals(version, data.getVersion());
assertEquals(singletonList("Misc"), data.getCategories());
assertEquals(1, data.getLinks().size());
final Link link = data.getLinks().iterator().next();
assertEquals("Detail", link.getName());
assertEquals("/component/details?identifiers=" + Base64.getUrlEncoder().withoutPadding().encodeToString((plugin + "#" + family + "#" + name).getBytes(StandardCharsets.UTF_8)), link.getPath());
assertEquals(MediaType.APPLICATION_JSON, link.getContentType());
if ("jdbc".equals(data.getId().getFamily()) && "input".equals(data.getId().getName())) {
assertEquals("db-input", data.getIcon().getIcon());
assertNotNull(data.getIcon().getCustomIcon());
assertEquals("image/png", data.getIcon().getCustomIconType());
} else {
assertEquals("default", data.getIcon().getIcon());
}
}
use of org.talend.sdk.component.server.front.model.Link in project component-runtime by Talend.
the class ComponentResource method toComponentIndex.
private ComponentIndex toComponentIndex(final ClassLoader loader, final Locale locale, final String plugin, final ComponentFamilyMeta.BaseMeta meta, final ComponentManager.OriginalId originalId, final boolean includeIcon) {
final String icon = meta.getIcon();
final String familyIcon = meta.getParent().getIcon();
final IconResolver.Icon iconContent = iconResolver.resolve(loader, icon);
final IconResolver.Icon iconFamilyContent = iconResolver.resolve(loader, familyIcon);
return new ComponentIndex(new ComponentId(meta.getId(), meta.getParent().getId(), plugin, ofNullable(originalId).map(ComponentManager.OriginalId::getValue).orElse(plugin), meta.getParent().getName(), meta.getName()), meta.findBundle(loader, locale).displayName().orElse(meta.getName()), meta.getParent().findBundle(loader, locale).displayName().orElse(meta.getParent().getName()), new Icon(icon, iconContent == null ? null : iconContent.getType(), !includeIcon ? null : (iconContent == null ? null : iconContent.getBytes())), new Icon(familyIcon, iconFamilyContent == null ? null : iconFamilyContent.getType(), !includeIcon ? null : (iconFamilyContent == null ? null : iconFamilyContent.getBytes())), meta.getVersion(), meta.getParent().getCategories(), singletonList(new Link("Detail", "/component/details?identifiers=" + meta.getId(), MediaType.APPLICATION_JSON)));
}
use of org.talend.sdk.component.server.front.model.Link in project component-runtime by Talend.
the class ComponentResourceTest method getDetails.
@Test
void getDetails() {
final ComponentDetailList details = base.path("component/details").queryParam("identifiers", client.fetchIndex().getComponents().stream().filter(c -> c.getId().getFamily().equals("chain") && c.getId().getName().equals("list")).findFirst().orElseThrow(() -> new IllegalArgumentException("no chain#list component")).getId().getId()).request(APPLICATION_JSON_TYPE).get(ComponentDetailList.class);
assertEquals(1, details.getDetails().size());
final ComponentDetail detail = details.getDetails().iterator().next();
assertEquals("the-test-component", detail.getId().getPlugin());
assertEquals("chain", detail.getId().getFamily());
assertEquals("list", detail.getId().getName());
assertEquals("The List Component", detail.getDisplayName());
final Collection<ActionReference> remoteActions = detail.getActions();
assertEquals(1, remoteActions.size());
final ActionReference action = remoteActions.iterator().next();
assertEquals("default", action.getName());
assertEquals("healthcheck", action.getType());
assertEquals(6, action.getProperties().size());
assertValidation("remote.urls", detail, validation -> validation.getMinItems() == 1);
assertValidation("remote.urls", detail, validation -> validation.getUniqueItems() != null && validation.getUniqueItems());
assertValidation("remote.user.user", detail, validation -> validation.getMinLength() != null && validation.getMinLength() == 2);
assertValidation("remote.user.password", detail, validation -> validation.getMaxLength() != null && validation.getMaxLength() == 8);
assertValidation("remote.user.password", detail, validation -> validation.getRequired() != null && validation.getRequired());
// for now
assertEquals(0, detail.getLinks().size());
/*
* final Link link = detail.getLinks().iterator().next(); assertEquals("Detail", link.getName());
* assertEquals("/component/...", link.getPath());
*/
}
Aggregations