1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.juneau.rest.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.encoders.*;
24 import org.apache.juneau.rest.guard.*;
25 import org.apache.juneau.rest.matcher.*;
26 import org.junit.jupiter.api.*;
27
28 class RestDeleteAnnotation_Test extends TestBase {
29
30 private static final String CNAME = RestDeleteAnnotation_Test.class.getName();
31
32
33
34
35
36 RestDelete a1 = RestDeleteAnnotation.create()
37 .clientVersion("a")
38 .debug("b")
39 .defaultAccept("c")
40 .defaultCharset("d")
41 .defaultRequestQueryData("e")
42 .defaultRequestAttributes("f")
43 .defaultRequestHeaders("g")
44 .defaultResponseHeaders("h")
45 .description("i")
46 .encoders(Encoder.class)
47 .guards(RestGuard.class)
48 .matchers(RestMatcher.class)
49 .on("j")
50 .path("k")
51 .roleGuard("l")
52 .rolesDeclared("m")
53 .summary("n")
54 .swagger(OpSwaggerAnnotation.DEFAULT)
55 .value("o")
56 .build();
57
58 RestDelete a2 = RestDeleteAnnotation.create()
59 .clientVersion("a")
60 .debug("b")
61 .defaultAccept("c")
62 .defaultCharset("d")
63 .defaultRequestQueryData("e")
64 .defaultRequestAttributes("f")
65 .defaultRequestHeaders("g")
66 .defaultResponseHeaders("h")
67 .description("i")
68 .encoders(Encoder.class)
69 .guards(RestGuard.class)
70 .matchers(RestMatcher.class)
71 .on("j")
72 .path("k")
73 .roleGuard("l")
74 .rolesDeclared("m")
75 .summary("n")
76 .swagger(OpSwaggerAnnotation.DEFAULT)
77 .value("o")
78 .build();
79
80 @Test void a01_basic() {
81 assertBean(a1,
82 "clientVersion,debug,defaultAccept,defaultCharset,defaultRequestAttributes,defaultRequestHeaders,defaultRequestQueryData,defaultResponseHeaders,description,encoders,guards,matchers,on,path,roleGuard,rolesDeclared,summary,swagger{consumes,deprecated,description,externalDocs{description,url},operationId,parameters,produces,responses,schemes,summary,tags,value},value",
83 "a,b,c,d,[f],[g],[e],[h],[i],[Encoder],[RestGuard],[RestMatcher],[j],[k],l,m,n,{[],,[],{[],},,[],[],[],[],[],[],[]},o");
84 }
85
86 @Test void a02_testEquivalency() {
87 assertEquals(a2, a1);
88 assertNotEqualsAny(a1.hashCode(), 0, -1);
89 assertEquals(a1.hashCode(), a2.hashCode());
90 }
91
92
93
94
95
96 @Test void b01_testEquivalencyInPropertyStores() {
97 var bc1 = BeanContext.create().annotations(a1).build();
98 var bc2 = BeanContext.create().annotations(a2).build();
99 assertSame(bc1, bc2);
100 }
101
102
103
104
105
106 public static class C1 {
107 public int f1;
108 public void m1() {}
109 }
110 public static class C2 {
111 public int f2;
112 public void m2() {}
113 }
114
115 @Test void c01_otherMethods() throws Exception {
116 var c4 = RestDeleteAnnotation.create().on(C1.class.getMethod("m1")).on(C2.class.getMethod("m2")).build();
117
118 assertBean(c4, "on", "["+CNAME+"$C1.m1(),"+CNAME+"$C2.m2()]");
119 }
120
121
122
123
124
125 public interface D1 {
126
127 @RestDelete(
128 clientVersion="a",
129 debug="b",
130 defaultAccept="c",
131 defaultCharset="d",
132 defaultRequestQueryData="e",
133 defaultRequestAttributes="f",
134 defaultRequestHeaders="g",
135 defaultResponseHeaders="h",
136 description="i",
137 encoders=Encoder.class,
138 guards=RestGuard.class,
139 matchers=RestMatcher.class,
140 on="j",
141 path="k",
142 roleGuard="l",
143 rolesDeclared="m",
144 summary="n",
145 swagger=@OpSwagger,
146 value="o"
147 )
148 void m1();
149
150 @RestDelete(
151 clientVersion="a",
152 debug="b",
153 defaultAccept="c",
154 defaultCharset="d",
155 defaultRequestQueryData="e",
156 defaultRequestAttributes="f",
157 defaultRequestHeaders="g",
158 defaultResponseHeaders="h",
159 description="i",
160 encoders=Encoder.class,
161 guards=RestGuard.class,
162 matchers=RestMatcher.class,
163 on="j",
164 path="k",
165 roleGuard="l",
166 rolesDeclared="m",
167 summary="n",
168 swagger=@OpSwagger,
169 value="o"
170 )
171 void m2();
172 }
173
174 RestDelete d1, d2;
175 {
176 try {
177 d1 = D1.class.getMethod("m1").getAnnotationsByType(RestDelete.class)[0];
178 d2 = D1.class.getMethod("m2").getAnnotationsByType(RestDelete.class)[0];
179
180 } catch (Exception e) {
181 throw new RuntimeException(e);
182 }
183 }
184
185 @Test void d01_comparisonWithDeclarativeAnnotations() {
186 assertEqualsAll(a1, d1, d2);
187 assertNotEqualsAny(a1.hashCode(), 0, -1);
188 assertEqualsAll(a1.hashCode(), d1.hashCode(), d2.hashCode());
189 }
190 }