summaryrefslogtreecommitdiffstats
path: root/vespaclient-container-plugin
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-09-30 07:59:22 +0200
committerJon Marius Venstad <venstad@gmail.com>2020-09-30 10:23:35 +0200
commitf6b2e26033e09d220a6f58c42a793a169950cf8c (patch)
tree23a6417863624119b60ff4243a399581e278f5d9 /vespaclient-container-plugin
parent85bffffb34ea959576baeef0affd73ea803fc93a (diff)
Fix tests
Diffstat (limited to 'vespaclient-container-plugin')
-rw-r--r--vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/DocumentOperationExecutorTest.java7
-rw-r--r--vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java10
2 files changed, 10 insertions, 7 deletions
diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/DocumentOperationExecutorTest.java b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/DocumentOperationExecutorTest.java
index 3d67ff93578..30ed5d28fb1 100644
--- a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/DocumentOperationExecutorTest.java
+++ b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/DocumentOperationExecutorTest.java
@@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.TreeMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Phaser;
@@ -142,8 +143,10 @@ public class DocumentOperationExecutorTest {
assertEquals("Your Vespa deployment has no content clusters, so the document API is not enabled", e.getMessage());
}
try {
- DocumentOperationExecutorImpl.resolveCluster(Optional.empty(), Map.of("one", new StorageCluster("one", "one-config", Map.of()),
- "two", new StorageCluster("two", "two-config", Map.of())));
+ Map<String, StorageCluster> twoClusters = new TreeMap<>();
+ twoClusters.put("one", new StorageCluster("one", "one-config", Map.of()));
+ twoClusters.put("two", new StorageCluster("two", "two-config", Map.of()));
+ DocumentOperationExecutorImpl.resolveCluster(Optional.empty(), twoClusters);
fail("More than one cluster and no document type should fail");
}
catch (IllegalArgumentException e) {
diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java
index 82d0a530600..d8e3629a5b0 100644
--- a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java
+++ b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/DocumentV1ApiTest.java
@@ -19,6 +19,7 @@ import com.yahoo.documentapi.local.LocalDocumentAccess;
import com.yahoo.jdisc.Metric;
import com.yahoo.metrics.simple.MetricReceiver;
import com.yahoo.searchdefinition.derived.Deriver;
+import com.yahoo.slime.Inspector;
import com.yahoo.slime.JsonFormat;
import com.yahoo.slime.SlimeUtils;
import com.yahoo.test.ManualClock;
@@ -44,6 +45,7 @@ import static com.yahoo.jdisc.http.HttpRequest.Method.POST;
import static com.yahoo.jdisc.http.HttpRequest.Method.PUT;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
/**
* @author jonmv
@@ -233,11 +235,9 @@ public class DocumentV1ApiTest {
"{" +
" ┻━┻︵ \\(°□°)/ ︵ ┻━┻" +
"}");
- assertSameJson("{" +
- " \"pathId\": \"/document/v1/space/music/number/1/two\"," +
- " \"message\": \"Unexpected character ('┻' (code 9531 / 0x253b)): was expecting double-quote to start field name\\n at [Source: com.yahoo.jdisc.handler.UnsafeContentInputStream@50ecde95; line: 1, column: 7]\"" +
- "}",
- response.readAll());
+ Inspector responseRoot = SlimeUtils.jsonToSlime(response.readAll()).get();
+ assertEquals("/document/v1/space/music/number/1/two", responseRoot.field("pathId").asString());
+ assertTrue(responseRoot.field("message").asString().startsWith("Unexpected character ('┻' (code 9531 / 0x253b)): was expecting double-quote to start field name"));
assertEquals(400, response.getStatus());
// PUT on a unknown document type is a 400