Skip to content

Commit 3685f60

Browse files
javier-godoypaodb
authored andcommitted
test: add test for array of JsonString
1 parent 900c853 commit 3685f60

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*-
2+
* #%L
3+
* Json Migration Helper
4+
* %%
5+
* Copyright (C) 2025 Flowing Code
6+
* %%
7+
* Licensed under the Apache License, Version 2.0 (the "License");
8+
* you may not use this file except in compliance with the License.
9+
* You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing, software
14+
* distributed under the License is distributed on an "AS IS" BASIS,
15+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* See the License for the specific language governing permissions and
17+
* limitations under the License.
18+
* #L%
19+
*/
20+
package com.flowingcode.vaadin.jsonmigration;
21+
22+
import static org.hamcrest.MatcherAssert.assertThat;
23+
import static org.hamcrest.Matchers.emptyArray;
24+
import static org.hamcrest.Matchers.not;
25+
import static org.hamcrest.Matchers.notNullValue;
26+
import elemental.json.JsonString;
27+
import org.hamcrest.Matchers;
28+
29+
public class LegacyClientCallable_ArrayOfJsonString__V extends BaseClientCallable {
30+
31+
@LegacyClientCallable
32+
public void test(JsonString[] arg) {
33+
assertThat(arg, notNullValue());
34+
assertThat(arg, not(emptyArray()));
35+
assertThat(arg, Matchers.instanceOf(JsonString[].class));
36+
trace();
37+
}
38+
}

src/test/java/com/flowingcode/vaadin/jsonmigration/LegacyClientCallablesTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ private static Object invokeTestMethod(BaseClientCallable instrumented, Object..
7979

8080
protected abstract Object createArrayOfJsonObject();
8181

82+
protected abstract Object createArrayOfJsonString();
83+
8284
@Test
8385
public void test__V() throws Exception {
8486
LegacyClientCallable__V instrumented =
@@ -315,6 +317,15 @@ public void test_JsonObject__V() throws Exception {
315317
assertTrue(instrumented.hasBeenTraced());
316318
}
317319

320+
@Test
321+
public void test_ArrayOfJsonString__V() throws Exception {
322+
LegacyClientCallable_ArrayOfJsonString__V instrumented =
323+
instrumentClass(LegacyClientCallable_ArrayOfJsonString__V.class).getDeclaredConstructor()
324+
.newInstance();
325+
invokeTestMethod(instrumented, createArrayOfJsonString());
326+
assertTrue(instrumented.hasBeenTraced());
327+
}
328+
318329
@Test
319330
public void test_ArrayOfJsonObject__V() throws Exception {
320331
LegacyClientCallable_ArrayOfJsonObject__V instrumented =

src/test/java/com/flowingcode/vaadin/jsonmigration/LegacyClientCallablesTest24.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.vaadin.flow.component.Component;
2323
import elemental.json.Json;
2424
import elemental.json.JsonObject;
25+
import elemental.json.JsonString;
2526

2627
public class LegacyClientCallablesTest24 extends LegacyClientCallablesTest {
2728

@@ -46,7 +47,7 @@ protected Object createJsonNumber() {
4647
}
4748

4849
@Override
49-
protected Object createJsonString() {
50+
protected JsonString createJsonString() {
5051
return Json.create("test");
5152
}
5253

@@ -65,4 +66,9 @@ protected Object createArrayOfJsonObject() {
6566
return new JsonObject[] {createJsonObject(), createJsonObject()};
6667
}
6768

69+
@Override
70+
protected Object createArrayOfJsonString() {
71+
return new JsonString[] {createJsonString(), createJsonString()};
72+
}
73+
6874
}

src/test/java/com/flowingcode/vaadin/jsonmigration/LegacyClientCallablesTest25.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected Object createJsonNumber() {
5252
}
5353

5454
@Override
55-
protected Object createJsonString() {
55+
protected StringNode createJsonString() {
5656
return StringNode.valueOf("test");
5757
}
5858

@@ -71,4 +71,9 @@ protected Object createArrayOfJsonObject() {
7171
return new ObjectNode[] {createJsonObject(), createJsonObject()};
7272
}
7373

74+
@Override
75+
protected Object createArrayOfJsonString() {
76+
return new StringNode[] {createJsonString(), createJsonString()};
77+
}
78+
7479
}

0 commit comments

Comments
 (0)