summaryrefslogtreecommitdiffstats
path: root/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java
diff options
context:
space:
mode:
authorJon Marius Venstad <venstad@gmail.com>2020-11-03 17:14:28 +0100
committerJon Marius Venstad <venstad@gmail.com>2020-11-03 17:14:28 +0100
commit7a17516b491c1bb4a248b4cf7d3488fe93eabe34 (patch)
treefc82a314db40d93aa63ef5c46a5443193a43aaef /vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java
parentc3c0c67621ec2ad422e69159fe46698e45e2cac1 (diff)
Remove old /document/v1 handler
Diffstat (limited to 'vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java')
-rw-r--r--vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java82
1 files changed, 0 insertions, 82 deletions
diff --git a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java b/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java
deleted file mode 100644
index eb6bb609970..00000000000
--- a/vespaclient-container-plugin/src/test/java/com/yahoo/document/restapi/resource/MockedOperationHandler.java
+++ /dev/null
@@ -1,82 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.document.restapi.resource;
-
-import com.yahoo.document.restapi.OperationHandler;
-import com.yahoo.document.restapi.Response;
-import com.yahoo.document.restapi.RestApiException;
-import com.yahoo.document.restapi.RestUri;
-import com.yahoo.vespaxmlparser.FeedOperation;
-
-import java.util.Optional;
-
-/**
- * Mock that collects info about operation and returns them on second delete.
- */
-public class MockedOperationHandler implements OperationHandler {
-
- StringBuilder log = new StringBuilder();
- int deleteCount = 0;
-
- @Override
- public VisitResult visit(RestUri restUri, String documentSelection, VisitOptions options) throws RestApiException {
- return new VisitResult(Optional.of("token"), "List of json docs, cont token "
- + options.continuation.orElse("not set") + ", doc selection: '"
- + documentSelection + "'"
- + options.wantedDocumentCount.map(n -> String.format(", min docs returned: %d", n)).orElse("")
- + options.fieldSet.map(s -> String.format(", field set: '%s'", s)).orElse("")
- + options.concurrency.map(n -> String.format(", concurrency: %d", n)).orElse("")
- + options.bucketSpace.map(s -> String.format(", bucket space: '%s'", s)).orElse("")
- + options.cluster.map(s -> String.format(", cluster: '%s'", s)).orElse(""));
- }
-
- @Override
- @SuppressWarnings("deprecation")
- public void put(RestUri restUri, FeedOperation data, Optional<String> route) throws RestApiException {
- log.append("PUT: " + data.getDocument().getId());
- log.append(data.getDocument().getHeader().toString());
- }
-
- @Override
- public void update(RestUri restUri, FeedOperation data, Optional<String> route) throws RestApiException {
- log.append("UPDATE: " + data.getDocumentUpdate().getId());
- log.append(data.getDocumentUpdate().fieldUpdates().toString());
- if (data.getDocumentUpdate().getCreateIfNonExistent()) {
- log.append("[CREATE IF NON EXISTENT IS TRUE]");
- }
- }
-
- @Override
- public void delete(RestUri restUri, String condition, Optional<String> route) throws RestApiException {
- deleteCount++;
- if (deleteCount == 2) {
- String theLog = log.toString();
- log = new StringBuilder();
- deleteCount = 0;
- throw new RestApiException(Response.createErrorResponse(666, theLog, RestUri.apiErrorCodes.ERROR_ID_BASIC_USAGE));
- }
- log.append("DELETE: " + restUri.generateFullId());
- }
-
- @Override
- public Optional<String> get(RestUri restUri, Optional<String> fieldSet, Optional<String> cluster) throws RestApiException {
- log.append("GET: " + restUri.generateFullId());
- // This is _not_ an elegant way to return data back to the test.
- // An alternative is removing this entire class in favor of explicit mock expectations.
- if (!fieldSet.isPresent() && !cluster.isPresent()) {
- return Optional.empty();
- }
- return Optional.of(String.format("{\"fields\": {\"fieldset\": \"%s\",\"cluster\":\"%s\"}}",
- fieldSet.orElse(""), cluster.orElse("")));
- }
-
- @Override
- public Optional<String> get(RestUri restUri, Optional<String> fieldSet) throws RestApiException {
- return get(restUri, fieldSet, Optional.empty());
- }
-
- @Override
- public Optional<String> get(RestUri restUri) throws RestApiException {
- return get(restUri, Optional.empty());
- }
-
-}