Search in sources :

Example 46 with TestTemplate

use of org.junit.jupiter.api.TestTemplate in project java-cloudant by cloudant.

the class DatabaseURIHelperTest method buildDocumentUri_options_encodeSeparators.

@TestTemplate
public void buildDocumentUri_options_encodeSeparators(String path) throws Exception {
    URI expected = new URI(uriBase + "/test/path1%2Fpath2?d%26etail%3D=%26%3D%3Dds%26&revs=%5B1-2%5D");
    TreeMap<String, Object> options = new TreeMap<String, Object>();
    options.put("revs", "[1-2]");
    options.put("d&etail=", "&==ds&");
    URI actual = helper(path + "/test").documentId("path1/path2").query(options).build();
    Assertions.assertEquals(expected, actual);
}
Also used : TreeMap(java.util.TreeMap) URI(java.net.URI) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 47 with TestTemplate

use of org.junit.jupiter.api.TestTemplate in project java-cloudant by cloudant.

the class DatabaseURIHelperTest method buildChangesUri_woOptions.

@TestTemplate
public void buildChangesUri_woOptions(String path) throws Exception {
    URI expected = new URI(uriBase + "/test/_changes");
    URI actual = helper(path + "/test").changesUri(new HashMap<String, Object>());
    Assertions.assertEquals(expected, actual);
}
Also used : URI(java.net.URI) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 48 with TestTemplate

use of org.junit.jupiter.api.TestTemplate in project java-cloudant by cloudant.

the class DatabaseURIHelperTest method buildDocumentUri_colonInDocumentId.

@TestTemplate
public void buildDocumentUri_colonInDocumentId(String path) throws Exception {
    URI expected = new URI(uriBase + "/test/:this:has:colons:");
    URI actual = helper(path + "/test").documentUri(":this:has:colons:");
    Assertions.assertEquals(expected, actual);
}
Also used : URI(java.net.URI) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 49 with TestTemplate

use of org.junit.jupiter.api.TestTemplate in project java-cloudant by cloudant.

the class DatabaseURIHelperTest method buildChangesUri_options_optionsEncoded.

@TestTemplate
public void buildChangesUri_options_optionsEncoded(String path) throws Exception {
    URI expected = new URI(uriBase + "/test/_changes?limit=100&since=%22%5B%5D%22");
    Map<String, Object> options = new HashMap<String, Object>();
    options.put("since", "\"[]\"");
    options.put("limit", 100);
    URI actual = helper(path + "/test").changesUri(options);
    Assertions.assertEquals(expected, actual);
}
Also used : HashMap(java.util.HashMap) URI(java.net.URI) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 50 with TestTemplate

use of org.junit.jupiter.api.TestTemplate in project java-cloudant by cloudant.

the class DatabaseURIHelperTest method buildBulkDocsUri.

@TestTemplate
public void buildBulkDocsUri(String path) throws Exception {
    URI expected = new URI(uriBase + "/test/_bulk_docs");
    URI actual = helper(path + "/test").bulkDocsUri();
    Assertions.assertEquals(expected, actual);
}
Also used : URI(java.net.URI) TestTemplate(org.junit.jupiter.api.TestTemplate)

Aggregations

TestTemplate (org.junit.jupiter.api.TestTemplate)51 CloudantClient (com.cloudant.client.api.CloudantClient)23 URI (java.net.URI)18 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)18 MockResponse (okhttp3.mockwebserver.MockResponse)16 HttpConnection (com.cloudant.http.HttpConnection)11 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)7 TreeMap (java.util.TreeMap)5 TestTimer (com.cloudant.tests.util.TestTimer)4 ByteArrayInputStream (java.io.ByteArrayInputStream)4 URL (java.net.URL)4 TooManyRequestsException (com.cloudant.client.org.lightcouch.TooManyRequestsException)3 Replay429Interceptor (com.cloudant.http.interceptors.Replay429Interceptor)3 CouchDbException (com.cloudant.client.org.lightcouch.CouchDbException)2 HttpConnectionInterceptorContext (com.cloudant.http.HttpConnectionInterceptorContext)2 RequiresCloudant (com.cloudant.test.main.RequiresCloudant)2 RequiresCloudantService (com.cloudant.test.main.RequiresCloudantService)2 Gson (com.google.gson.Gson)2 JsonObject (com.google.gson.JsonObject)2 IOException (java.io.IOException)2