use of org.talend.sdk.component.server.front.model.ComponentIndex 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.ComponentIndex 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)));
}
Aggregations