mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Add unit tests
This commit is contained in:
parent
85d0e08a80
commit
19a8ac4841
@ -0,0 +1,42 @@
|
||||
package io.swagger.client;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.*;
|
||||
|
||||
public class ApiInvokerTest {
|
||||
@Test
|
||||
public void testSelectHeaderAccept() {
|
||||
String[] accepts = { "APPLICATION/JSON", "APPLICATION/XML" };
|
||||
assertEquals("application/json", ApiInvoker.selectHeaderAccept(accepts));
|
||||
|
||||
accepts = new String[] { "application/json", "application/xml" };
|
||||
assertEquals("application/json", ApiInvoker.selectHeaderAccept(accepts));
|
||||
|
||||
accepts = new String[] { "application/xml", "application/json" };
|
||||
assertEquals("application/json", ApiInvoker.selectHeaderAccept(accepts));
|
||||
|
||||
accepts = new String[] { "text/plain", "application/xml" };
|
||||
assertEquals("text/plain,application/xml", ApiInvoker.selectHeaderAccept(accepts));
|
||||
|
||||
accepts = new String[] { };
|
||||
assertEquals("application/json", ApiInvoker.selectHeaderAccept(accepts));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSelectHeaderContentType() {
|
||||
String[] contentTypes = { "APPLICATION/JSON", "APPLICATION/XML" };
|
||||
assertEquals("application/json", ApiInvoker.selectHeaderContentType(contentTypes));
|
||||
|
||||
contentTypes = new String[] { "application/json", "application/xml" };
|
||||
assertEquals("application/json", ApiInvoker.selectHeaderContentType(contentTypes));
|
||||
|
||||
contentTypes = new String[] { "application/xml", "application/json" };
|
||||
assertEquals("application/json", ApiInvoker.selectHeaderContentType(contentTypes));
|
||||
|
||||
contentTypes = new String[] { "text/plain", "application/xml" };
|
||||
assertEquals("text/plain", ApiInvoker.selectHeaderContentType(contentTypes));
|
||||
|
||||
contentTypes = new String[] { };
|
||||
assertEquals("application/json", ApiInvoker.selectHeaderContentType(contentTypes));
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package io.swagger.client;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.*;
|
||||
|
||||
public class StringUtilTest {
|
||||
@Test
|
||||
public void testContainsIgnoreCase() {
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{ "abc" }, "abc"));
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{ "abc" }, "ABC"));
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{ "ABC" }, "abc"));
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{ null, "abc" }, "ABC"));
|
||||
assertTrue(StringUtil.containsIgnoreCase(new String[]{ null, "abc" }, null));
|
||||
|
||||
assertFalse(StringUtil.containsIgnoreCase(new String[]{ "abc" }, "def"));
|
||||
assertFalse(StringUtil.containsIgnoreCase(new String[]{ }, "ABC"));
|
||||
assertFalse(StringUtil.containsIgnoreCase(new String[]{ }, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoin() {
|
||||
String[] array = { "aa", "bb", "cc" };
|
||||
assertEquals("aa,bb,cc", StringUtil.join(array, ","));
|
||||
assertEquals("aa, bb, cc", StringUtil.join(array, ", "));
|
||||
assertEquals("aabbcc", StringUtil.join(array, ""));
|
||||
assertEquals("aa bb cc", StringUtil.join(array, " "));
|
||||
assertEquals("aa\nbb\ncc", StringUtil.join(array, "\n"));
|
||||
|
||||
assertEquals("", StringUtil.join(new String[]{ }, ","));
|
||||
assertEquals("abc", StringUtil.join(new String[]{ "abc" }, ","));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user