Search in sources :

Example 66 with Test

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

the class QueryTests method basicSelector5_single.

// "$and operator used with full text indexing"
@Test
public void basicSelector5_single() {
    QueryBuilder qb = new QueryBuilder(and(eq("$text", "Schwarzenegger"), in("year", 1984)));
    Assertions.assertEquals("{\"selector\": {\"$and\": [{\"$text\": {\"$eq\": " + "\"Schwarzenegger\"}}, {\"year\": {\"$in\": [1984]}}]}}", qb.build());
}
Also used : QueryBuilder(com.cloudant.client.api.query.QueryBuilder) Test(org.junit.jupiter.api.Test)

Example 67 with Test

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

the class ReplicatorTest method replication_filteredWithQueryParams.

@Test
public void replication_filteredWithQueryParams() throws Exception {
    Map<String, Object> queryParams = new HashMap<String, Object>();
    queryParams.put("somekey1", "value 1");
    Response response = account.replicator().createTarget(true).replicatorDocId(repDocId).source(db1URI).target(db2URI).filter("example/example_filter").queryParams(queryParams).save();
    // find and remove replicator doc
    ReplicatorDocument repDoc = Utils.waitForReplicatorToComplete(account, response.getId());
    assertTrue("completed".equalsIgnoreCase(repDoc.getReplicationState()), "The replicator " + "should reach completed state");
}
Also used : Response(com.cloudant.client.api.model.Response) HashMap(java.util.HashMap) ReplicatorDocument(com.cloudant.client.api.model.ReplicatorDocument) Test(org.junit.jupiter.api.Test)

Example 68 with Test

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

the class ReplicatorTest method replication.

@Test
public void replication() throws Exception {
    Response response = account.replicator().replicatorDocId(repDocId).createTarget(true).source(db1URI).target(db2URI).save();
    // find and remove replicator doc
    ReplicatorDocument repDoc = Utils.waitForReplicatorToComplete(account, response.getId());
    assertTrue("completed".equalsIgnoreCase(repDoc.getReplicationState()), "The replicator " + "should reach completed state");
}
Also used : Response(com.cloudant.client.api.model.Response) ReplicatorDocument(com.cloudant.client.api.model.ReplicatorDocument) Test(org.junit.jupiter.api.Test)

Example 69 with Test

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

the class ReplicatorTest method replication_conflict.

@Test
public void replication_conflict() throws Exception {
    String docId = Utils.generateUUID();
    Foo foodb1 = new Foo(docId, "titleX");
    Foo foodb2 = new Foo(docId, "titleY");
    // save Foo(X) in DB1
    db1.save(foodb1);
    // save Foo(Y) in DB2
    db2.save(foodb2);
    // replicate with DB1 with DB2
    Response response = account.replicator().source(db1URI).target(db2URI).replicatorDocId(repDocId).save();
    // we need the replication to finish before continuing
    Utils.waitForReplicatorToComplete(account, response.getId());
    // we replicated with a doc with the same ID but different content in each DB, we should get
    // a conflict
    assertConflictsNotZero(db2);
}
Also used : Response(com.cloudant.client.api.model.Response) Test(org.junit.jupiter.api.Test)

Example 70 with Test

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

the class ResponseTest method verifyBulkDocumentRequest.

@Test
public void verifyBulkDocumentRequest() {
    ArrayList<Foo> foos = new ArrayList<Foo>();
    foos.add(new Foo(Utils.generateUUID()));
    foos.add(new Foo(Utils.generateUUID()));
    foos.add(new Foo(Utils.generateUUID()));
    List<Response> responses = db.bulk(foos);
    for (Response response : responses) {
        assertEquals(2, response.getStatusCode() / 100);
    }
}
Also used : Response(com.cloudant.client.api.model.Response) ArrayList(java.util.ArrayList) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)67450 lombok.val (lombok.val)3880 File (java.io.File)2228 HashMap (java.util.HashMap)2180 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2164 ArrayList (java.util.ArrayList)2137 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)2027 SqlSession (org.apache.ibatis.session.SqlSession)1845 List (java.util.List)1799 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)1484 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1184 Map (java.util.Map)1143 IOException (java.io.IOException)1048 Path (java.nio.file.Path)1006 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)935 Date (java.util.Date)914 Method (java.lang.reflect.Method)862 TestBean (org.springframework.beans.testfixture.beans.TestBean)822 Transaction (org.neo4j.graphdb.Transaction)752 BaseDataTest (org.apache.ibatis.BaseDataTest)740