You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juneau.apache.org by ja...@apache.org on 2018/01/18 19:01:06 UTC
[10/10] juneau git commit: JUNEAU-78
JUNEAU-78
Support for missing $ref field.
Project: http://git-wip-us.apache.org/repos/asf/juneau/repo
Commit: http://git-wip-us.apache.org/repos/asf/juneau/commit/8df34f56
Tree: http://git-wip-us.apache.org/repos/asf/juneau/tree/8df34f56
Diff: http://git-wip-us.apache.org/repos/asf/juneau/diff/8df34f56
Branch: refs/heads/master
Commit: 8df34f56dc3b0f5e67318ad050f8e288a58d6c00
Parents: 6f4b27e
Author: JamesBognar <ja...@apache.org>
Authored: Thu Jan 18 14:00:53 2018 -0500
Committer: JamesBognar <ja...@apache.org>
Committed: Thu Jan 18 14:00:53 2018 -0500
----------------------------------------------------------------------
.../apache/juneau/dto/swagger/ContactTest.java | 123 ++
.../dto/swagger/ExternalDocumentationTest.java | 101 ++
.../juneau/dto/swagger/HeaderInfoTest.java | 607 ++++++++++
.../org/apache/juneau/dto/swagger/InfoTest.java | 200 ++++
.../apache/juneau/dto/swagger/ItemsTest.java | 582 ++++++++++
.../apache/juneau/dto/swagger/LicenseTest.java | 109 ++
.../juneau/dto/swagger/OperationTest.java | 675 +++++++++++
.../juneau/dto/swagger/ParameterInfoTest.java | 729 ++++++++++++
.../juneau/dto/swagger/ResponseInfoTest.java | 265 +++++
.../juneau/dto/swagger/SchemaInfoTest.java | 1011 ++++++++++++++++
.../juneau/dto/swagger/SecuritySchemeTest.java | 284 +++++
.../juneau/dto/swagger/SwaggerBuilderTest.java | 322 ++++++
.../apache/juneau/dto/swagger/SwaggerTest.java | 910 +++++++++++++++
.../org/apache/juneau/dto/swagger/TagTest.java | 133 +++
.../org/apache/juneau/dto/swagger/XmlTest.java | 186 +++
.../apache/juneau/dto/html5/HtmlElement.java | 2 +-
.../juneau/dto/html5/HtmlElementContainer.java | 2 +-
.../juneau/dto/html5/HtmlElementMixed.java | 2 +-
.../org/apache/juneau/dto/swagger/Contact.java | 126 +-
.../dto/swagger/ExternalDocumentation.java | 123 +-
.../apache/juneau/dto/swagger/HeaderInfo.java | 829 +++++++------
.../org/apache/juneau/dto/swagger/Info.java | 233 ++--
.../org/apache/juneau/dto/swagger/Items.java | 828 ++++++++-----
.../org/apache/juneau/dto/swagger/License.java | 119 +-
.../apache/juneau/dto/swagger/Operation.java | 883 ++++++++------
.../juneau/dto/swagger/ParameterInfo.java | 1094 +++++++++++-------
.../apache/juneau/dto/swagger/ResponseInfo.java | 267 +++--
.../apache/juneau/dto/swagger/SchemaInfo.java | 996 ++++++++++------
.../juneau/dto/swagger/SecurityScheme.java | 352 +++---
.../org/apache/juneau/dto/swagger/Swagger.java | 1005 +++++++++-------
.../juneau/dto/swagger/SwaggerBuilder.java | 163 ++-
.../juneau/dto/swagger/SwaggerElement.java | 105 +-
.../java/org/apache/juneau/dto/swagger/Tag.java | 147 ++-
.../java/org/apache/juneau/dto/swagger/Xml.java | 205 ++--
.../org/apache/juneau/dto/swagger/package.html | 156 ---
.../juneau/internal/BeanPropertyUtils.java | 257 ++++
.../org/apache/juneau/internal/ObjectUtils.java | 58 +-
.../org/apache/juneau/internal/StringUtils.java | 7 +-
38 files changed, 11205 insertions(+), 2991 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/ContactTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/ContactTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/ContactTest.java
new file mode 100644
index 0000000..90be313
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/ContactTest.java
@@ -0,0 +1,123 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.dto.swagger;
+
+import static org.apache.juneau.TestUtils.*;
+
+import static org.junit.Assert.*;
+
+import java.net.*;
+
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+/**
+ * Testcase for {@link Contact}.
+ */
+public class ContactTest {
+
+ /**
+ * Test method for {@link Contact#name(java.lang.Object)}.
+ */
+ @Test
+ public void testName() {
+ Contact t = new Contact();
+
+ t.name("foo");
+ assertEquals("foo", t.getName());
+
+ t.name(new StringBuilder("foo"));
+ assertEquals("foo", t.getName());
+ assertType(String.class, t.getName());
+
+ t.name(null);
+ assertNull(t.getName());
+ }
+
+ /**
+ * Test method for {@link Contact#url(java.lang.Object)}.
+ */
+ @Test
+ public void testUrl() {
+ Contact t = new Contact();
+
+ t.url("foo");
+ assertEquals("foo", t.getUrl().toString());
+
+ t.url(new StringBuilder("foo"));
+ assertEquals("foo", t.getUrl().toString());
+ assertType(URI.class, t.getUrl());
+
+ t.url(null);
+ assertNull(t.getUrl());
+ }
+
+ /**
+ * Test method for {@link Contact#email(java.lang.Object)}.
+ */
+ @Test
+ public void testEmail() {
+ Contact t = new Contact();
+
+ t.email("foo");
+ assertEquals("foo", t.getEmail());
+
+ t.email(new StringBuilder("foo"));
+ assertEquals("foo", t.getEmail());
+ assertType(String.class, t.getEmail());
+
+ t.email(null);
+ assertNull(t.getEmail());
+ }
+
+ /**
+ * Test method for {@link Contact#set(String, Object)}.
+ */
+ @Test
+ public void testSet() throws Exception {
+ Contact t = new Contact();
+
+ t
+ .set("name", "foo")
+ .set("url", "bar")
+ .set("email", "baz")
+ .set("$ref", "qux");
+
+ assertObjectEquals("{name:'foo',url:'bar',email:'baz','$ref':'qux'}", t);
+
+ t
+ .set("name", new StringBuilder("foo"))
+ .set("url", new StringBuilder("bar"))
+ .set("email", new StringBuilder("baz"))
+ .set("$ref", new StringBuilder("qux"));
+
+ assertObjectEquals("{name:'foo',url:'bar',email:'baz','$ref':'qux'}", t);
+
+ assertEquals("foo", t.get("name", String.class));
+ assertEquals("bar", t.get("url", URI.class).toString());
+ assertEquals("baz", t.get("email", String.class));
+ assertEquals("qux", t.get("$ref", String.class));
+
+ assertType(String.class, t.get("name", String.class));
+ assertType(URI.class, t.get("url", URI.class));
+ assertType(String.class, t.get("email", String.class));
+ assertType(String.class, t.get("$ref", String.class));
+
+ t.set("null", null).set(null, "null");
+ assertNull(t.get("null", Object.class));
+ assertNull(t.get(null, Object.class));
+ assertNull(t.get("foo", Object.class));
+
+ assertObjectEquals("{name:'foo',url:'bar',email:'baz','$ref':'qux'}", JsonParser.DEFAULT.parse("{name:'foo',url:'bar',email:'baz','$ref':'qux'}", Contact.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/ExternalDocumentationTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/ExternalDocumentationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/ExternalDocumentationTest.java
new file mode 100644
index 0000000..d92cc4d
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/ExternalDocumentationTest.java
@@ -0,0 +1,101 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.dto.swagger;
+
+import static org.apache.juneau.TestUtils.*;
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+
+import java.net.*;
+
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+/**
+ * Testcase for {@link ExternalDocumentation}.
+ */
+public class ExternalDocumentationTest {
+
+ /**
+ * Test method for {@link ExternalDocumentation#description(java.lang.Object)}.
+ */
+ @Test
+ public void testDescription() {
+ ExternalDocumentation t = new ExternalDocumentation();
+
+ t.description("foo");
+ assertEquals("foo", t.getDescription());
+
+ t.description(new StringBuilder("foo"));
+ assertEquals("foo", t.getDescription());
+ assertType(String.class, t.getDescription());
+
+ t.description(null);
+ assertNull(t.getDescription());
+ }
+
+ /**
+ * Test method for {@link ExternalDocumentation#url(java.lang.Object)}.
+ */
+ @Test
+ public void testUrl() {
+ ExternalDocumentation t = new ExternalDocumentation();
+
+ t.url("foo");
+ assertEquals("foo", t.getUrl().toString());
+
+ t.url(new StringBuilder("foo"));
+ assertEquals("foo", t.getUrl().toString());
+ assertType(URI.class, t.getUrl());
+
+ t.url(null);
+ assertNull(t.getUrl());
+ }
+
+ /**
+ * Test method for {@link ExternalDocumentation#set(java.lang.String, java.lang.Object)}.
+ */
+ @Test
+ public void testSet() throws Exception {
+ ExternalDocumentation t = new ExternalDocumentation();
+
+ t
+ .set("description", "foo")
+ .set("url", "bar")
+ .set("$ref", "baz");
+
+ assertObjectEquals("{description:'foo',url:'bar','$ref':'baz'}", t);
+
+ t
+ .set("description", new StringBuilder("foo"))
+ .set("url", new StringBuilder("bar"))
+ .set("$ref", new StringBuilder("baz"));
+
+ assertObjectEquals("{description:'foo',url:'bar','$ref':'baz'}", t);
+
+ assertEquals("foo", t.get("description", String.class));
+ assertEquals("bar", t.get("url", URI.class).toString());
+ assertEquals("baz", t.get("$ref", String.class));
+
+ assertType(String.class, t.get("description", String.class));
+ assertType(URI.class, t.get("url", URI.class));
+ assertType(String.class, t.get("$ref", String.class));
+
+ t.set("null", null).set(null, "null");
+ assertNull(t.get("null", Object.class));
+ assertNull(t.get(null, Object.class));
+ assertNull(t.get("foo", Object.class));
+
+ assertObjectEquals("{description:'foo',url:'bar','$ref':'baz'}", JsonParser.DEFAULT.parse("{description:'foo',url:'bar','$ref':'baz'}", ExternalDocumentation.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/HeaderInfoTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/HeaderInfoTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/HeaderInfoTest.java
new file mode 100644
index 0000000..4eece6b
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/HeaderInfoTest.java
@@ -0,0 +1,607 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.dto.swagger;
+
+import static org.apache.juneau.TestUtils.*;
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+
+import java.util.*;
+
+import org.apache.juneau.json.*;
+import org.apache.juneau.utils.*;
+
+import static org.apache.juneau.dto.swagger.SwaggerBuilder.*;
+
+import org.junit.*;
+
+/**
+ * Testcase for {@link HeaderInfo}.
+ */
+public class HeaderInfoTest {
+
+ /**
+ * Test method for {@link HeaderInfo#description(java.lang.Object)}.
+ */
+ @Test
+ public void testDescription() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.description("foo");
+ assertEquals("foo", t.getDescription());
+
+ t.description(new StringBuilder("foo"));
+ assertEquals("foo", t.getDescription());
+ assertType(String.class, t.getDescription());
+
+ t.description(null);
+ assertNull(t.getDescription());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#type(java.lang.Object)}.
+ */
+ @Test
+ public void testType() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.type("foo");
+ assertEquals("foo", t.getType());
+
+ t.type(new StringBuilder("foo"));
+ assertEquals("foo", t.getType());
+ assertType(String.class, t.getType());
+
+ t.type(null);
+ assertNull(t.getType());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#format(java.lang.Object)}.
+ */
+ @Test
+ public void testFormat() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.format("foo");
+ assertEquals("foo", t.getFormat());
+
+ t.format(new StringBuilder("foo"));
+ assertEquals("foo", t.getFormat());
+ assertType(String.class, t.getFormat());
+
+ t.format(null);
+ assertNull(t.getFormat());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#items(java.lang.Object)}.
+ */
+ @Test
+ public void testItems() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.items(items("foo"));
+ assertObjectEquals("{type:'foo'}", t.getItems());
+
+ t.items("{type:'foo'}");
+ assertObjectEquals("{type:'foo'}", t.getItems());
+ assertType(Items.class, t.getItems());
+
+ t.items(null);
+ assertNull(t.getItems());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#collectionFormat(java.lang.Object)}.
+ */
+ @Test
+ public void testCollectionFormat() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.collectionFormat("foo");
+ assertEquals("foo", t.getCollectionFormat());
+
+ t.collectionFormat(new StringBuilder("foo"));
+ assertEquals("foo", t.getCollectionFormat());
+ assertType(String.class, t.getCollectionFormat());
+
+ t.collectionFormat(null);
+ assertNull(t.getCollectionFormat());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#_default(java.lang.Object)}.
+ */
+ @Test
+ public void test_default() {
+ HeaderInfo t = new HeaderInfo();
+
+ t._default("foo");
+ assertEquals("foo", t.getDefault());
+
+ t._default(new StringBuilder("foo"));
+ assertEquals("foo", t.getDefault().toString());
+ assertType(StringBuilder.class, t.getDefault());
+
+ t._default(null);
+ assertNull(t.getDefault());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#maximum(java.lang.Object)}.
+ */
+ @Test
+ public void testMaximum() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.maximum(123);
+ assertEquals(123, t.getMaximum());
+ assertType(Integer.class, t.getMaximum());
+
+ t.maximum(123f);
+ assertEquals(123f, t.getMaximum());
+ assertType(Float.class, t.getMaximum());
+
+ t.maximum("123");
+ assertEquals(123, t.getMaximum());
+ assertType(Integer.class, t.getMaximum());
+
+ t.maximum(new StringBuilder("123"));
+ assertEquals(123, t.getMaximum());
+ assertType(Integer.class, t.getMaximum());
+
+ t.maximum(null);
+ assertNull(t.getMaximum());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#exclusiveMaximum(java.lang.Object)}.
+ */
+ @Test
+ public void testExclusiveMaximum() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.exclusiveMaximum(true);
+ assertEquals(true, t.getExclusiveMaximum());
+ assertType(Boolean.class, t.getExclusiveMaximum());
+
+ t.exclusiveMaximum("true");
+ assertEquals(true, t.getExclusiveMaximum());
+ assertType(Boolean.class, t.getExclusiveMaximum());
+
+ t.exclusiveMaximum(new StringBuilder("true"));
+ assertEquals(true, t.getExclusiveMaximum());
+ assertType(Boolean.class, t.getExclusiveMaximum());
+
+ t.exclusiveMaximum(null);
+ assertNull(t.getExclusiveMaximum());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#minimum(java.lang.Object)}.
+ */
+ @Test
+ public void testMinimum() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.minimum(123);
+ assertEquals(123, t.getMinimum());
+ assertType(Integer.class, t.getMinimum());
+
+ t.minimum(123f);
+ assertEquals(123f, t.getMinimum());
+ assertType(Float.class, t.getMinimum());
+
+ t.minimum("123");
+ assertEquals(123, t.getMinimum());
+ assertType(Integer.class, t.getMinimum());
+
+ t.minimum(new StringBuilder("123"));
+ assertEquals(123, t.getMinimum());
+ assertType(Integer.class, t.getMinimum());
+
+ t.minimum(null);
+ assertNull(t.getMinimum());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#exclusiveMinimum(java.lang.Object)}.
+ */
+ @Test
+ public void testExclusiveMinimum() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.exclusiveMinimum(true);
+ assertEquals(true, t.getExclusiveMinimum());
+ assertType(Boolean.class, t.getExclusiveMinimum());
+
+ t.exclusiveMinimum("true");
+ assertEquals(true, t.getExclusiveMinimum());
+ assertType(Boolean.class, t.getExclusiveMinimum());
+
+ t.exclusiveMinimum(new StringBuilder("true"));
+ assertEquals(true, t.getExclusiveMinimum());
+ assertType(Boolean.class, t.getExclusiveMinimum());
+
+ t.exclusiveMinimum(null);
+ assertNull(t.getExclusiveMinimum());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#maxLength(java.lang.Object)}.
+ */
+ @Test
+ public void testMaxLength() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.maxLength(123);
+ assertEquals(123, t.getMaxLength().intValue());
+ assertType(Integer.class, t.getMaxLength());
+
+ t.maxLength(123f);
+ assertEquals(123, t.getMaxLength().intValue());
+ assertType(Integer.class, t.getMaxLength());
+
+ t.maxLength("123");
+ assertEquals(123, t.getMaxLength().intValue());
+ assertType(Integer.class, t.getMaxLength());
+
+ t.maxLength(new StringBuilder("123"));
+ assertEquals(123, t.getMaxLength().intValue());
+ assertType(Integer.class, t.getMaxLength());
+
+ t.maxLength(null);
+ assertNull(t.getMaxLength());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#minLength(java.lang.Object)}.
+ */
+ @Test
+ public void testMinLength() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.minLength(123);
+ assertEquals(123, t.getMinLength().intValue());
+ assertType(Integer.class, t.getMinLength());
+
+ t.minLength(123f);
+ assertEquals(123, t.getMinLength().intValue());
+ assertType(Integer.class, t.getMinLength());
+
+ t.minLength("123");
+ assertEquals(123, t.getMinLength().intValue());
+ assertType(Integer.class, t.getMinLength());
+
+ t.minLength(new StringBuilder("123"));
+ assertEquals(123, t.getMinLength().intValue());
+ assertType(Integer.class, t.getMinLength());
+
+ t.minLength(null);
+ assertNull(t.getMinLength());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#pattern(java.lang.Object)}.
+ */
+ @Test
+ public void testPattern() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.pattern("foo");
+ assertEquals("foo", t.getPattern());
+
+ t.pattern(new StringBuilder("foo"));
+ assertEquals("foo", t.getPattern());
+ assertType(String.class, t.getPattern());
+
+ t.pattern(null);
+ assertNull(t.getPattern());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#maxItems(java.lang.Object)}.
+ */
+ @Test
+ public void testMaxItems() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.maxItems(123);
+ assertEquals(123, t.getMaxItems().intValue());
+ assertType(Integer.class, t.getMaxItems());
+
+ t.maxItems(123f);
+ assertEquals(123, t.getMaxItems().intValue());
+ assertType(Integer.class, t.getMaxItems());
+
+ t.maxItems("123");
+ assertEquals(123, t.getMaxItems().intValue());
+ assertType(Integer.class, t.getMaxItems());
+
+ t.maxItems(new StringBuilder("123"));
+ assertEquals(123, t.getMaxItems().intValue());
+ assertType(Integer.class, t.getMaxItems());
+
+ t.maxItems(null);
+ assertNull(t.getMaxItems());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#minItems(java.lang.Object)}.
+ */
+ @Test
+ public void testMinItems() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.minItems(123);
+ assertEquals(123, t.getMinItems().intValue());
+ assertType(Integer.class, t.getMinItems());
+
+ t.minItems(123f);
+ assertEquals(123, t.getMinItems().intValue());
+ assertType(Integer.class, t.getMinItems());
+
+ t.minItems("123");
+ assertEquals(123, t.getMinItems().intValue());
+ assertType(Integer.class, t.getMinItems());
+
+ t.minItems(new StringBuilder("123"));
+ assertEquals(123, t.getMinItems().intValue());
+ assertType(Integer.class, t.getMinItems());
+
+ t.minItems(null);
+ assertNull(t.getMinItems());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#uniqueItems(java.lang.Object)}.
+ */
+ @Test
+ public void testUniqueItems() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.uniqueItems(true);
+ assertEquals(true, t.getUniqueItems());
+ assertType(Boolean.class, t.getUniqueItems());
+
+ t.uniqueItems("true");
+ assertEquals(true, t.getUniqueItems());
+ assertType(Boolean.class, t.getUniqueItems());
+
+ t.uniqueItems(new StringBuilder("true"));
+ assertEquals(true, t.getUniqueItems());
+ assertType(Boolean.class, t.getUniqueItems());
+
+ t.uniqueItems(null);
+ assertNull(t.getUniqueItems());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#setEnum(java.util.Collection)}.
+ */
+ @Test
+ public void testSetEnum() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.setEnum(new ASet<Object>().appendAll("foo","bar"));
+ assertObjectEquals("['foo','bar']", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t.setEnum(new ASet<Object>());
+ assertObjectEquals("[]", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t.setEnum(null);
+ assertNull(t.getEnum());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#addEnum(java.util.Collection)}.
+ */
+ @Test
+ public void testAddEnum() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.addEnum(new ASet<Object>().appendAll("foo","bar"));
+ assertObjectEquals("['foo','bar']", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t.addEnum(new ASet<Object>().appendAll("baz"));
+ assertObjectEquals("['foo','bar','baz']", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t.addEnum(null);
+ assertObjectEquals("['foo','bar','baz']", t.getEnum());
+ assertType(List.class, t.getEnum());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#_enum(java.lang.Object[])}.
+ */
+ @Test
+ public void test_enum() {
+ HeaderInfo t = new HeaderInfo();
+
+ t._enum(new ASet<Object>().appendAll("foo","bar"));
+ assertObjectEquals("['foo','bar']", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t._enum(new ASet<Object>().appendAll("baz"));
+ assertObjectEquals("['foo','bar','baz']", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t._enum((Object[])null);
+ assertObjectEquals("['foo','bar','baz']", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t.setEnum(null);
+ t._enum("foo")._enum(new StringBuilder("bar"))._enum("['baz','qux']")._enum((Object)new String[]{"quux"});
+ assertObjectEquals("['foo','bar','baz','qux','quux']", t.getEnum());
+ assertType(List.class, t.getEnum());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#multipleOf(java.lang.Object)}.
+ */
+ @Test
+ public void testMultipleOf() {
+ HeaderInfo t = new HeaderInfo();
+
+ t.multipleOf(123);
+ assertEquals(123, t.getMultipleOf());
+ assertType(Integer.class, t.getMultipleOf());
+
+ t.multipleOf(123f);
+ assertEquals(123f, t.getMultipleOf());
+ assertType(Float.class, t.getMultipleOf());
+
+ t.multipleOf("123");
+ assertEquals(123, t.getMultipleOf());
+ assertType(Integer.class, t.getMultipleOf());
+
+ t.multipleOf(new StringBuilder("123"));
+ assertEquals(123, t.getMultipleOf());
+ assertType(Integer.class, t.getMultipleOf());
+
+ t.multipleOf(null);
+ assertNull(t.getMultipleOf());
+ }
+
+ /**
+ * Test method for {@link HeaderInfo#set(java.lang.String, java.lang.Object)}.
+ */
+ @Test
+ public void testSet() throws Exception {
+ HeaderInfo t = new HeaderInfo();
+
+ t
+ .set("default", "a")
+ .set("enum", new ASet<String>().append("b"))
+ .set("collectionFormat", "c")
+ .set("description", "d")
+ .set("exclusiveMaximum", true)
+ .set("exclusiveMinimum", true)
+ .set("format", "g")
+ .set("items", items("h"))
+ .set("maximum", 123f)
+ .set("maxItems", 123)
+ .set("maxLength", 123)
+ .set("minimum", 123f)
+ .set("minItems", 123)
+ .set("minLength", 123)
+ .set("multipleOf", 123f)
+ .set("pattern", "i")
+ .set("type", "j")
+ .set("uniqueItems", true)
+ .set("$ref", "ref");
+
+ assertObjectEquals("{description:'d',type:'j',format:'g',items:{type:'h'},collectionFormat:'c','default':'a',maximum:123.0,exclusiveMaximum:true,minimum:123.0,exclusiveMinimum:true,maxLength:123,minLength:123,pattern:'i',maxItems:123,minItems:123,uniqueItems:true,'enum':['b'],multipleOf:123.0,'$ref':'ref'}", t);
+
+ t
+ .set("default", "a")
+ .set("enum", "['b']")
+ .set("collectionFormat", "c")
+ .set("description", "d")
+ .set("exclusiveMaximum", "true")
+ .set("exclusiveMinimum", "true")
+ .set("format", "g")
+ .set("items", "{type:'h'}")
+ .set("maximum", "123f")
+ .set("maxItems", "123")
+ .set("maxLength", "123")
+ .set("minimum", "123f")
+ .set("minItems", "123")
+ .set("minLength", "123")
+ .set("multipleOf", "123f")
+ .set("pattern", "i")
+ .set("type", "j")
+ .set("uniqueItems", "true")
+ .set("$ref", "ref");
+
+ assertObjectEquals("{description:'d',type:'j',format:'g',items:{type:'h'},collectionFormat:'c','default':'a',maximum:123.0,exclusiveMaximum:true,minimum:123.0,exclusiveMinimum:true,maxLength:123,minLength:123,pattern:'i',maxItems:123,minItems:123,uniqueItems:true,'enum':['b'],multipleOf:123.0,'$ref':'ref'}", t);
+
+ t
+ .set("default", new StringBuilder("a"))
+ .set("enum", new StringBuilder("['b']"))
+ .set("collectionFormat", new StringBuilder("c"))
+ .set("description", new StringBuilder("d"))
+ .set("exclusiveMaximum", new StringBuilder("true"))
+ .set("exclusiveMinimum", new StringBuilder("true"))
+ .set("format", new StringBuilder("g"))
+ .set("items", new StringBuilder("{type:'h'}"))
+ .set("maximum", new StringBuilder("123f"))
+ .set("maxItems", new StringBuilder("123"))
+ .set("maxLength", new StringBuilder("123"))
+ .set("minimum", new StringBuilder("123f"))
+ .set("minItems", new StringBuilder("123"))
+ .set("minLength", new StringBuilder("123"))
+ .set("multipleOf", new StringBuilder("123f"))
+ .set("pattern", new StringBuilder("i"))
+ .set("type", new StringBuilder("j"))
+ .set("uniqueItems", new StringBuilder("true"))
+ .set("$ref", new StringBuilder("ref"));
+
+ assertObjectEquals("{description:'d',type:'j',format:'g',items:{type:'h'},collectionFormat:'c','default':'a',maximum:123.0,exclusiveMaximum:true,minimum:123.0,exclusiveMinimum:true,maxLength:123,minLength:123,pattern:'i',maxItems:123,minItems:123,uniqueItems:true,'enum':['b'],multipleOf:123.0,'$ref':'ref'}", t);
+
+ assertEquals("a", t.get("default", String.class));
+ assertEquals("['b']", t.get("enum", String.class));
+ assertEquals("c", t.get("collectionFormat", String.class));
+ assertEquals("d", t.get("description", String.class));
+ assertEquals("true", t.get("exclusiveMaximum", String.class));
+ assertEquals("true", t.get("exclusiveMinimum", String.class));
+ assertEquals("g", t.get("format", String.class));
+ assertEquals("{type:'h'}", t.get("items", String.class));
+ assertEquals("123.0", t.get("maximum", String.class));
+ assertEquals("123", t.get("maxItems", String.class));
+ assertEquals("123", t.get("maxLength", String.class));
+ assertEquals("123.0", t.get("minimum", String.class));
+ assertEquals("123", t.get("minItems", String.class));
+ assertEquals("123", t.get("minLength", String.class));
+ assertEquals("123.0", t.get("multipleOf", String.class));
+ assertEquals("i", t.get("pattern", String.class));
+ assertEquals("j", t.get("type", String.class));
+ assertEquals("true", t.get("uniqueItems", String.class));
+ assertEquals("ref", t.get("$ref", String.class));
+
+ assertType(StringBuilder.class, t.get("default", Object.class));
+ assertType(List.class, t.get("enum", Object.class));
+ assertType(String.class, t.get("collectionFormat", Object.class));
+ assertType(String.class, t.get("description", Object.class));
+ assertType(Boolean.class, t.get("exclusiveMaximum", Object.class));
+ assertType(Boolean.class, t.get("exclusiveMinimum", Object.class));
+ assertType(String.class, t.get("format", Object.class));
+ assertType(Items.class, t.get("items", Object.class));
+ assertType(Float.class, t.get("maximum", Object.class));
+ assertType(Integer.class, t.get("maxItems", Object.class));
+ assertType(Integer.class, t.get("maxLength", Object.class));
+ assertType(Float.class, t.get("minimum", Object.class));
+ assertType(Integer.class, t.get("minItems", Object.class));
+ assertType(Integer.class, t.get("minLength", Object.class));
+ assertType(Float.class, t.get("multipleOf", Object.class));
+ assertType(String.class, t.get("pattern", Object.class));
+ assertType(String.class, t.get("type", Object.class));
+ assertType(Boolean.class, t.get("uniqueItems", Object.class));
+ assertType(StringBuilder.class, t.get("$ref", Object.class));
+
+ JsonSerializer.DEFAULT_LAX.println(t);
+
+ t.set("null", null).set(null, "null");
+ assertNull(t.get("null", Object.class));
+ assertNull(t.get(null, Object.class));
+ assertNull(t.get("foo", Object.class));
+
+ String s = "{description:'d',type:'j',format:'g',items:{type:'h'},collectionFormat:'c','default':'a',maximum:123.0,exclusiveMaximum:true,minimum:123.0,exclusiveMinimum:true,maxLength:123,minLength:123,pattern:'i',maxItems:123,minItems:123,uniqueItems:true,'enum':['b'],multipleOf:123.0,'$ref':'ref'}";
+ assertObjectEquals(s, JsonParser.DEFAULT.parse(s, HeaderInfo.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/InfoTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/InfoTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/InfoTest.java
new file mode 100644
index 0000000..ce7d48c
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/InfoTest.java
@@ -0,0 +1,200 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.dto.swagger;
+
+import static org.apache.juneau.TestUtils.*;
+import static org.apache.juneau.dto.swagger.SwaggerBuilder.*;
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+/**
+ * Testcase for {@link Info}.
+ */
+public class InfoTest {
+
+ /**
+ * Test method for {@link Info#title(java.lang.Object)}.
+ */
+ @Test
+ public void testTitle() {
+ Info t = new Info();
+
+ t.title("foo");
+ assertEquals("foo", t.getTitle());
+
+ t.title(new StringBuilder("foo"));
+ assertEquals("foo", t.getTitle());
+ assertType(String.class, t.getTitle());
+
+ t.title(null);
+ assertNull(t.getTitle());
+ }
+
+ /**
+ * Test method for {@link Info#description(java.lang.Object)}.
+ */
+ @Test
+ public void testDescription() {
+ Info t = new Info();
+
+ t.description("foo");
+ assertEquals("foo", t.getDescription());
+
+ t.description(new StringBuilder("foo"));
+ assertEquals("foo", t.getDescription());
+ assertType(String.class, t.getDescription());
+
+ t.description(null);
+ assertNull(t.getDescription());
+ }
+
+ /**
+ * Test method for {@link Info#termsOfService(java.lang.Object)}.
+ */
+ @Test
+ public void testTermsOfService() {
+ Info t = new Info();
+
+ t.termsOfService("foo");
+ assertEquals("foo", t.getTermsOfService());
+
+ t.termsOfService(new StringBuilder("foo"));
+ assertEquals("foo", t.getTermsOfService());
+ assertType(String.class, t.getTermsOfService());
+
+ t.termsOfService(null);
+ assertNull(t.getTermsOfService());
+ }
+
+ /**
+ * Test method for {@link Info#contact(java.lang.Object)}.
+ */
+ @Test
+ public void testContact() {
+ Info t = new Info();
+
+ t.contact(contact("foo"));
+ assertObjectEquals("{name:'foo'}", t.getContact());
+
+ t.contact("{name:'foo'}");
+ assertObjectEquals("{name:'foo'}", t.getContact());
+ assertType(Contact.class, t.getContact());
+
+ t.contact(null);
+ assertNull(t.getContact());
+ }
+
+ /**
+ * Test method for {@link Info#license(java.lang.Object)}.
+ */
+ @Test
+ public void testLicense() {
+ Info t = new Info();
+
+ t.license(license("foo"));
+ assertObjectEquals("{name:'foo'}", t.getLicense());
+
+ t.license("{name:'foo'}");
+ assertObjectEquals("{name:'foo'}", t.getLicense());
+ assertType(License.class, t.getLicense());
+
+ t.license(null);
+ assertNull(t.getLicense());
+ }
+
+ /**
+ * Test method for {@link Info#version(java.lang.Object)}.
+ */
+ @Test
+ public void testVersion() {
+ Info t = new Info();
+
+ t.version("foo");
+ assertEquals("foo", t.getVersion());
+
+ t.version(new StringBuilder("foo"));
+ assertEquals("foo", t.getVersion());
+ assertType(String.class, t.getVersion());
+
+ t.version(null);
+ assertNull(t.getVersion());
+ }
+
+ /**
+ * Test method for {@link Info#set(java.lang.String, java.lang.Object)}.
+ */
+ @Test
+ public void testSet() throws Exception {
+ Info t = new Info();
+
+ t
+ .set("contact", contact("a"))
+ .set("description", "b")
+ .set("license", license("c"))
+ .set("termsOfService", "d")
+ .set("title", "e")
+ .set("version", "f")
+ .set("$ref", "ref");
+
+ assertObjectEquals("{title:'e',description:'b',termsOfService:'d',contact:{name:'a'},license:{name:'c'},version:'f','$ref':'ref'}", t);
+
+ t
+ .set("contact", "{name:'a'}")
+ .set("description", "b")
+ .set("license", "{name:'c'}")
+ .set("termsOfService", "d")
+ .set("title", "e")
+ .set("version", "f")
+ .set("$ref", "ref");
+
+ assertObjectEquals("{title:'e',description:'b',termsOfService:'d',contact:{name:'a'},license:{name:'c'},version:'f','$ref':'ref'}", t);
+
+ t
+ .set("contact", new StringBuilder("{name:'a'}"))
+ .set("description", new StringBuilder("b"))
+ .set("license", new StringBuilder("{name:'c'}"))
+ .set("termsOfService", new StringBuilder("d"))
+ .set("title", new StringBuilder("e"))
+ .set("version", new StringBuilder("f"))
+ .set("$ref", new StringBuilder("ref"));
+
+ assertObjectEquals("{title:'e',description:'b',termsOfService:'d',contact:{name:'a'},license:{name:'c'},version:'f','$ref':'ref'}", t);
+
+ assertEquals("{name:'a'}", t.get("contact", String.class));
+ assertEquals("b", t.get("description", String.class));
+ assertEquals("{name:'c'}", t.get("license", String.class));
+ assertEquals("d", t.get("termsOfService", String.class));
+ assertEquals("e", t.get("title", String.class));
+ assertEquals("f", t.get("version", String.class));
+ assertEquals("ref", t.get("$ref", String.class));
+
+ assertType(Contact.class, t.get("contact", Object.class));
+ assertType(String.class, t.get("description", Object.class));
+ assertType(License.class, t.get("license", Object.class));
+ assertType(String.class, t.get("termsOfService", Object.class));
+ assertType(String.class, t.get("title", Object.class));
+ assertType(String.class, t.get("version", Object.class));
+ assertType(StringBuilder.class, t.get("$ref", Object.class));
+
+ t.set("null", null).set(null, "null");
+ assertNull(t.get("null", Object.class));
+ assertNull(t.get(null, Object.class));
+ assertNull(t.get("foo", Object.class));
+
+ String s = "{title:'e',description:'b',termsOfService:'d',contact:{name:'a'},license:{name:'c'},version:'f','$ref':'ref'}";
+ assertObjectEquals(s, JsonParser.DEFAULT.parse(s, Info.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/ItemsTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/ItemsTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/ItemsTest.java
new file mode 100644
index 0000000..06f313a
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/ItemsTest.java
@@ -0,0 +1,582 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.dto.swagger;
+
+import static org.apache.juneau.TestUtils.*;
+import static org.apache.juneau.dto.swagger.SwaggerBuilder.*;
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+
+import java.util.*;
+
+import org.apache.juneau.json.*;
+import org.apache.juneau.utils.*;
+import org.junit.*;
+
+/**
+ * Testcase for {@link Items}.
+ */
+public class ItemsTest {
+
+ /**
+ * Test method for {@link Items#type(java.lang.Object)}.
+ */
+ @Test
+ public void testType() {
+ Items t = new Items();
+
+ t.type("foo");
+ assertEquals("foo", t.getType());
+
+ t.type(new StringBuilder("foo"));
+ assertEquals("foo", t.getType());
+ assertType(String.class, t.getType());
+
+ t.type(null);
+ assertNull(t.getType());
+ }
+
+ /**
+ * Test method for {@link Items#format(java.lang.Object)}.
+ */
+ @Test
+ public void testFormat() {
+ Items t = new Items();
+
+ t.format("foo");
+ assertEquals("foo", t.getFormat());
+
+ t.format(new StringBuilder("foo"));
+ assertEquals("foo", t.getFormat());
+ assertType(String.class, t.getFormat());
+
+ t.format(null);
+ assertNull(t.getFormat());
+ }
+
+ /**
+ * Test method for {@link Items#items(java.lang.Object)}.
+ */
+ @Test
+ public void testItems() {
+ Items t = new Items();
+
+ t.items(items("foo"));
+ assertObjectEquals("{type:'foo'}", t.getItems());
+
+ t.items("{type:'foo'}");
+ assertObjectEquals("{type:'foo'}", t.getItems());
+ assertType(Items.class, t.getItems());
+
+ t.items(null);
+ assertNull(t.getItems());
+ }
+
+ /**
+ * Test method for {@link Items#collectionFormat(java.lang.Object)}.
+ */
+ @Test
+ public void testCollectionFormat() {
+ Items t = new Items();
+
+ t.collectionFormat("foo");
+ assertEquals("foo", t.getCollectionFormat());
+
+ t.collectionFormat(new StringBuilder("foo"));
+ assertEquals("foo", t.getCollectionFormat());
+ assertType(String.class, t.getCollectionFormat());
+
+ t.collectionFormat(null);
+ assertNull(t.getCollectionFormat());
+ }
+
+ /**
+ * Test method for {@link Items#_default(java.lang.Object)}.
+ */
+ @Test
+ public void test_default() {
+ Items t = new Items();
+
+ t._default("foo");
+ assertEquals("foo", t.getDefault());
+
+ t._default(new StringBuilder("foo"));
+ assertEquals("foo", t.getDefault().toString());
+ assertType(StringBuilder.class, t.getDefault());
+
+ t._default(null);
+ assertNull(t.getDefault());
+ }
+
+ /**
+ * Test method for {@link Items#maximum(java.lang.Object)}.
+ */
+ @Test
+ public void testMaximum() {
+ Items t = new Items();
+
+ t.maximum(123);
+ assertEquals(123, t.getMaximum());
+ assertType(Integer.class, t.getMaximum());
+
+ t.maximum(123f);
+ assertEquals(123f, t.getMaximum());
+ assertType(Float.class, t.getMaximum());
+
+ t.maximum("123");
+ assertEquals(123, t.getMaximum());
+ assertType(Integer.class, t.getMaximum());
+
+ t.maximum(new StringBuilder("123"));
+ assertEquals(123, t.getMaximum());
+ assertType(Integer.class, t.getMaximum());
+
+ t.maximum(null);
+ assertNull(t.getMaximum());
+ }
+
+ /**
+ * Test method for {@link Items#exclusiveMaximum(java.lang.Object)}.
+ */
+ @Test
+ public void testExclusiveMaximum() {
+ Items t = new Items();
+
+ t.exclusiveMaximum(true);
+ assertEquals(true, t.getExclusiveMaximum());
+ assertType(Boolean.class, t.getExclusiveMaximum());
+
+ t.exclusiveMaximum("true");
+ assertEquals(true, t.getExclusiveMaximum());
+ assertType(Boolean.class, t.getExclusiveMaximum());
+
+ t.exclusiveMaximum(new StringBuilder("true"));
+ assertEquals(true, t.getExclusiveMaximum());
+ assertType(Boolean.class, t.getExclusiveMaximum());
+
+ t.exclusiveMaximum(null);
+ assertNull(t.getExclusiveMaximum());
+ }
+
+ /**
+ * Test method for {@link Items#minimum(java.lang.Object)}.
+ */
+ @Test
+ public void testMinimum() {
+ Items t = new Items();
+
+ t.minimum(123);
+ assertEquals(123, t.getMinimum());
+ assertType(Integer.class, t.getMinimum());
+
+ t.minimum(123f);
+ assertEquals(123f, t.getMinimum());
+ assertType(Float.class, t.getMinimum());
+
+ t.minimum("123");
+ assertEquals(123, t.getMinimum());
+ assertType(Integer.class, t.getMinimum());
+
+ t.minimum(new StringBuilder("123"));
+ assertEquals(123, t.getMinimum());
+ assertType(Integer.class, t.getMinimum());
+
+ t.minimum(null);
+ assertNull(t.getMinimum());
+ }
+
+ /**
+ * Test method for {@link Items#exclusiveMinimum(java.lang.Object)}.
+ */
+ @Test
+ public void testExclusiveMinimum() {
+ Items t = new Items();
+
+ t.exclusiveMinimum(true);
+ assertEquals(true, t.getExclusiveMinimum());
+ assertType(Boolean.class, t.getExclusiveMinimum());
+
+ t.exclusiveMinimum("true");
+ assertEquals(true, t.getExclusiveMinimum());
+ assertType(Boolean.class, t.getExclusiveMinimum());
+
+ t.exclusiveMinimum(new StringBuilder("true"));
+ assertEquals(true, t.getExclusiveMinimum());
+ assertType(Boolean.class, t.getExclusiveMinimum());
+
+ t.exclusiveMinimum(null);
+ assertNull(t.getExclusiveMinimum());
+ }
+
+ /**
+ * Test method for {@link Items#maxLength(java.lang.Object)}.
+ */
+ @Test
+ public void testMaxLength() {
+ Items t = new Items();
+
+ t.maxLength(123);
+ assertEquals(123, t.getMaxLength().intValue());
+ assertType(Integer.class, t.getMaxLength());
+
+ t.maxLength(123f);
+ assertEquals(123, t.getMaxLength().intValue());
+ assertType(Integer.class, t.getMaxLength());
+
+ t.maxLength("123");
+ assertEquals(123, t.getMaxLength().intValue());
+ assertType(Integer.class, t.getMaxLength());
+
+ t.maxLength(new StringBuilder("123"));
+ assertEquals(123, t.getMaxLength().intValue());
+ assertType(Integer.class, t.getMaxLength());
+
+ t.maxLength(null);
+ assertNull(t.getMaxLength());
+ }
+
+ /**
+ * Test method for {@link Items#minLength(java.lang.Object)}.
+ */
+ @Test
+ public void testMinLength() {
+ Items t = new Items();
+
+ t.minLength(123);
+ assertEquals(123, t.getMinLength().intValue());
+ assertType(Integer.class, t.getMinLength());
+
+ t.minLength(123f);
+ assertEquals(123, t.getMinLength().intValue());
+ assertType(Integer.class, t.getMinLength());
+
+ t.minLength("123");
+ assertEquals(123, t.getMinLength().intValue());
+ assertType(Integer.class, t.getMinLength());
+
+ t.minLength(new StringBuilder("123"));
+ assertEquals(123, t.getMinLength().intValue());
+ assertType(Integer.class, t.getMinLength());
+
+ t.minLength(null);
+ assertNull(t.getMinLength());
+ }
+
+ /**
+ * Test method for {@link Items#pattern(java.lang.Object)}.
+ */
+ @Test
+ public void testPattern() {
+ Items t = new Items();
+
+ t.pattern("foo");
+ assertEquals("foo", t.getPattern());
+
+ t.pattern(new StringBuilder("foo"));
+ assertEquals("foo", t.getPattern());
+ assertType(String.class, t.getPattern());
+
+ t.pattern(null);
+ assertNull(t.getPattern());
+ }
+
+ /**
+ * Test method for {@link Items#maxItems(java.lang.Object)}.
+ */
+ @Test
+ public void testMaxItems() {
+ Items t = new Items();
+
+ t.maxItems(123);
+ assertEquals(123, t.getMaxItems().intValue());
+ assertType(Integer.class, t.getMaxItems());
+
+ t.maxItems(123f);
+ assertEquals(123, t.getMaxItems().intValue());
+ assertType(Integer.class, t.getMaxItems());
+
+ t.maxItems("123");
+ assertEquals(123, t.getMaxItems().intValue());
+ assertType(Integer.class, t.getMaxItems());
+
+ t.maxItems(new StringBuilder("123"));
+ assertEquals(123, t.getMaxItems().intValue());
+ assertType(Integer.class, t.getMaxItems());
+
+ t.maxItems(null);
+ assertNull(t.getMaxItems());
+ }
+
+ /**
+ * Test method for {@link Items#minItems(java.lang.Object)}.
+ */
+ @Test
+ public void testMinItems() {
+ Items t = new Items();
+
+ t.minItems(123);
+ assertEquals(123, t.getMinItems().intValue());
+ assertType(Integer.class, t.getMinItems());
+
+ t.minItems(123f);
+ assertEquals(123, t.getMinItems().intValue());
+ assertType(Integer.class, t.getMinItems());
+
+ t.minItems("123");
+ assertEquals(123, t.getMinItems().intValue());
+ assertType(Integer.class, t.getMinItems());
+
+ t.minItems(new StringBuilder("123"));
+ assertEquals(123, t.getMinItems().intValue());
+ assertType(Integer.class, t.getMinItems());
+
+ t.minItems(null);
+ assertNull(t.getMinItems());
+ }
+
+ /**
+ * Test method for {@link Items#uniqueItems(java.lang.Object)}.
+ */
+ @Test
+ public void testUniqueItems() {
+ Items t = new Items();
+
+ t.uniqueItems(true);
+ assertEquals(true, t.getUniqueItems());
+ assertType(Boolean.class, t.getUniqueItems());
+
+ t.uniqueItems("true");
+ assertEquals(true, t.getUniqueItems());
+ assertType(Boolean.class, t.getUniqueItems());
+
+ t.uniqueItems(new StringBuilder("true"));
+ assertEquals(true, t.getUniqueItems());
+ assertType(Boolean.class, t.getUniqueItems());
+
+ t.uniqueItems(null);
+ assertNull(t.getUniqueItems());
+ }
+
+ /**
+ * Test method for {@link Items#setEnum(java.util.Collection)}.
+ */
+ @Test
+ public void testSetEnum() {
+ Items t = new Items();
+
+ t.setEnum(new ASet<Object>().appendAll("foo","bar"));
+ assertObjectEquals("['foo','bar']", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t.setEnum(new ASet<Object>());
+ assertObjectEquals("[]", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t.setEnum(null);
+ assertNull(t.getEnum());
+ }
+
+ /**
+ * Test method for {@link Items#addEnum(java.util.Collection)}.
+ */
+ @Test
+ public void testAddEnum() {
+ Items t = new Items();
+
+ t.addEnum(new ASet<Object>().appendAll("foo","bar"));
+ assertObjectEquals("['foo','bar']", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t.addEnum(new ASet<Object>().appendAll("baz"));
+ assertObjectEquals("['foo','bar','baz']", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t.addEnum(null);
+ assertObjectEquals("['foo','bar','baz']", t.getEnum());
+ assertType(List.class, t.getEnum());
+ }
+
+ /**
+ * Test method for {@link Items#_enum(java.lang.Object[])}.
+ */
+ @Test
+ public void test_enum() {
+ Items t = new Items();
+
+ t._enum(new ASet<Object>().appendAll("foo","bar"));
+ assertObjectEquals("['foo','bar']", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t._enum(new ASet<Object>().appendAll("baz"));
+ assertObjectEquals("['foo','bar','baz']", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t._enum((Object[])null);
+ assertObjectEquals("['foo','bar','baz']", t.getEnum());
+ assertType(List.class, t.getEnum());
+
+ t.setEnum(null);
+ t._enum("foo")._enum(new StringBuilder("bar"))._enum("['baz','qux']")._enum((Object)new String[]{"quux"});
+ assertObjectEquals("['foo','bar','baz','qux','quux']", t.getEnum());
+ assertType(List.class, t.getEnum());
+ }
+
+ /**
+ * Test method for {@link Items#multipleOf(java.lang.Object)}.
+ */
+ @Test
+ public void testMultipleOf() {
+ Items t = new Items();
+
+ t.multipleOf(123);
+ assertEquals(123, t.getMultipleOf());
+ assertType(Integer.class, t.getMultipleOf());
+
+ t.multipleOf(123f);
+ assertEquals(123f, t.getMultipleOf());
+ assertType(Float.class, t.getMultipleOf());
+
+ t.multipleOf("123");
+ assertEquals(123, t.getMultipleOf());
+ assertType(Integer.class, t.getMultipleOf());
+
+ t.multipleOf(new StringBuilder("123"));
+ assertEquals(123, t.getMultipleOf());
+ assertType(Integer.class, t.getMultipleOf());
+
+ t.multipleOf(null);
+ assertNull(t.getMultipleOf());
+ }
+
+ /**
+ * Test method for {@link Items#set(java.lang.String, java.lang.Object)}.
+ */
+ @Test
+ public void testSet() throws Exception {
+ Items t = new Items();
+
+ t
+ .set("default", "a")
+ .set("enum", new ASet<String>().append("b"))
+ .set("collectionFormat", "c")
+ .set("exclusiveMaximum", true)
+ .set("exclusiveMinimum", true)
+ .set("format", "g")
+ .set("items", items("h"))
+ .set("maximum", 123f)
+ .set("maxItems", 123)
+ .set("maxLength", 123)
+ .set("minimum", 123f)
+ .set("minItems", 123)
+ .set("minLength", 123)
+ .set("multipleOf", 123f)
+ .set("pattern", "i")
+ .set("type", "j")
+ .set("uniqueItems", true)
+ .set("$ref", "ref");
+
+ assertObjectEquals("{type:'j',format:'g',items:{type:'h'},collectionFormat:'c','default':'a',maximum:123.0,exclusiveMaximum:true,minimum:123.0,exclusiveMinimum:true,maxLength:123,minLength:123,pattern:'i',maxItems:123,minItems:123,uniqueItems:true,'enum':['b'],multipleOf:123.0,'$ref':'ref'}", t);
+
+ t
+ .set("default", "a")
+ .set("enum", "['b']")
+ .set("collectionFormat", "c")
+ .set("exclusiveMaximum", "true")
+ .set("exclusiveMinimum", "true")
+ .set("format", "g")
+ .set("items", "{type:'h'}")
+ .set("maximum", "123f")
+ .set("maxItems", "123")
+ .set("maxLength", "123")
+ .set("minimum", "123f")
+ .set("minItems", "123")
+ .set("minLength", "123")
+ .set("multipleOf", "123f")
+ .set("pattern", "i")
+ .set("type", "j")
+ .set("uniqueItems", "true")
+ .set("$ref", "ref");
+
+ assertObjectEquals("{type:'j',format:'g',items:{type:'h'},collectionFormat:'c','default':'a',maximum:123.0,exclusiveMaximum:true,minimum:123.0,exclusiveMinimum:true,maxLength:123,minLength:123,pattern:'i',maxItems:123,minItems:123,uniqueItems:true,'enum':['b'],multipleOf:123.0,'$ref':'ref'}", t);
+
+ t
+ .set("default", new StringBuilder("a"))
+ .set("enum", new StringBuilder("['b']"))
+ .set("collectionFormat", new StringBuilder("c"))
+ .set("exclusiveMaximum", new StringBuilder("true"))
+ .set("exclusiveMinimum", new StringBuilder("true"))
+ .set("format", new StringBuilder("g"))
+ .set("items", new StringBuilder("{type:'h'}"))
+ .set("maximum", new StringBuilder("123f"))
+ .set("maxItems", new StringBuilder("123"))
+ .set("maxLength", new StringBuilder("123"))
+ .set("minimum", new StringBuilder("123f"))
+ .set("minItems", new StringBuilder("123"))
+ .set("minLength", new StringBuilder("123"))
+ .set("multipleOf", new StringBuilder("123f"))
+ .set("pattern", new StringBuilder("i"))
+ .set("type", new StringBuilder("j"))
+ .set("uniqueItems", new StringBuilder("true"))
+ .set("$ref", new StringBuilder("ref"));
+
+ assertObjectEquals("{type:'j',format:'g',items:{type:'h'},collectionFormat:'c','default':'a',maximum:123.0,exclusiveMaximum:true,minimum:123.0,exclusiveMinimum:true,maxLength:123,minLength:123,pattern:'i',maxItems:123,minItems:123,uniqueItems:true,'enum':['b'],multipleOf:123.0,'$ref':'ref'}", t);
+
+ assertEquals("a", t.get("default", String.class));
+ assertEquals("['b']", t.get("enum", String.class));
+ assertEquals("c", t.get("collectionFormat", String.class));
+ assertEquals("true", t.get("exclusiveMaximum", String.class));
+ assertEquals("true", t.get("exclusiveMinimum", String.class));
+ assertEquals("g", t.get("format", String.class));
+ assertEquals("{type:'h'}", t.get("items", String.class));
+ assertEquals("123.0", t.get("maximum", String.class));
+ assertEquals("123", t.get("maxItems", String.class));
+ assertEquals("123", t.get("maxLength", String.class));
+ assertEquals("123.0", t.get("minimum", String.class));
+ assertEquals("123", t.get("minItems", String.class));
+ assertEquals("123", t.get("minLength", String.class));
+ assertEquals("123.0", t.get("multipleOf", String.class));
+ assertEquals("i", t.get("pattern", String.class));
+ assertEquals("j", t.get("type", String.class));
+ assertEquals("true", t.get("uniqueItems", String.class));
+ assertEquals("ref", t.get("$ref", String.class));
+
+ assertType(StringBuilder.class, t.get("default", Object.class));
+ assertType(List.class, t.get("enum", Object.class));
+ assertType(String.class, t.get("collectionFormat", Object.class));
+ assertType(Boolean.class, t.get("exclusiveMaximum", Object.class));
+ assertType(Boolean.class, t.get("exclusiveMinimum", Object.class));
+ assertType(String.class, t.get("format", Object.class));
+ assertType(Items.class, t.get("items", Object.class));
+ assertType(Float.class, t.get("maximum", Object.class));
+ assertType(Integer.class, t.get("maxItems", Object.class));
+ assertType(Integer.class, t.get("maxLength", Object.class));
+ assertType(Float.class, t.get("minimum", Object.class));
+ assertType(Integer.class, t.get("minItems", Object.class));
+ assertType(Integer.class, t.get("minLength", Object.class));
+ assertType(Float.class, t.get("multipleOf", Object.class));
+ assertType(String.class, t.get("pattern", Object.class));
+ assertType(String.class, t.get("type", Object.class));
+ assertType(Boolean.class, t.get("uniqueItems", Object.class));
+ assertType(StringBuilder.class, t.get("$ref", Object.class));
+
+ JsonSerializer.DEFAULT_LAX.println(t);
+
+ t.set("null", null).set(null, "null");
+ assertNull(t.get("null", Object.class));
+ assertNull(t.get(null, Object.class));
+ assertNull(t.get("foo", Object.class));
+
+ String s = "{type:'j',format:'g',items:{type:'h'},collectionFormat:'c','default':'a',maximum:123.0,exclusiveMaximum:true,minimum:123.0,exclusiveMinimum:true,maxLength:123,minLength:123,pattern:'i',maxItems:123,minItems:123,uniqueItems:true,'enum':['b'],multipleOf:123.0,'$ref':'ref'}";
+ assertObjectEquals(s, JsonParser.DEFAULT.parse(s, Items.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/LicenseTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/LicenseTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/LicenseTest.java
new file mode 100644
index 0000000..5983e5c
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/LicenseTest.java
@@ -0,0 +1,109 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.dto.swagger;
+
+import static org.apache.juneau.TestUtils.*;
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+
+import java.net.*;
+
+import org.apache.juneau.json.*;
+import org.junit.*;
+
+/**
+ * Testcase for {@link License}.
+ */
+public class LicenseTest {
+
+ /**
+ * Test method for {@link License#name(java.lang.Object)}.
+ */
+ @Test
+ public void testName() {
+ License t = new License();
+
+ t.name("foo");
+ assertEquals("foo", t.getName());
+
+ t.name(new StringBuilder("foo"));
+ assertEquals("foo", t.getName());
+ assertType(String.class, t.getName());
+
+ t.name(null);
+ assertNull(t.getName());
+ }
+
+ /**
+ * Test method for {@link License#url(java.lang.Object)}.
+ */
+ @Test
+ public void testUrl() {
+ License t = new License();
+
+ t.url(URI.create("foo"));
+ assertEquals("foo", t.getUrl().toString());
+
+ t.url("foo");
+ assertEquals("foo", t.getUrl().toString());
+ assertType(URI.class, t.getUrl());
+
+ t.url(null);
+ assertNull(t.getUrl());
+ }
+
+ /**
+ * Test method for {@link License#set(java.lang.String, java.lang.Object)}.
+ */
+ @Test
+ public void testSet() throws Exception {
+ License t = new License();
+
+ t
+ .set("name", "a")
+ .set("url", URI.create("b"))
+ .set("$ref", "ref");
+
+ assertObjectEquals("{name:'a',url:'b','$ref':'ref'}", t);
+
+ t
+ .set("name", "a")
+ .set("url", "b")
+ .set("$ref", "ref");
+
+ assertObjectEquals("{name:'a',url:'b','$ref':'ref'}", t);
+
+ t
+ .set("name", new StringBuilder("a"))
+ .set("url", new StringBuilder("b"))
+ .set("$ref", new StringBuilder("ref"));
+
+ assertObjectEquals("{name:'a',url:'b','$ref':'ref'}", t);
+
+ assertEquals("a", t.get("name", String.class));
+ assertEquals("b", t.get("url", String.class));
+ assertEquals("ref", t.get("$ref", String.class));
+
+ assertType(String.class, t.get("name", Object.class));
+ assertType(URI.class, t.get("url", Object.class));
+ assertType(StringBuilder.class, t.get("$ref", Object.class));
+
+ t.set("null", null).set(null, "null");
+ assertNull(t.get("null", Object.class));
+ assertNull(t.get(null, Object.class));
+ assertNull(t.get("foo", Object.class));
+
+ String s = "{name:'a',url:'b','$ref':'ref'}";
+ assertObjectEquals(s, JsonParser.DEFAULT.parse(s, License.class));
+ }
+}
http://git-wip-us.apache.org/repos/asf/juneau/blob/8df34f56/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/OperationTest.java
----------------------------------------------------------------------
diff --git a/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/OperationTest.java b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/OperationTest.java
new file mode 100644
index 0000000..1f44ad1
--- /dev/null
+++ b/juneau-core/juneau-core-test/src/test/java/org/apache/juneau/dto/swagger/OperationTest.java
@@ -0,0 +1,675 @@
+// ***************************************************************************************************************************
+// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file *
+// * distributed with this work for additional information regarding copyright ownership. The ASF licenses this file *
+// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance *
+// * with the License. You may obtain a copy of the License at *
+// * *
+// * http://www.apache.org/licenses/LICENSE-2.0 *
+// * *
+// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an *
+// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the *
+// * specific language governing permissions and limitations under the License. *
+// ***************************************************************************************************************************
+package org.apache.juneau.dto.swagger;
+
+import static org.apache.juneau.TestUtils.*;
+import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+
+import java.util.*;
+
+import org.apache.juneau.http.*;
+import org.apache.juneau.json.*;
+import org.apache.juneau.utils.*;
+
+import static org.apache.juneau.dto.swagger.SwaggerBuilder.*;
+
+import org.junit.*;
+
+/**
+ * Testcase for {@link Operation}.
+ */
+public class OperationTest {
+
+ /**
+ * Test method for {@link Operation#setTags(java.util.Collection)}.
+ */
+ @Test
+ public void testSetTags() {
+ Operation t = new Operation();
+
+ t.setTags(new ASet<String>().appendAll("foo","bar"));
+ assertObjectEquals("['foo','bar']", t.getTags());
+ assertType(List.class, t.getTags());
+
+ t.setTags(new ASet<String>());
+ assertObjectEquals("[]", t.getTags());
+ assertType(List.class, t.getTags());
+
+ t.setTags(null);
+ assertNull(t.getTags());
+ }
+
+ /**
+ * Test method for {@link Operation#addTags(java.util.Collection)}.
+ */
+ @Test
+ public void testAddTags() {
+ Operation t = new Operation();
+
+ t.addTags(new ASet<String>().appendAll("foo","bar"));
+ assertObjectEquals("['foo','bar']", t.getTags());
+ assertType(List.class, t.getTags());
+
+ t.addTags(new ASet<String>());
+ assertObjectEquals("['foo','bar']", t.getTags());
+ assertType(List.class, t.getTags());
+
+ t.addTags(null);
+ assertObjectEquals("['foo','bar']", t.getTags());
+ assertType(List.class, t.getTags());
+ }
+
+ /**
+ * Test method for {@link Operation#tags(java.lang.Object[])}.
+ */
+ @Test
+ public void testTags() {
+ Operation t = new Operation();
+
+ t.tags(new ASet<String>().appendAll("a"));
+ t.tags(new ASet<Object>().appendAll(new StringBuilder("b")));
+ t.tags((Object)new String[] {"c"});
+ t.tags((Object)new Object[] {new StringBuilder("d")});
+ t.tags("e");
+ t.tags("['f']");
+ t.tags("[]");
+ t.tags((Object)null);
+ assertObjectEquals("['a','b','c','d','e','f']", t.getTags());
+ for (String s : t.getTags())
+ assertType(String.class, s);
+ }
+
+ /**
+ * Test method for {@link Operation#summary(java.lang.Object)}.
+ */
+ @Test
+ public void testSummary() {
+ Operation t = new Operation();
+
+ t.summary("foo");
+ assertEquals("foo", t.getSummary());
+
+ t.summary(new StringBuilder("foo"));
+ assertEquals("foo", t.getSummary());
+ assertType(String.class, t.getSummary());
+
+ t.summary(null);
+ assertNull(t.getSummary());
+ }
+
+ /**
+ * Test method for {@link Operation#description(java.lang.Object)}.
+ */
+ @Test
+ public void testDescription() {
+ Operation t = new Operation();
+
+ t.description("foo");
+ assertEquals("foo", t.getDescription());
+
+ t.description(new StringBuilder("foo"));
+ assertEquals("foo", t.getDescription());
+ assertType(String.class, t.getDescription());
+
+ t.description(null);
+ assertNull(t.getDescription());
+ }
+
+ /**
+ * Test method for {@link Operation#externalDocs(java.lang.Object)}.
+ */
+ @Test
+ public void testExternalDocs() {
+ Operation t = new Operation();
+
+ t.externalDocs(externalDocumentation("foo"));
+ assertObjectEquals("{url:'foo'}", t.getExternalDocs());
+
+ t.externalDocs("{url:'foo'}");
+ assertObjectEquals("{url:'foo'}", t.getExternalDocs());
+ assertType(ExternalDocumentation.class, t.getExternalDocs());
+
+ t.externalDocs(null);
+ assertNull(t.getExternalDocs());
+ }
+
+ /**
+ * Test method for {@link Operation#operationId(java.lang.Object)}.
+ */
+ @Test
+ public void testOperationId() {
+ Operation t = new Operation();
+
+ t.operationId("foo");
+ assertEquals("foo", t.getOperationId());
+
+ t.operationId(new StringBuilder("foo"));
+ assertEquals("foo", t.getOperationId());
+ assertType(String.class, t.getOperationId());
+
+ t.operationId(null);
+ assertNull(t.getOperationId());
+ }
+
+ /**
+ * Test method for {@link Operation#setConsumes(java.util.Collection)}.
+ */
+ @Test
+ public void testSetConsumes() {
+ Operation t = new Operation();
+
+ t.setConsumes(new ASet<MediaType>().appendAll(MediaType.forString("text/foo")));
+ assertObjectEquals("['text/foo']", t.getConsumes());
+ assertType(List.class, t.getConsumes());
+
+ t.setConsumes(new ASet<MediaType>());
+ assertObjectEquals("[]", t.getConsumes());
+ assertType(List.class, t.getConsumes());
+
+ t.setConsumes(null);
+ assertNull(t.getConsumes());
+ }
+
+ /**
+ * Test method for {@link Operation#addConsumes(java.util.Collection)}.
+ */
+ @Test
+ public void testAddConsumes() {
+ Operation t = new Operation();
+
+ t.addConsumes(new ASet<MediaType>().appendAll(MediaType.forString("text/foo")));
+ assertObjectEquals("['text/foo']", t.getConsumes());
+ assertType(List.class, t.getConsumes());
+
+ t.addConsumes(new ASet<MediaType>());
+ assertObjectEquals("['text/foo']", t.getConsumes());
+ assertType(List.class, t.getConsumes());
+
+ t.addConsumes(null);
+ assertObjectEquals("['text/foo']", t.getConsumes());
+ assertType(List.class, t.getConsumes());
+ }
+
+ /**
+ * Test method for {@link Operation#consumes(java.lang.Object[])}.
+ */
+ @Test
+ public void testConsumes() {
+ Operation t = new Operation();
+
+ t.consumes(new ASet<MediaType>().appendAll(MediaType.forString("text/foo")));
+ t.consumes(MediaType.forString("text/bar"));
+ t.consumes("text/baz");
+ t.consumes(new StringBuilder("text/qux"));
+ t.consumes((Object)new String[]{"text/quux"});
+ t.consumes((Object)new ASet<String>().append("text/quuux"));
+ t.consumes("['text/quuuux']");
+ t.consumes("[]");
+ t.consumes((Object)null);
+ assertObjectEquals("['text/foo','text/bar','text/baz','text/qux','text/quux','text/quuux','text/quuuux']", t.getConsumes());
+ assertType(List.class, t.getConsumes());
+ for (MediaType mt : t.getConsumes())
+ assertType(MediaType.class, mt);
+ }
+
+ /**
+ * Test method for {@link Operation#setProduces(java.util.Collection)}.
+ */
+ @Test
+ public void testSetProduces() {
+ Operation t = new Operation();
+
+ t.setProduces(new ASet<MediaType>().appendAll(MediaType.forString("text/foo")));
+ assertObjectEquals("['text/foo']", t.getProduces());
+ assertType(List.class, t.getProduces());
+
+ t.setProduces(new ASet<MediaType>());
+ assertObjectEquals("[]", t.getProduces());
+ assertType(List.class, t.getProduces());
+
+ t.setProduces(null);
+ assertNull(t.getProduces());
+ }
+
+ /**
+ * Test method for {@link Operation#addProduces(java.util.Collection)}.
+ */
+ @Test
+ public void testAddProduces() {
+ Operation t = new Operation();
+
+ t.addProduces(new ASet<MediaType>().appendAll(MediaType.forString("text/foo")));
+ assertObjectEquals("['text/foo']", t.getProduces());
+ assertType(List.class, t.getProduces());
+
+ t.addProduces(new ASet<MediaType>());
+ assertObjectEquals("['text/foo']", t.getProduces());
+ assertType(List.class, t.getProduces());
+
+ t.addProduces(null);
+ assertObjectEquals("['text/foo']", t.getProduces());
+ assertType(List.class, t.getProduces());
+ }
+
+ /**
+ * Test method for {@link Operation#produces(java.lang.Object[])}.
+ */
+ @Test
+ public void testProduces() {
+ Operation t = new Operation();
+
+ t.produces(new ASet<MediaType>().appendAll(MediaType.forString("text/foo")));
+ t.produces(MediaType.forString("text/bar"));
+ t.produces("text/baz");
+ t.produces(new StringBuilder("text/qux"));
+ t.produces((Object)new String[]{"text/quux"});
+ t.produces((Object)new ASet<String>().append("text/quuux"));
+ t.produces("['text/quuuux']");
+ t.produces("[]");
+ t.produces((Object)null);
+ assertObjectEquals("['text/foo','text/bar','text/baz','text/qux','text/quux','text/quuux','text/quuuux']", t.getProduces());
+ assertType(List.class, t.getProduces());
+ for (MediaType mt : t.getProduces())
+ assertType(MediaType.class, mt);
+ }
+
+ /**
+ * Test method for {@link Operation#setParameters(java.util.Collection)}.
+ */
+ @Test
+ public void testSetParameters() {
+ Operation t = new Operation();
+
+ t.setParameters(new ASet<ParameterInfo>().appendAll(parameterInfo("foo","bar")));
+ assertObjectEquals("[{'in':'foo',name:'bar'}]", t.getParameters());
+ assertType(List.class, t.getParameters());
+
+ t.setParameters(new ASet<ParameterInfo>());
+ assertObjectEquals("[]", t.getParameters());
+ assertType(List.class, t.getParameters());
+
+ t.setParameters(null);
+ assertNull(t.getParameters());
+ }
+
+ /**
+ * Test method for {@link Operation#addParameters(java.util.Collection)}.
+ */
+ @Test
+ public void testAddParameters() {
+ Operation t = new Operation();
+
+ t.addParameters(new ASet<ParameterInfo>().appendAll(parameterInfo("foo","bar")));
+ assertObjectEquals("[{'in':'foo',name:'bar'}]", t.getParameters());
+ assertType(List.class, t.getParameters());
+
+ t.addParameters(new ASet<ParameterInfo>());
+ assertObjectEquals("[{'in':'foo',name:'bar'}]", t.getParameters());
+ assertType(List.class, t.getParameters());
+
+ t.addParameters(null);
+ assertObjectEquals("[{'in':'foo',name:'bar'}]", t.getParameters());
+ assertType(List.class, t.getParameters());
+ }
+
+ /**
+ * Test method for {@link Operation#parameters(java.lang.Object[])}.
+ */
+ @Test
+ public void testParameters() {
+ Operation t = new Operation();
+
+ t.parameters(new ASet<ParameterInfo>().appendAll(parameterInfo("a1","a2")));
+ t.parameters(parameterInfo("b1","b2"));
+ t.parameters("{in:'c1',name:'c2'}");
+ t.parameters(new StringBuilder("{in:'d1',name:'d2'}"));
+ t.parameters((Object)new String[]{"{in:'e1',name:'e2'}"});
+ t.parameters((Object)new ASet<String>().append("{in:'f1',name:'f2'}"));
+ t.parameters("[{in:'g1',name:'g2'}]");
+ t.parameters("[]");
+ t.parameters((Object)null);
+ assertObjectEquals("[{'in':'a1',name:'a2'},{'in':'b1',name:'b2'},{'in':'c1',name:'c2'},{'in':'d1',name:'d2'},{'in':'e1',name:'e2'},{'in':'f1',name:'f2'},{'in':'g1',name:'g2'}]", t.getParameters());
+ assertType(List.class, t.getParameters());
+ for (ParameterInfo pi : t.getParameters())
+ assertType(ParameterInfo.class, pi);
+ }
+
+ /**
+ * Test method for {@link Operation#setResponses(java.util.Map)}.
+ */
+ @Test
+ public void testSetResponses() {
+ Operation t = new Operation();
+
+ t.setResponses(new AMap<Integer,ResponseInfo>().append(123,responseInfo("bar")));
+ assertObjectEquals("{'123':{description:'bar'}}", t.getResponses());
+ assertType(Map.class, t.getResponses());
+
+ t.setResponses(new AMap<Integer,ResponseInfo>());
+ assertObjectEquals("{}", t.getResponses());
+ assertType(Map.class, t.getResponses());
+
+ t.setResponses(null);
+ assertNull(t.getResponses());
+ }
+
+ /**
+ * Test method for {@link Operation#addResponses(java.util.Map)}.
+ */
+ @Test
+ public void testAddResponses() {
+ Operation t = new Operation();
+
+ t.addResponses(new AMap<Integer,ResponseInfo>().append(123,responseInfo("bar")));
+ assertObjectEquals("{'123':{description:'bar'}}", t.getResponses());
+ assertType(Map.class, t.getResponses());
+
+ t.addResponses(new AMap<Integer,ResponseInfo>());
+ assertObjectEquals("{'123':{description:'bar'}}", t.getResponses());
+ assertType(Map.class, t.getResponses());
+
+ t.addResponses(null);
+ assertObjectEquals("{'123':{description:'bar'}}", t.getResponses());
+ assertType(Map.class, t.getResponses());
+ }
+
+ /**
+ * Test method for {@link Operation#response(java.lang.Integer, org.apache.juneau.dto.swagger.ResponseInfo)}.
+ */
+ @Test
+ public void testResponse() {
+ Operation t = new Operation();
+
+ t.response(1, responseInfo("foo"));
+ t.response(null, responseInfo("bar"));
+ t.response(2, null);
+ assertObjectEquals("{'1':{description:'foo'},null:{description:'bar'},'2':null}", t.getResponses());
+ }
+
+ /**
+ * Test method for {@link Operation#responses(java.lang.Object[])}.
+ */
+ @Test
+ public void testResponses() {
+ Operation t = new Operation();
+
+ t.responses(new AMap<Integer,ResponseInfo>().append(1,responseInfo("a")));
+ t.responses(new AMap<String,String>().append("2","{description:'b'}"));
+ t.responses("{3:{description:'c'}}");
+ t.responses("{}");
+ t.responses((Object)null);
+
+ assertObjectEquals("{'1':{description:'a'},'2':{description:'b'},'3':{description:'c'}}", t.getResponses());
+ for (Map.Entry<Integer,ResponseInfo> e : t.getResponses().entrySet()) {
+ assertType(Integer.class, e.getKey());
+ assertType(ResponseInfo.class, e.getValue());
+ }
+ }
+
+ /**
+ * Test method for {@link Operation#setSchemes(java.util.Collection)}.
+ */
+ @Test
+ public void testSetSchemes() {
+ Operation t = new Operation();
+
+ t.setSchemes(new ASet<String>().appendAll("foo"));
+ assertObjectEquals("['foo']", t.getSchemes());
+ assertType(List.class, t.getSchemes());
+
+ t.setSchemes(new ASet<String>());
+ assertObjectEquals("[]", t.getSchemes());
+ assertType(List.class, t.getSchemes());
+
+ t.setSchemes(null);
+ assertNull(t.getSchemes());
+ }
+
+ /**
+ * Test method for {@link Operation#setSecurity(java.util.Collection)}.
+ */
+ @Test
+ public void testSetSecurity() {
+ Operation t = new Operation();
+
+ t.setSecurity(new ASet<Map<String, List<String>>>().append(new AMap<String,List<String>>().append("foo",new AList<String>().append("bar"))));
+ assertObjectEquals("[{foo:['bar']}]", t.getSecurity());
+ assertType(List.class, t.getSecurity());
+
+ t.setSecurity(new ASet<Map<String, List<String>>>());
+ assertObjectEquals("[]", t.getSecurity());
+ assertType(List.class, t.getSecurity());
+
+ t.setSecurity(null);
+ assertNull(t.getSecurity());
+ }
+
+ /**
+ * Test method for {@link Operation#addSchemes(java.util.Collection)}.
+ */
+ @Test
+ public void testAddSchemes() {
+ Operation t = new Operation();
+
+ t.addSchemes(new ASet<String>().appendAll("foo"));
+ assertObjectEquals("['foo']", t.getSchemes());
+ assertType(List.class, t.getSchemes());
+
+ t.addSchemes(new ASet<String>());
+ assertObjectEquals("['foo']", t.getSchemes());
+ assertType(List.class, t.getSchemes());
+
+ t.addSchemes(null);
+ assertObjectEquals("['foo']", t.getSchemes());
+ assertType(List.class, t.getSchemes());
+ }
+
+ /**
+ * Test method for {@link Operation#schemes(java.lang.Object[])}.
+ */
+ @Test
+ public void testSchemes() {
+ Operation t = new Operation();
+
+ t.schemes(new ASet<String>().appendAll("a"));
+ t.schemes(new ASet<Object>().appendAll(new StringBuilder("b")));
+ t.schemes((Object)new String[] {"c"});
+ t.schemes((Object)new Object[] {new StringBuilder("d")});
+ t.schemes("e");
+ t.schemes("['f']");
+ t.schemes("[]");
+ t.schemes((Object)null);
+ assertObjectEquals("['a','b','c','d','e','f']", t.getSchemes());
+ for (String s : t.getSchemes())
+ assertType(String.class, s);
+ }
+
+ /**
+ * Test method for {@link Operation#deprecated(java.lang.Object)}.
+ */
+ @Test
+ public void testDeprecated() {
+ Operation t = new Operation();
+
+ t.deprecated(true);
+ assertEquals(true, t.getDeprecated());
+ assertType(Boolean.class, t.getDeprecated());
+
+ t.deprecated("true");
+ assertEquals(true, t.getDeprecated());
+ assertType(Boolean.class, t.getDeprecated());
+
+ t.deprecated(new StringBuilder("true"));
+ assertEquals(true, t.getDeprecated());
+ assertType(Boolean.class, t.getDeprecated());
+
+ t.deprecated(null);
+ assertNull(t.getDeprecated());
+ }
+
+ /**
+ * Test method for {@link Operation#addSecurity(java.util.List)}.
+ */
+ @Test
+ public void testAddSecurity() {
+ Operation t = new Operation();
+
+ t.addSecurity(new ASet<Map<String, List<String>>>().append(new AMap<String,List<String>>().append("foo",new AList<String>().append("bar"))));
+ assertObjectEquals("[{foo:['bar']}]", t.getSecurity());
+ assertType(List.class, t.getSecurity());
+
+ t.addSecurity(new ASet<Map<String, List<String>>>());
+ assertObjectEquals("[{foo:['bar']}]", t.getSecurity());
+ assertType(List.class, t.getSecurity());
+
+ t.addSecurity(null);
+ assertObjectEquals("[{foo:['bar']}]", t.getSecurity());
+ assertType(List.class, t.getSecurity());
+ }
+
+ /**
+ * Test method for {@link Operation#security(java.lang.String, java.lang.String[])}.
+ */
+ @Test
+ public void testSecurity() {
+ Operation t = new Operation();
+
+ t.security("a", "a1", "a2");
+ t.security("b");
+ t.security("c", (String)null);
+ t.security(null, "d");
+
+ assertObjectEquals("[{a:['a1','a2']},{b:[]},{c:[null]},{null:['d']}]", t.getSecurity());
+ }
+
+ /**
+ * Test method for {@link Operation#securities(java.lang.Object[])}.
+ */
+ @Test
+ public void testSecurities() {
+ Operation t = new Operation();
+
+ t.securities(new ASet<Map<String,List<String>>>().append(new AMap<String,List<String>>().append("a1",new AList<String>().append("a2"))));
+ t.securities(new AMap<String,List<String>>().append("b1",new AList<String>().append("b2")));
+ t.securities("{c1:['c2']}");
+ t.securities(new StringBuilder("{d1:['d2']}"));
+ t.securities((Object)new String[]{"{e1:['e2']}"});
+ t.securities((Object)new ASet<String>().append("{f1:['f2']}"));
+ t.securities("[{g1:['g2']}]");
+ t.securities("[]");
+ t.securities((Object)null);
+ assertObjectEquals("[{a1:['a2']},{b1:['b2']},{c1:['c2']},{d1:['d2']},{e1:['e2']},{f1:['f2']},{g1:['g2']}]", t.getSecurity());
+ assertType(List.class, t.getSecurity());
+ }
+
+ /**
+ * Test method for {@link Operation#set(java.lang.String, java.lang.Object)}.
+ */
+ @Test
+ public void testSet() throws Exception {
+ Operation t = new Operation();
+
+ t
+ .set("consumes", new ASet<MediaType>().appendAll(MediaType.forString("text/a")))
+ .set("deprecated", true)
+ .set("description", "b")
+ .set("externalDocs", externalDocumentation("c"))
+ .set("operationId", "d")
+ .set("parameters", new ASet<ParameterInfo>().appendAll(parameterInfo("e1","e2")))
+ .set("produces", new ASet<MediaType>().appendAll(MediaType.forString("text/f")))
+ .set("responses", new AMap<Integer,ResponseInfo>().append(1,responseInfo("g")))
+ .set("schemes", new ASet<String>().appendAll("h"))
+ .set("security", new ASet<Map<String,List<String>>>().append(new AMap<String,List<String>>().append("i1",new AList<String>().append("i2"))))
+ .set("summary", "j")
+ .set("tags", new ASet<String>().appendAll("k"))
+ .set("$ref", "ref");
+
+ assertObjectEquals("{operationId:'d',summary:'j',description:'b',tags:['k'],externalDocs:{url:'c'},consumes:['text/a'],produces:['text/f'],parameters:[{'in':'e1',name:'e2'}],responses:{'1':{description:'g'}},schemes:['h'],deprecated:true,security:[{i1:['i2']}],'$ref':'ref'}", t);
+
+ t
+ .set("consumes", "['text/a']")
+ .set("deprecated", "true")
+ .set("description", "b")
+ .set("externalDocs", "{url:'c'}")
+ .set("operationId", "d")
+ .set("parameters", "[{'in':'e1',name:'e2'}]")
+ .set("produces", "['text/f']")
+ .set("responses", "{'1':{description:'g'}}")
+ .set("schemes", "['h']")
+ .set("security", "[{i1:['i2']}]")
+ .set("summary", "j")
+ .set("tags", "['k']")
+ .set("$ref", "ref");
+
+ assertObjectEquals("{operationId:'d',summary:'j',description:'b',tags:['k'],externalDocs:{url:'c'},consumes:['text/a'],produces:['text/f'],parameters:[{'in':'e1',name:'e2'}],responses:{'1':{description:'g'}},schemes:['h'],deprecated:true,security:[{i1:['i2']}],'$ref':'ref'}", t);
+
+ t
+ .set("consumes", new StringBuilder("['text/a']"))
+ .set("deprecated", new StringBuilder("true"))
+ .set("description", new StringBuilder("b"))
+ .set("externalDocs", new StringBuilder("{url:'c'}"))
+ .set("operationId", new StringBuilder("d"))
+ .set("parameters", new StringBuilder("[{'in':'e1',name:'e2'}]"))
+ .set("produces", new StringBuilder("['text/f']"))
+ .set("responses", new StringBuilder("{'1':{description:'g'}}"))
+ .set("schemes", new StringBuilder("['h']"))
+ .set("security", new StringBuilder("[{i1:['i2']}]"))
+ .set("summary", new StringBuilder("j"))
+ .set("tags", new StringBuilder("['k']"))
+ .set("$ref", new StringBuilder("ref"));
+
+ assertObjectEquals("{operationId:'d',summary:'j',description:'b',tags:['k'],externalDocs:{url:'c'},consumes:['text/a'],produces:['text/f'],parameters:[{'in':'e1',name:'e2'}],responses:{'1':{description:'g'}},schemes:['h'],deprecated:true,security:[{i1:['i2']}],'$ref':'ref'}", t);
+
+ assertEquals("['text/a']", t.get("consumes", String.class));
+ assertEquals("true", t.get("deprecated", String.class));
+ assertEquals("b", t.get("description", String.class));
+ assertEquals("{url:'c'}", t.get("externalDocs", String.class));
+ assertEquals("d", t.get("operationId", String.class));
+ assertEquals("[{'in':'e1',name:'e2'}]", t.get("parameters", String.class));
+ assertEquals("['text/f']", t.get("produces", String.class));
+ assertEquals("{'1':{description:'g'}}", t.get("responses", String.class));
+ assertEquals("['h']", t.get("schemes", String.class));
+ assertEquals("[{i1:['i2']}]", t.get("security", String.class));
+ assertEquals("j", t.get("summary", String.class));
+ assertEquals("['k']", t.get("tags", String.class));
+ assertEquals("ref", t.get("$ref", String.class));
+
+ assertType(List.class, t.get("consumes", Object.class));
+ assertType(MediaType.class, t.get("consumes", List.class).get(0));
+ assertType(Boolean.class, t.get("deprecated", Object.class));
+ assertType(String.class, t.get("description", Object.class));
+ assertType(ExternalDocumentation.class, t.get("externalDocs", Object.class));
+ assertType(String.class, t.get("operationId", Object.class));
+ assertType(List.class, t.get("parameters", Object.class));
+ assertType(ParameterInfo.class, t.get("parameters", List.class).get(0));
+ assertType(List.class, t.get("produces", Object.class));
+ assertType(MediaType.class, t.get("produces", List.class).get(0));
+ assertType(Map.class, t.get("responses", Object.class));
+ assertType(Integer.class, t.get("responses", Map.class).keySet().iterator().next());
+ assertType(ResponseInfo.class, t.get("responses", Map.class).values().iterator().next());
+ assertType(List.class, t.get("schemes", Object.class));
+ assertType(List.class, t.get("security", Object.class));
+ assertType(String.class, t.get("summary", Object.class));
+ assertType(List.class, t.get("tags", Object.class));
+ assertType(StringBuilder.class, t.get("$ref", Object.class));
+
+ t.set("null", null).set(null, "null");
+ assertNull(t.get("null", Object.class));
+ assertNull(t.get(null, Object.class));
+ assertNull(t.get("foo", Object.class));
+
+ String s = "{operationId:'d',summary:'j',description:'b',tags:['k'],externalDocs:{url:'c'},consumes:['text/a'],produces:['text/f'],parameters:[{'in':'e1',name:'e2'}],responses:{'1':{description:'g'}},schemes:['h'],deprecated:true,security:[{i1:['i2']}],'$ref':'ref'}";
+ assertObjectEquals(s, JsonParser.DEFAULT.parse(s, Operation.class));
+ }
+}