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