Skip to content
This repository was archived by the owner on Sep 28, 2022. It is now read-only.

Add document:mCreateOrReplace#68

Merged
y-abs merged 20 commits into
3-devfrom
KZL-1350-document-mCreateOrReplace
Mar 13, 2020
Merged

Add document:mCreateOrReplace#68
y-abs merged 20 commits into
3-devfrom
KZL-1350-document-mCreateOrReplace

Conversation

@y-abs
Copy link
Copy Markdown
Contributor

@y-abs y-abs commented Mar 5, 2020

What does this PR do ?

This PR implements the mCreateOrReplace method with its unit tests.

How should this be manually tested?

Clone this branch and run unit tests
./gradlew test

When it succeed, compile it

./gradlew jar

Initiate another java project by adding the compiled SDK as a dependency.

Then, run Kuzzle, create an index nyc-open-data and a yellow-taxi collection in the admin console.
Finally, run this code

import io.kuzzle.sdk.*;
import io.kuzzle.sdk.Options.KuzzleOptions;
import io.kuzzle.sdk.Options.Protocol.WebSocketOptions;
import io.kuzzle.sdk.Protocol.WebSocket;

import java.util.concurrent.ConcurrentHashMap;

public class mCreateOrReplaceDocument {
    private static Kuzzle kuzzle;

    public static void main(String[] args) {
        WebSocketOptions opts = new WebSocketOptions();
        opts.setAutoReconnect(true).setConnectionTimeout(42000);

        try {
            WebSocket ws = new WebSocket("localhost", opts);

            kuzzle = new Kuzzle(ws, (KuzzleOptions) null);

            kuzzle.connect();

            ConcurrentHashMap<String, Object> document1 = new ConcurrentHashMap<>();
            ConcurrentHashMap<String, Object> body1 = new ConcurrentHashMap<>();

            ConcurrentHashMap<String, Object> document2 = new ConcurrentHashMap<>();
            ConcurrentHashMap<String, Object> body2 = new ConcurrentHashMap<>();

            document1.put("_id", "some-id1");
            body1.put("key", "value");
            document1.put("body", body1);

            document2.put("_id", "some-id2");
            body2.put("key", "value");
            document2.put("body", body2);

            ArrayList<ConcurrentHashMap<String, Object>> documents = new ArrayList<>();
            documents.add(document1);
            documents.add(document2);

            ConcurrentHashMap<String, Object> response =
            kuzzle.getDocumentController().mCreateOrReplace("nyc-open-data", "yellow-taxi", documents)
            .get();

            System.out.println(response);
        }  catch (Exception e) {
            e.printStackTrace();
        }

        kuzzle.disconnect();
    }
};

You should see the documents in your collection.

Other changes

Update subscribe documentation -> Remove non existing snippets

@y-abs y-abs self-assigned this Mar 5, 2020
Comment thread doc/3/controllers/realtime/subscribe/index.md Outdated
@y-abs y-abs merged commit 407d0d0 into 3-dev Mar 13, 2020
@y-abs y-abs deleted the KZL-1350-document-mCreateOrReplace branch March 13, 2020 13:53
@jenow jenow mentioned this pull request May 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants