Search in sources :

Example 16 with TestTemplate

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

the class DatabaseURIHelperTest method buildDbUri.

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

Example 17 with TestTemplate

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

the class DatabaseURIHelperTest method buildDocumentUri_specialCharsInDocumentId.

@TestTemplate
public void buildDocumentUri_specialCharsInDocumentId(String path) throws Exception {
    URI expected = new URI(uriBase + "/test/SDF@%23%25$%23)DFGKLDfdffdg%C3%A9");
    URI actual = helper(path + "/test").documentUri("SDF@#%$#)DFGKLDfdffdg\u00E9");
    Assertions.assertEquals(expected, actual);
}
Also used : URI(java.net.URI) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 18 with TestTemplate

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

the class DatabaseURIHelperTest method buildDocumentUri_woOptions.

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

Example 19 with TestTemplate

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

the class DatabaseURIHelperTest method _localDocumentURI.

@TestTemplate
public void _localDocumentURI(String path) throws Exception {
    final String expected = uriBase + "/db_name/_local/mylocaldoc";
    DatabaseURIHelper helper = helper(path + "/db_name");
    URI localDoc = helper.documentUri("_local/mylocaldoc");
    Assertions.assertEquals(expected, localDoc.toString());
}
Also used : DatabaseURIHelper(com.cloudant.client.internal.DatabaseURIHelper) URI(java.net.URI) TestTemplate(org.junit.jupiter.api.TestTemplate)

Example 20 with TestTemplate

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

the class DatabaseURIHelperTest method buildDocumentUri_options_hasPlus.

@TestTemplate
public void buildDocumentUri_options_hasPlus(String path) throws Exception {
    URI expected = new URI(uriBase + "/test/path1%2Fpath2?q=class:mammal%2Bwith%2Bplusses");
    TreeMap<String, Object> options = new TreeMap<String, Object>();
    options.put("q", "class:mammal+with+plusses");
    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)

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