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.annotation.*;
24 import org.junit.jupiter.api.*;
25
26 class OpSwaggerAnnotation_Test extends TestBase {
27
28
29
30
31
32 OpSwagger a1 = OpSwaggerAnnotation.create()
33 .consumes("a")
34 .deprecated("b")
35 .description("c")
36 .externalDocs(ExternalDocsAnnotation.DEFAULT)
37 .operationId("d")
38 .parameters("e")
39 .produces("f")
40 .responses("g")
41 .schemes("h")
42 .summary("i")
43 .tags("j")
44 .value("k")
45 .build();
46
47 OpSwagger a2 = OpSwaggerAnnotation.create()
48 .consumes("a")
49 .deprecated("b")
50 .description("c")
51 .externalDocs(ExternalDocsAnnotation.DEFAULT)
52 .operationId("d")
53 .parameters("e")
54 .produces("f")
55 .responses("g")
56 .schemes("h")
57 .summary("i")
58 .tags("j")
59 .value("k")
60 .build();
61
62 @Test void a01_basic() {
63 assertBean(a1,
64 "consumes,deprecated,description,externalDocs{description,url},operationId,parameters,produces,responses,schemes,summary,tags,value",
65 "[a],b,[c],{[],},d,[e],[f],[g],[h],[i],[j],[k]");
66 }
67
68 @Test void a02_testEquivalency() {
69 assertEquals(a2, a1);
70 assertNotEqualsAny(a1.hashCode(), 0, -1);
71 assertEquals(a1.hashCode(), a2.hashCode());
72 }
73
74
75
76
77
78 @Test void b01_testEquivalencyInPropertyStores() {
79 var bc1 = BeanContext.create().annotations(a1).build();
80 var bc2 = BeanContext.create().annotations(a2).build();
81 assertSame(bc1, bc2);
82 }
83
84
85
86
87
88
89
90
91
92 @OpSwagger(
93 consumes="a",
94 deprecated="b",
95 description="c",
96 externalDocs=@ExternalDocs,
97 operationId="d",
98 parameters="e",
99 produces="f",
100 responses="g",
101 schemes="h",
102 summary="i",
103 tags="j",
104 value="k"
105 )
106 public static class D1 {}
107 OpSwagger d1 = D1.class.getAnnotationsByType(OpSwagger.class)[0];
108
109 @OpSwagger(
110 consumes="a",
111 deprecated="b",
112 description="c",
113 externalDocs=@ExternalDocs,
114 operationId="d",
115 parameters="e",
116 produces="f",
117 responses="g",
118 schemes="h",
119 summary="i",
120 tags="j",
121 value="k"
122 )
123 public static class D2 {}
124 OpSwagger d2 = D2.class.getAnnotationsByType(OpSwagger.class)[0];
125
126 @Test void d01_comparisonWithDeclarativeAnnotations() {
127 assertEqualsAll(a1, d1, d2);
128 assertNotEqualsAny(a1.hashCode(), 0, -1);
129 assertEqualsAll(a1.hashCode(), d1.hashCode(), d2.hashCode());
130 }
131 }