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.junit.jupiter.api.Assertions.*;
20
21 import org.apache.juneau.annotation.*;
22 import org.junit.jupiter.params.*;
23 import org.junit.jupiter.params.provider.*;
24
25
26
27
28
29 class ReadOnlyBeans_RoundTripTest extends RoundTripTest_Base {
30
31
32
33
34
35 @ParameterizedTest
36 @MethodSource("testers")
37 void a01_basic(RoundTrip_Tester t) throws Exception {
38 var x1 = new B(1, "a");
39 var x2 = new B(2, "b");
40 var x3 = new A(x1, x2);
41
42 x3 = t.roundTrip(x3, A.class);
43 assertEquals(1, x3.getF1().getF1());
44 assertEquals("a", x3.getF1().getF2());
45 assertEquals(2, x3.getF2().getF1());
46 assertEquals("b", x3.getF2().getF2());
47 }
48
49 public static class A {
50 private B f1;
51 private final B f2;
52
53 @Beanc(properties="f2")
54 public A(B f2) {
55 this.f2 = f2;
56 }
57
58 public A(B f1, B f2) {
59 this.f1 = f1;
60 this.f2 = f2;
61 }
62
63 public B getF1() { return f1; }
64 public void setF1(B v) { f1 = v; }
65
66 public B getF2() { return f2; }
67 }
68
69 public static class B {
70 private int f1;
71 private final String f2;
72
73 @Beanc(properties="f2")
74 public B(String sField) {
75 this.f2 = sField;
76 }
77
78 public B(int iField, String sField) {
79 this.f1 = iField;
80 this.f2 = sField;
81 }
82
83 public int getF1() { return f1;}
84 public void setF1(int v) { f1 = v; }
85
86 public String getF2() { return f2; }
87 }
88 }