|
| 1 | +package io.swagger.client; |
| 2 | + |
| 3 | +import static org.junit.Assert.*; |
| 4 | +import org.junit.*; |
| 5 | + |
| 6 | +public class ApiClientTest { |
| 7 | + ApiClient apiClient = null; |
| 8 | + |
| 9 | + @Before |
| 10 | + public void setup() { |
| 11 | + apiClient = new ApiClient(); |
| 12 | + } |
| 13 | + @Test |
| 14 | + public void testSelectHeaderAccept() { |
| 15 | + String[] accepts = { "APPLICATION/JSON", "APPLICATION/XML" }; |
| 16 | + assertEquals("application/json", apiClient.selectHeaderAccept(accepts)); |
| 17 | + |
| 18 | + accepts = new String[] { "application/json", "application/xml" }; |
| 19 | + assertEquals("application/json", apiClient.selectHeaderAccept(accepts)); |
| 20 | + |
| 21 | + accepts = new String[] { "application/xml", "application/json" }; |
| 22 | + assertEquals("application/json", apiClient.selectHeaderAccept(accepts)); |
| 23 | + |
| 24 | + accepts = new String[] { "text/plain", "application/xml" }; |
| 25 | + assertEquals("text/plain,application/xml", apiClient.selectHeaderAccept(accepts)); |
| 26 | + |
| 27 | + accepts = new String[] { }; |
| 28 | + assertNull(apiClient.selectHeaderAccept(accepts)); |
| 29 | + } |
| 30 | + |
| 31 | + @Test |
| 32 | + public void testSelectHeaderContentType() { |
| 33 | + String[] contentTypes = { "APPLICATION/JSON", "APPLICATION/XML" }; |
| 34 | + assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes)); |
| 35 | + |
| 36 | + contentTypes = new String[] { "application/json", "application/xml" }; |
| 37 | + assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes)); |
| 38 | + |
| 39 | + contentTypes = new String[] { "application/xml", "application/json" }; |
| 40 | + assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes)); |
| 41 | + |
| 42 | + contentTypes = new String[] { "text/plain", "application/xml" }; |
| 43 | + assertEquals("text/plain", apiClient.selectHeaderContentType(contentTypes)); |
| 44 | + |
| 45 | + contentTypes = new String[] { }; |
| 46 | + assertEquals("application/json", apiClient.selectHeaderContentType(contentTypes)); |
| 47 | + } |
| 48 | +} |
0 commit comments