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

Add collection:updateSpecifications#85

Merged
scottinet merged 12 commits into
3-devfrom
KZL-1462-collection-updateSpecifications
Apr 9, 2020
Merged

Add collection:updateSpecifications#85
scottinet merged 12 commits into
3-devfrom
KZL-1462-collection-updateSpecifications

Conversation

@y-abs
Copy link
Copy Markdown
Contributor

@y-abs y-abs commented Apr 2, 2020

What does this PR do ?

This PR implements the collection:updateSpecifications 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, a yellow-taxi collection
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 updateSpecificationsCollection {
    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> specifications = new ConcurrentHashMap<>();
            ConcurrentHashMap<String, Object> fields = new ConcurrentHashMap<>();
            ConcurrentHashMap<String, Object> license = new ConcurrentHashMap<>();

            specifications.put("strict", false);
            license.put("mandatory", true);
            license.put("type", "string");
            fields.put("license", license);
            specifications.put("fields", fields);

            ConcurrentHashMap<String, Object> result = 
            kuzzle.getCollectionController().updateSpecifications("nyc-open-data", "yellow-taxi",  
            specifications).get();
           
        }  catch (Exception e) {
            e.printStackTrace();
        }

        kuzzle.disconnect();
    }
};

@y-abs y-abs self-assigned this Apr 2, 2020

It must follow the [Specification Structure](/core/2/guides/essentials/data-validation):

```java
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.

The content of this example doesn't appear to be written in java.

Given that there is already a code snippet in java, and JSON examples in the link you put a few lines back, then I think that this example should be removed.

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.

I think it's the output of a println on the HashMap but still I agree with @scottinet, you should keep the JSON

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.

After @scottinet comment and this nitpicking, 👍

@y-abs y-abs requested a review from scottinet April 8, 2020 12:41
@scottinet scottinet merged commit abf202f into 3-dev Apr 9, 2020
@scottinet scottinet deleted the KZL-1462-collection-updateSpecifications branch April 9, 2020 11:13
@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