-
Notifications
You must be signed in to change notification settings - Fork 105
[682] Correct the fix for 670 and return the type if the type has alr… #683
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -52,6 +52,7 @@ | |||||||||||||||||||||
| import org.eclipse.yasson.defaultmapping.generics.model.GenericArrayClass; | ||||||||||||||||||||||
| import org.eclipse.yasson.defaultmapping.generics.model.GenericTestClass; | ||||||||||||||||||||||
| import org.eclipse.yasson.defaultmapping.generics.model.GenericWithUnboundedWildcardClass; | ||||||||||||||||||||||
| import org.eclipse.yasson.defaultmapping.generics.model.ListContainer; | ||||||||||||||||||||||
| import org.eclipse.yasson.defaultmapping.generics.model.LowerBoundTypeVariableWithCollectionAttributeClass; | ||||||||||||||||||||||
| import org.eclipse.yasson.defaultmapping.generics.model.MultiLevelExtendedGenericTestClass; | ||||||||||||||||||||||
| import org.eclipse.yasson.defaultmapping.generics.model.MultipleBoundsContainer; | ||||||||||||||||||||||
|
|
@@ -516,14 +517,32 @@ public void wildcardCollectionContainer() { | |||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @Test | ||||||||||||||||||||||
| public void genericUpperBoundContainer() { | ||||||||||||||||||||||
| final String expectedJson = "{\"tree\":{\"children\":[{\"children\":[],\"name\":\"child\"}],\"name\":\"parent\"}}"; | ||||||||||||||||||||||
| public void genericUpperBoundContainer() throws Exception { | ||||||||||||||||||||||
| final String expectedJson = "{\"tree\":{\"children\":[{\"name\":\"child\"}],\"name\":\"parent\"}}"; | ||||||||||||||||||||||
| final TreeContainer<TreeElement> container = new TreeContainer<>(); | ||||||||||||||||||||||
| final TreeElement parent = new TreeElement("parent"); | ||||||||||||||||||||||
| parent.setChildren(List.of(new TreeElement("child"))); | ||||||||||||||||||||||
| container.setTree(parent); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| assertEquals(expectedJson, defaultJsonb.toJson(container)); | ||||||||||||||||||||||
| // Use a new instance of Jsonb to avoid any caching | ||||||||||||||||||||||
| try (var jsonb = JsonbBuilder.create()) { | ||||||||||||||||||||||
| assertEquals(expectedJson, jsonb.toJson(container)); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @Test | ||||||||||||||||||||||
| public void genericUpperBoundContainerWithListContainer() throws Exception { | ||||||||||||||||||||||
| final String expectedJson = "{\"list\":[{\"children\":[{\"name\":\"child\"}],\"name\":\"parent\"}]}"; | ||||||||||||||||||||||
| final ListContainer<TreeElement> container = new ListContainer<>(); | ||||||||||||||||||||||
| final TreeElement parent = new TreeElement("parent"); | ||||||||||||||||||||||
| parent.setChildren(List.of(new TreeElement("child"))); | ||||||||||||||||||||||
| container.setList(List.of(parent)); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Use a new instance of Jsonb to avoid any caching | ||||||||||||||||||||||
| try (var jsonb = JsonbBuilder.create()) { | ||||||||||||||||||||||
| assertEquals(expectedJson, jsonb.toJson(container)); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+542
to
+545
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Requires addition of: import static org.junit.jupiter.api.Assertions.assertIterableEquals; |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| /* | ||
| * Copyright (c) 2025 IBM, Inc. and/or its affiliates. | ||
| * | ||
| * This program and the accompanying materials are made available under the | ||
| * terms of the Eclipse Public License v. 2.0 which is available at | ||
| * http://www.eclipse.org/legal/epl-2.0, | ||
| * or the Eclipse Distribution License v. 1.0 which is available at | ||
| * http://www.eclipse.org/org/documents/edl-v10.php. | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause | ||
| */ | ||
|
|
||
| package org.eclipse.yasson.defaultmapping.generics.model; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * | ||
| * @author <a href="mailto:jperkins@ibm.com">James R. Perkins</a> | ||
| */ | ||
| public class ListContainer<T> { | ||
|
|
||
| private List<T> list; | ||
|
|
||
| public List<T> getList() { | ||
| return list; | ||
| } | ||
|
|
||
| public void setList(List<T> list) { | ||
| this.list = list; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,16 +12,12 @@ | |||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| package org.eclipse.yasson.defaultmapping.generics.model; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| import java.util.ArrayList; | ||||||||||||||||||||||||||||||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||||||||||
| * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> | ||||||||||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||||||||||
| public class TreeElement implements TreeTypeContainer<TreeElement> { | ||||||||||||||||||||||||||||||||||||||||||||||||
| public class TreeElement extends TreeTypeContainer<TreeElement> { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| private final String name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
suggestion: allow for deserialization |
||||||||||||||||||||||||||||||||||||||||||||||||
| private List<TreeElement> children = new ArrayList<>(); | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| public TreeElement(final String name) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| this.name = name; | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -30,12 +26,4 @@ public TreeElement(final String name) { | |||||||||||||||||||||||||||||||||||||||||||||||
| public String getName() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return name; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| public List<TreeElement> getChildren() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| return children; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| public void setChildren(final List<TreeElement> children) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| this.children = children; | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
suggestion: allow for deserialization and assertions. |
||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,9 +17,14 @@ | |||||||||||||||||||||||||||||||||||||||
| /** | ||||||||||||||||||||||||||||||||||||||||
| * @author <a href="mailto:jperkins@redhat.com">James R. Perkins</a> | ||||||||||||||||||||||||||||||||||||||||
| */ | ||||||||||||||||||||||||||||||||||||||||
| public interface TreeTypeContainer<T extends TreeTypeContainer<T>> { | ||||||||||||||||||||||||||||||||||||||||
| public class TreeTypeContainer<T extends TreeTypeContainer<T>> { | ||||||||||||||||||||||||||||||||||||||||
| private List<T> children; | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| List<T> getChildren(); | ||||||||||||||||||||||||||||||||||||||||
| public List<T> getChildren() { | ||||||||||||||||||||||||||||||||||||||||
| return children; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||
| void setChildren(List<T> children); | ||||||||||||||||||||||||||||||||||||||||
| public void setChildren(final List<T> children) { | ||||||||||||||||||||||||||||||||||||||||
| this.children = children; | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Suggestion: allow for assertions. |
||||||||||||||||||||||||||||||||||||||||
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.
Requires addition of: