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

Add document:replace#62

Merged
y-abs merged 12 commits into
3-devfrom
KZL-1350-document-replace
Mar 2, 2020
Merged

Add document:replace#62
y-abs merged 12 commits into
3-devfrom
KZL-1350-document-replace

Conversation

@y-abs
Copy link
Copy Markdown
Contributor

@y-abs y-abs commented Feb 21, 2020

What does this PR do ?

This PR implements the document:replace 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. Create a document with id some-id
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 replaceDocument {
    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> content = new ConcurrentHashMap<>();
            content.put("name", "Yoann");

            kuzzle.getDocumentController().replace("nyc-open-data", "yellow-taxi", "some-id", content)
            .get();
            System.out.println("New document added to the yellow-taxi collection!");
        }  catch (Exception e) {
            e.printStackTrace();
        }

        kuzzle.disconnect();
    }
};

You should see the replaced document in your collection.

@y-abs y-abs self-assigned this Feb 21, 2020
Copy link
Copy Markdown
Contributor

@scottinet scottinet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also report changes requested in #55, #59 and #61

@y-abs y-abs requested a review from scottinet February 26, 2020 16:28
Comment thread doc/3/controllers/document/replace/index.md Outdated
Comment thread doc/3/controllers/document/replace/index.md Outdated

ConcurrentHashMap<String, Object> response = kuzzle.getDocumentController().replace("nyc-open-data", "yellow-taxi", "some-id", document)
.get();
System.out.println(response); No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the result of the println in comment?
It helps developer to better apprehend the structure of the response object they have. We try to do this for every method (Look the Javascript SDK and Doc)

y-abs and others added 3 commits February 27, 2020 10:14
Co-Authored-By: Adrien Maret <amaret93@gmail.com>
Co-Authored-By: Adrien Maret <amaret93@gmail.com>
@y-abs y-abs requested a review from Aschen February 28, 2020 14:13
Copy link
Copy Markdown
Contributor

@Aschen Aschen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you change the method description and use the same wording as for the JS SDK ?
This remark apply for all your current PR on the SDK

@y-abs y-abs merged commit b00e7c6 into 3-dev Mar 2, 2020
@y-abs y-abs deleted the KZL-1350-document-replace branch March 2, 2020 12:08
@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.

4 participants