-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(TCOMP-2100): backlog tasks #892
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/component-server-parent/component-server/src/main/java/org/talend/sdk/component/server/front/ComponentResourceImpl.java b/component-server-parent/component-server/src/main/java/org/talend/sdk/component/server/front/ComponentResourceImpl.java index 3d47f106411..74b31d1dee2 100644 --- a/component-server-parent/component-server/src/main/java/org/talend/sdk/component/server/front/ComponentResourceImpl.java +++ b/component-server-parent/component-server/src/main/java/org/talend/sdk/component/server/front/ComponentResourceImpl.java @@ -149,7 +149,7 @@ public class ComponentResourceImpl implements ComponentResource { public static final String THEME_ALL = "all"; - public static final String MEDIA_TYPE_SVG_XML = "image/svg+xml"; + public static final String IMAGE_SVG_XML_TYPE = "image/svg+xml"; private final ConcurrentMap<RequestKey, ComponentIndices> indicesPerRequest = new ConcurrentHashMap<>(); @@ -534,7 +534,7 @@ public class ComponentResourceImpl implements ComponentResource { .replace("<", "<") .replace(">", ">"); - return Response.ok(svgs).type(MEDIA_TYPE_SVG_XML).build(); + return Response.ok(svgs).type(IMAGE_SVG_XML_TYPE).build(); } catch (Exception e) { log.error("[getIconIndex] {}", e.getMessage()); return Response @@ -669,7 +669,7 @@ public class ComponentResourceImpl implements ComponentResource { Map<String, IconSymbol> icons = components .stream() .filter(c -> c.getIconFamily().getCustomIcon() != null) - .filter(c -> MEDIA_TYPE_SVG_XML.equals(c.getIconFamily().getCustomIconType())) + .filter(c -> IMAGE_SVG_XML_TYPE.equals(c.getIconFamily().getCustomIconType())) .map(c -> new IconSymbol(c.getIconFamily().getIcon(), c.getFamilyDisplayName(), "family", @@ -680,7 +680,7 @@ public class ComponentResourceImpl implements ComponentResource { icons.putAll(components .stream() .filter(c -> c.getIcon().getCustomIcon() != null) - .filter(c -> MEDIA_TYPE_SVG_XML.equals(c.getIcon().getCustomIconType())) + .filter(c -> IMAGE_SVG_XML_TYPE.equals(c.getIcon().getCustomIconType())) .map(c -> new IconSymbol(c.getIcon().getIcon(), c.getFamilyDisplayName(), "connector", diff --git a/component-server-parent/component-server/src/test/java/org/talend/sdk/component/server/front/ComponentResourceImplTest.java b/component-server-parent/component-server/src/test/java/org/talend/sdk/component/server/front/ComponentResourceImplTest.java index b9763b6dcdc..a656ae81994 100644 --- a/component-server-parent/component-server/src/test/java/org/talend/sdk/component/server/front/ComponentResourceImplTest.java +++ b/component-server-parent/component-server/src/test/java/org/talend/sdk/component/server/front/ComponentResourceImplTest.java @@ -29,7 +29,7 @@ import static org.junit.jupiter.api.Assertions.fail; import static org.talend.sdk.component.server.front.ComponentResourceImpl.COMPONENT_TYPE_INPUT; import static org.talend.sdk.component.server.front.ComponentResourceImpl.COMPONENT_TYPE_PROCESSOR; import static org.talend.sdk.component.server.front.ComponentResourceImpl.COMPONENT_TYPE_STANDALONE; -import static org.talend.sdk.component.server.front.ComponentResourceImpl.MEDIA_TYPE_SVG_XML; +import static org.talend.sdk.component.server.front.ComponentResourceImpl.IMAGE_SVG_XML_TYPE; import java.io.File; import java.io.FileOutputStream; @@ -248,7 +248,7 @@ class ComponentResourceImplTest { .accept(APPLICATION_OCTET_STREAM_TYPE) .get(Response.class); assertNotNull(icon); - assertEquals(MEDIA_TYPE_SVG_XML, icon.getMediaType().toString()); + assertEquals(IMAGE_SVG_XML_TYPE, icon.getMediaType().toString()); } @test @@ -270,7 +270,7 @@ class ComponentResourceImplTest { .accept(APPLICATION_OCTET_STREAM_TYPE) .get(Response.class); assertNotNull(icon); - assertEquals(MEDIA_TYPE_SVG_XML, icon.getMediaType().toString()); + assertEquals(IMAGE_SVG_XML_TYPE, icon.getMediaType().toString()); assertThrows(NotFoundException.class, () -> base.path("component/icon/family/{id}") .resolveTemplate("id", family) @@ -322,17 +322,33 @@ class ComponentResourceImplTest { @test void getIconIndex() { - // content type + // wrong content type Response icons = base.path("component/icon/index") .request(APPLICATION_SVG_XML_TYPE) .accept(APPLICATION_SVG_XML_TYPE) .get(); assertNotNull(icons); - assertEquals(APPLICATION_SVG_XML_TYPE, icons.getMediaType()); + assertEquals(406, icons.getStatus()); + // inexistant theme (no fallback) + icons = base.path("component/icon/index") + .queryParam("theme", "dak") + .request(IMAGE_SVG_XML_TYPE) + .accept(IMAGE_SVG_XML_TYPE) + .get(); + assertEquals(404, icons.getStatus()); + assertEquals(APPLICATION_JSON_TYPE, icons.getMediaType()); + + // content type + icons = base.path("component/icon/index") + .request(IMAGE_SVG_XML_TYPE) + .accept(IMAGE_SVG_XML_TYPE, APPLICATION_JSON_TYPE.toString()) + .get(); + assertNotNull(icons); + assertEquals(IMAGE_SVG_XML_TYPE, icons.getMediaType().toString()); // default: light theme String content = base.path("component/icon/index") - .request(APPLICATION_SVG_XML_TYPE) - .accept(APPLICATION_SVG_XML_TYPE) + .request(IMAGE_SVG_XML_TYPE) + .accept(IMAGE_SVG_XML_TYPE) .get(String.class); assertNotNull(content); assertTrue( @@ -345,8 +361,8 @@ class ComponentResourceImplTest { // light theme content = base.path("component/icon/index") .queryParam("theme", "light") - .request(APPLICATION_SVG_XML_TYPE) - .accept(APPLICATION_SVG_XML_TYPE) + .request(IMAGE_SVG_XML_TYPE) + .accept(IMAGE_SVG_XML_TYPE) .get(String.class); assertNotNull(content); assertTrue( @@ -360,8 +376,8 @@ class ComponentResourceImplTest { // dark theme content = base.path("component/icon/index") .queryParam("theme", "dark") - .request(APPLICATION_SVG_XML_TYPE) - .accept(APPLICATION_SVG_XML_TYPE) + .request(IMAGE_SVG_XML_TYPE) + .accept(IMAGE_SVG_XML_TYPE) .get(String.class); assertNotNull(content); assertTrue( @@ -374,8 +390,8 @@ class ComponentResourceImplTest { // theme = all content = base.path("component/icon/index") .queryParam("theme", "all") - .request(APPLICATION_SVG_XML_TYPE) - .accept(APPLICATION_SVG_XML_TYPE) + .request(IMAGE_SVG_XML_TYPE) + .accept(IMAGE_SVG_XML_TYPE) .get(String.class); assertNotNull(content); assertTrue( @@ -389,14 +405,6 @@ class ComponentResourceImplTest { "connector=\"standalone\" family=\"chain\" id=\"myicon\" theme=\"light\" type=\"connector\"")); assertTrue( content.contains("connector=\"\" family=\"file\" id=\"file-family\" theme=\"light\" type=\"family\"")); - // inexistant theme (no fallback) - icons = base.path("component/icon/index") - .queryParam("theme", "dak") - .request(APPLICATION_SVG_XML_TYPE) - .accept(APPLICATION_SVG_XML_TYPE) - .get(); - assertEquals(404, icons.getStatus()); - assertEquals(APPLICATION_JSON_TYPE, icons.getMediaType()); } @test @@ -691,7 +699,7 @@ class ComponentResourceImplTest { assertEquals("light", data.getIcon().getTheme()); assertTrue(new String(data.getIcon().getCustomIcon(), StandardCharsets.UTF_8) .startsWith("<svg xmlns=\"http://www.w3.org/2000/svg\"")); - assertEquals(MEDIA_TYPE_SVG_XML, data.getIcon().getCustomIconType()); + assertEquals(IMAGE_SVG_XML_TYPE, data.getIcon().getCustomIconType()); assertEquals(singletonList("Misc/" + data.getFamilyDisplayName()), data.getCategories()); } else { assertEquals(singletonList("Misc/" + data.getFamilyDisplayName()), data.getCategories()); diff --git a/component-server-parent/component-server/src/test/java/org/talend/sdk/component/server/service/IconResolverTest.java b/component-server-parent/component-server/src/test/java/org/talend/sdk/component/server/service/IconResolverTest.java index 594decda0aa..7ee94341762 100644 --- a/component-server-parent/component-server/src/test/java/org/talend/sdk/component/server/service/IconResolverTest.java +++ b/component-server-parent/component-server/src/test/java/org/talend/sdk/component/server/service/IconResolverTest.java @@ -18,7 +18,7 @@ package org.talend.sdk.component.server.service; import static org.junit.Assert.assertNull; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.talend.sdk.component.server.front.ComponentResourceImpl.MEDIA_TYPE_SVG_XML; +import static org.talend.sdk.component.server.front.ComponentResourceImpl.IMAGE_SVG_XML_TYPE; import static org.talend.sdk.component.server.front.ComponentResourceImpl.THEME_DARK; import static org.talend.sdk.component.server.front.ComponentResourceImpl.THEME_LIGHT; @@ -68,12 +68,12 @@ class IconResolverTest { // IconResolver.Icon icon = resolver.resolve(plugin, "logo", THEME_DARK); assertNotNull(icon); - assertEquals(MEDIA_TYPE_SVG_XML, icon.getType()); + assertEquals(IMAGE_SVG_XML_TYPE, icon.getType()); assertEquals(THEME_DARK, icon.getTheme()); // icon = resolver.resolve(plugin, PLUGIN_DB_INPUT, THEME_DARK); assertNotNull(icon); - assertEquals(MEDIA_TYPE_SVG_XML, icon.getType()); + assertEquals(IMAGE_SVG_XML_TYPE, icon.getType()); assertEquals(THEME_DARK, icon.getTheme()); // icon = resolver.resolve(plugin, PLUGIN_DB_INPUT, THEME_LIGHT);
Analysis Details0 IssuesCoverage and DuplicationsProject ID: org.talend.sdk.component:component-runtime |
acatoire
approved these changes
May 29, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
acatoire
pushed a commit
that referenced
this pull request
May 29, 2024
Backlog tasks for https://jira.talendforge.org/browse/TCOMP-2100 Backlog Tasks https://jira.talendforge.org/browse/TCOMP-2731: media type https://jira.talendforge.org/browse/TCOMP-2723: normalize xml attribute names (cherry picked from commit ff37627)
acatoire
pushed a commit
that referenced
this pull request
Jul 11, 2024
Backlog tasks for https://jira.talendforge.org/browse/TCOMP-2100 Backlog Tasks https://jira.talendforge.org/browse/TCOMP-2731: media type https://jira.talendforge.org/browse/TCOMP-2723: normalize xml attribute names (cherry picked from commit ff37627)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backlog tasks for https://jira.talendforge.org/browse/TCOMP-2100
Backlog Tasks