-
Notifications
You must be signed in to change notification settings - Fork 0
Add unit tests and fixes to class instrumentation #17
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
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
385f1af
test: add unit tests
javier-godoy 3d324a3
feat: implement toJson in UnsupportedJsonValueImpl
javier-godoy e71eab3
fix: instrument legacy callables in Vaadin 14-24
javier-godoy 596f7c5
fix: correct use of return opcodes
javier-godoy 9c101ac
fix: extract Jackson type mapping to helper class
javier-godoy 954619b
fix: check use of annotations in legacy framework versions
javier-godoy b1003d2
fix: make classloader cache non-static
javier-godoy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
src/main/java/com/flowingcode/vaadin/jsonmigration/ClassInstrumentationJacksonHelper.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package com.flowingcode.vaadin.jsonmigration; | ||
|
|
||
| import elemental.json.JsonArray; | ||
| import elemental.json.JsonBoolean; | ||
| import elemental.json.JsonNumber; | ||
| import elemental.json.JsonObject; | ||
| import elemental.json.JsonString; | ||
| import elemental.json.JsonValue; | ||
| import org.objectweb.asm.Type; | ||
| import tools.jackson.databind.JsonNode; | ||
| import tools.jackson.databind.node.ArrayNode; | ||
| import tools.jackson.databind.node.BooleanNode; | ||
| import tools.jackson.databind.node.DoubleNode; | ||
| import tools.jackson.databind.node.ObjectNode; | ||
| import tools.jackson.databind.node.StringNode; | ||
|
|
||
| class ClassInstrumentationJacksonHelper { | ||
|
|
||
| public static String getConvertedTypeDescriptor(Class<?> type) { | ||
| if (type == JsonObject.class) { | ||
| return Type.getDescriptor(ObjectNode.class); | ||
| } else if (type == JsonArray.class) { | ||
| return Type.getDescriptor(ArrayNode.class); | ||
| } else if (type == JsonBoolean.class) { | ||
| return Type.getDescriptor(BooleanNode.class); | ||
| } else if (type == JsonNumber.class) { | ||
| return Type.getDescriptor(DoubleNode.class); | ||
| } else if (type == JsonString.class) { | ||
| return Type.getDescriptor(StringNode.class); | ||
| } else if (JsonValue.class.isAssignableFrom(type)) { | ||
| return Type.getDescriptor(JsonNode.class); | ||
| } | ||
| return Type.getDescriptor(type); | ||
| } | ||
|
|
||
| } |
This file contains hidden or 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
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,5 +28,10 @@ public ElementalNullNode() { | |
| super(); | ||
| } | ||
|
|
||
| @Override | ||
| public String toJson() { | ||
| return null; | ||
| } | ||
|
|
||
| } | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
17 changes: 17 additions & 0 deletions
17
src/test/java/com/flowingcode/vaadin/jsonmigration/BaseClientCallable.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package com.flowingcode.vaadin.jsonmigration; | ||
|
|
||
| import com.vaadin.flow.component.html.Div; | ||
|
|
||
| public abstract class BaseClientCallable extends Div { | ||
|
|
||
| private boolean traced; | ||
|
|
||
| protected final void trace() { | ||
| traced = true; | ||
| } | ||
|
|
||
| public boolean hasBeenTraced() { | ||
| return traced; | ||
| } | ||
|
|
||
| } |
14 changes: 14 additions & 0 deletions
14
src/test/java/com/flowingcode/vaadin/jsonmigration/ClientCallable_D__V.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.flowingcode.vaadin.jsonmigration; | ||
|
|
||
|
|
||
| import com.vaadin.flow.component.ClientCallable; | ||
|
|
||
| public class ClientCallable_D__V extends BaseClientCallable { | ||
|
|
||
| @ClientCallable | ||
| public void test(double arg) { | ||
| trace(); | ||
| } | ||
| } | ||
|
|
||
|
|
14 changes: 14 additions & 0 deletions
14
src/test/java/com/flowingcode/vaadin/jsonmigration/ClientCallable_I__V.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| package com.flowingcode.vaadin.jsonmigration; | ||
|
|
||
|
|
||
| import com.vaadin.flow.component.ClientCallable; | ||
|
|
||
| public class ClientCallable_I__V extends BaseClientCallable { | ||
|
|
||
| @ClientCallable | ||
| public void test(int arg) { | ||
| trace(); | ||
| } | ||
| } | ||
|
|
||
|
|
16 changes: 16 additions & 0 deletions
16
src/test/java/com/flowingcode/vaadin/jsonmigration/ClientCallable_JsonArray__V.java
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| package com.flowingcode.vaadin.jsonmigration; | ||
|
|
||
|
|
||
| import com.vaadin.flow.component.ClientCallable; | ||
|
|
||
| import elemental.json.JsonArray; | ||
|
|
||
| public class ClientCallable_JsonArray__V extends BaseClientCallable { | ||
|
|
||
| @ClientCallable | ||
| public void test(JsonArray arg) { | ||
| trace(); | ||
| } | ||
| } | ||
|
|
||
|
|
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.