diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2021-06-23 19:07:46 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2021-06-23 19:07:46 +0200 |
commit | c9770112336d353dc5e69357ffbd0f830d08068e (patch) | |
tree | 2a476842751511ded7b1702efb4264a6631697f6 /vespa-feed-client/src/test/java | |
parent | f8b5458406a0bc6f9d39afcfa61d266823ec46fd (diff) |
Support concatenated JSON objects as feed format
Diffstat (limited to 'vespa-feed-client/src/test/java')
-rw-r--r-- | vespa-feed-client/src/test/java/ai/vespa/feed/client/JsonFeederTest.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/vespa-feed-client/src/test/java/ai/vespa/feed/client/JsonFeederTest.java b/vespa-feed-client/src/test/java/ai/vespa/feed/client/JsonFeederTest.java index 3e0f886a40a..6c26e1d8ae8 100644 --- a/vespa-feed-client/src/test/java/ai/vespa/feed/client/JsonFeederTest.java +++ b/vespa-feed-client/src/test/java/ai/vespa/feed/client/JsonFeederTest.java @@ -3,11 +3,13 @@ package ai.vespa.feed.client; import org.junit.jupiter.api.Test; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.StandardOpenOption; +import java.util.Arrays; import java.util.HashSet; import java.util.Set; import java.util.concurrent.CompletableFuture; @@ -77,6 +79,48 @@ class JsonFeederTest { } @Test + public void multipleJsonArrayOperationsAreDispatchedToFeedClient() throws IOException, ExecutionException, InterruptedException { + SimpleClient client = new SimpleClient(); + try (JsonFeeder feeder = JsonFeeder.builder(client).build()) { + String json = "[{" + + " \"put\": \"id:ns:type::abc1\",\n" + + " \"fields\": {\n" + + " \"lul\":\"lal\"\n" + + " }\n" + + "},\n" + + "{" + + " \"put\": \"id:ns:type::abc2\",\n" + + " \"fields\": {\n" + + " \"lul\":\"lal\"\n" + + " }\n" + + "}]\n"; + feeder.feedMany(new ByteArrayInputStream(json.getBytes(UTF_8))).get(); + assertEquals(new HashSet<>(Arrays.asList("abc1", "abc2")), client.ids); + } + } + + @Test + public void multipleJsonLOperationsAreDispatchedToFeedClient() throws IOException, ExecutionException, InterruptedException { + SimpleClient client = new SimpleClient(); + try (JsonFeeder feeder = JsonFeeder.builder(client).build()) { + String json = "{" + + " \"put\": \"id:ns:type::abc1\",\n" + + " \"fields\": {\n" + + " \"lul\":\"lal\"\n" + + " }\n" + + "}\n" + + "{" + + " \"put\": \"id:ns:type::abc2\",\n" + + " \"fields\": {\n" + + " \"lul\":\"lal\"\n" + + " }\n" + + "}\n"; + feeder.feedMany(new ByteArrayInputStream(json.getBytes(UTF_8))).get(); + assertEquals(new HashSet<>(Arrays.asList("abc1", "abc2")), client.ids); + } + } + + @Test public void singleJsonOperationIsDispatchedToFeedClient() throws IOException, ExecutionException, InterruptedException { try (JsonFeeder feeder = JsonFeeder.builder(new SimpleClient()).build()) { String json = "{\"put\": \"id:ns:type::abc1\",\n" + |