1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.juneau.a.rttests;
18
19 import static org.apache.juneau.TestUtils.*;
20 import static org.junit.jupiter.api.Assertions.*;
21
22 import org.apache.juneau.annotation.*;
23 import org.junit.jupiter.params.*;
24 import org.junit.jupiter.params.provider.*;
25
26
27
28
29
30 class Generics_RoundTripTest extends RoundTripTest_Base {
31
32
33
34
35
36 @ParameterizedTest
37 @MethodSource("testers")
38 void a01_beansWithUnboundTypeVars(RoundTrip_Tester t) throws Exception {
39
40 if (t.returnOriginalObject)
41 return;
42
43
44
45 var x = new Pair<Object,Object>(new Source().init(), new Target().init());
46 x = t.roundTrip(x);
47 assertBean(x, "s{s1},t{t1}", "{a1},{b1}");
48 assertEquals("JsonMap", x.getS().getClass().getSimpleName());
49 assertEquals("JsonMap", x.getT().getClass().getSimpleName());
50
51
52
53 x = t.roundTrip(x, RealPair.class);
54 assertBean(x, "s{s1},t{t1}", "{a1},{b1}");
55 assertEquals("Source", x.getS().getClass().getSimpleName());
56 assertEquals("Target", x.getT().getClass().getSimpleName());
57 }
58
59
60 @Bean(p="s,t")
61 public static class Pair<S,T> {
62
63 public Pair() {}
64
65 public Pair(S s, T t) {
66 this.s = s;
67 this.t = t;
68 }
69
70
71 private S s;
72 public S getS() { return s; }
73 public void setS(S v) { s = v; }
74
75 private T t;
76 public T getT() { return t; }
77 public void setT(T v) { t = v; }
78 }
79
80
81 public static class RealPair extends Pair<Source,Target> {}
82
83 public static class Source {
84 public String s1;
85 public Source init() {
86 s1 = "a1";
87 return this;
88 }
89 }
90
91 public static class Target {
92 public String t1;
93 public Target init() {
94 t1 = "b1";
95 return this;
96 }
97 }
98 }