1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.juneau.jsonschema.annotation;
18
19 import static org.apache.juneau.TestUtils.*;
20 import static org.junit.jupiter.api.Assertions.*;
21
22 import org.apache.juneau.*;
23 import org.apache.juneau.annotation.*;
24 import org.junit.jupiter.api.*;
25
26 class SubItemsAnnotation_Test extends TestBase {
27
28
29
30
31
32 SubItems a1 = SubItemsAnnotation.create()
33 .$ref("a")
34 ._default("b")
35 ._enum("c")
36 .cf("d")
37 .collectionFormat("e")
38 .description("f")
39 .df("g")
40 .e("h")
41 .emax(true)
42 .emin(true)
43 .exclusiveMaximum(true)
44 .exclusiveMinimum(true)
45 .f("i")
46 .format("j")
47 .max("k")
48 .maxi(1)
49 .maximum("l")
50 .maxItems(2)
51 .maxl(3)
52 .maxLength(4)
53 .min("m")
54 .mini(5)
55 .minimum("n")
56 .minItems(6)
57 .minl(7)
58 .minLength(8)
59 .mo("o")
60 .multipleOf("p")
61 .p("q")
62 .pattern("r")
63 .t("s")
64 .type("t")
65 .ui(true)
66 .uniqueItems(true)
67 .build();
68
69 SubItems a2 = SubItemsAnnotation.create()
70 .$ref("a")
71 ._default("b")
72 ._enum("c")
73 .cf("d")
74 .collectionFormat("e")
75 .description("f")
76 .df("g")
77 .e("h")
78 .emax(true)
79 .emin(true)
80 .exclusiveMaximum(true)
81 .exclusiveMinimum(true)
82 .f("i")
83 .format("j")
84 .max("k")
85 .maxi(1)
86 .maximum("l")
87 .maxItems(2)
88 .maxl(3)
89 .maxLength(4)
90 .min("m")
91 .mini(5)
92 .minimum("n")
93 .minItems(6)
94 .minl(7)
95 .minLength(8)
96 .mo("o")
97 .multipleOf("p")
98 .p("q")
99 .pattern("r")
100 .t("s")
101 .type("t")
102 .ui(true)
103 .uniqueItems(true)
104 .build();
105
106 @Test void a01_basic() {
107 assertBean(a1, "$ref,_default,_enum,cf,collectionFormat,description,df,e,emax,emin,exclusiveMaximum,exclusiveMinimum,f,format,items,max,maxItems,maxLength,maxi,maximum,maxl,min,minItems,minLength,mini,minimum,minl,mo,multipleOf,p,pattern,t,type,ui,uniqueItems", "a,[b],[c],d,e,[f],[g],[h],true,true,true,true,i,j,[],k,2,4,1,l,3,m,6,8,5,n,7,o,p,q,r,s,t,true,true");
108 }
109
110 @Test void a02_testEquivalency() {
111 assertEquals(a2, a1);
112 assertNotEqualsAny(a1.hashCode(), 0, -1);
113 assertEquals(a1.hashCode(), a2.hashCode());
114 }
115
116
117
118
119
120 @Test void b01_testEquivalencyInPropertyStores() {
121 var bc1 = BeanContext.create().annotations(a1).build();
122 var bc2 = BeanContext.create().annotations(a2).build();
123 assertSame(bc1, bc2);
124 }
125
126
127
128
129
130
131
132
133
134 @SubItems(
135 $ref="a",
136 _default="b",
137 _enum="c",
138 cf="d",
139 collectionFormat="e",
140 description={ "f" },
141 df="g",
142 e="h",
143 emax=true,
144 emin=true,
145 exclusiveMaximum=true,
146 exclusiveMinimum=true,
147 f="i",
148 format="j",
149 max="k",
150 maxi=1,
151 maximum="l",
152 maxItems=2,
153 maxl=3,
154 maxLength=4,
155 min="m",
156 mini=5,
157 minimum="n",
158 minItems=6,
159 minl=7,
160 minLength=8,
161 mo="o",
162 multipleOf="p",
163 p="q",
164 pattern="r",
165 t="s",
166 type="t",
167 ui=true,
168 uniqueItems=true
169 )
170 public static class D1 {}
171 SubItems d1 = D1.class.getAnnotationsByType(SubItems.class)[0];
172
173 @SubItems(
174 $ref="a",
175 _default="b",
176 _enum="c",
177 cf="d",
178 collectionFormat="e",
179 description={ "f" },
180 df="g",
181 e="h",
182 emax=true,
183 emin=true,
184 exclusiveMaximum=true,
185 exclusiveMinimum=true,
186 f="i",
187 format="j",
188 max="k",
189 maxi=1,
190 maximum="l",
191 maxItems=2,
192 maxl=3,
193 maxLength=4,
194 min="m",
195 mini=5,
196 minimum="n",
197 minItems=6,
198 minl=7,
199 minLength=8,
200 mo="o",
201 multipleOf="p",
202 p="q",
203 pattern="r",
204 t="s",
205 type="t",
206 ui=true,
207 uniqueItems=true
208 )
209 public static class D2 {}
210 SubItems d2 = D2.class.getAnnotationsByType(SubItems.class)[0];
211
212 @Test void d01_comparisonWithDeclarativeAnnotations() {
213 assertEqualsAll(a1, d1, d2);
214 assertNotEqualsAny(a1.hashCode(), 0, -1);
215 assertEqualsAll(a1.hashCode(), d1.hashCode(), d2.hashCode());
216 }
217 }