1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17 package org.apache.juneau.bean.openapi3;
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.junit.jupiter.api.*;
24
25 /**
26 * Testcase for {@link OpenApiElement}.
27 * Most of the contents of this class are covered in the subclass tests.
28 */
29 class OpenApiElement_Test extends TestBase {
30
31 @Test void a01_basic() {
32 var x = new OpenApiElement() {};
33 x.set("a1", "a2");
34 assertString("{'a1':'a2'}".replace('\'','"'), x);
35 }
36
37 @Test void a02_strict_withNull() {
38 // Test strict(Object) with null value - should set strict to false
39 var x = new OpenApiElement() {};
40 x.strict(null);
41 assertFalse(x.isStrict());
42 }
43
44 @Test void a03_strict_withTrue() {
45 // Test strict(Object) with true value
46 var x = new OpenApiElement() {};
47 x.strict(true);
48 assertTrue(x.isStrict());
49 }
50
51 @Test void a04_strict_withFalse() {
52 // Test strict(Object) with false value
53 var x = new OpenApiElement() {};
54 x.strict(false);
55 assertFalse(x.isStrict());
56 }
57
58 @Test void a05_strict_withStringTrue() {
59 // Test strict(Object) with string "true"
60 var x = new OpenApiElement() {};
61 x.strict("true");
62 assertTrue(x.isStrict());
63 }
64
65 @Test void a06_strict_withStringFalse() {
66 // Test strict(Object) with string "false"
67 var x = new OpenApiElement() {};
68 x.strict("false");
69 assertFalse(x.isStrict());
70 }
71 }