summaryrefslogtreecommitdiffstats
path: root/src/test/java/org/onap/aai/sa/rest/StubEsController.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/onap/aai/sa/rest/StubEsController.java')
-rw-r--r--src/test/java/org/onap/aai/sa/rest/StubEsController.java61
1 files changed, 37 insertions, 24 deletions
diff --git a/src/test/java/org/onap/aai/sa/rest/StubEsController.java b/src/test/java/org/onap/aai/sa/rest/StubEsController.java
index c792391..fe72090 100644
--- a/src/test/java/org/onap/aai/sa/rest/StubEsController.java
+++ b/src/test/java/org/onap/aai/sa/rest/StubEsController.java
@@ -35,8 +35,9 @@ import java.util.HashMap;
import java.util.Map;
/**
- * This class implements a stubbed version of the document store DAO so that we can run unit tests
- * without trying to connect to a real document store.
+ * This class implements a stubbed version of the document store DAO so
+ * that we can run unit tests without trying to connect to a real
+ * document store.
*/
public class StubEsController implements DocumentStoreInterface {
@@ -47,7 +48,7 @@ public class StubEsController implements DocumentStoreInterface {
/**
*
*/
- // private IndexAPIHarness indexAPIHarness;
+ //private IndexAPIHarness indexAPIHarness;
StubEsController() {
analysisConfig = new AnalysisConfiguration();
@@ -55,8 +56,10 @@ public class StubEsController implements DocumentStoreInterface {
"src/test/resources/json/analysis-config.json");
}
+
@Override
- public OperationResult createIndex(String index, DocumentSchema documentSchema) {
+ public OperationResult createIndex(String index,
+ DocumentSchema documentSchema) {
// Just return an OK result, with the parameters that we were passed
// bundled in the response string. This allows unit tests to validate
@@ -74,12 +77,12 @@ public class StubEsController implements DocumentStoreInterface {
public OperationResult createDynamicIndex(String index, String dynamicSchema) {
OperationResult opResult = new OperationResult();
opResult.setResultCode(200);
- // Directly return the json as this flow should not edit the json in any
- // way
+ // Directly return the json as this flow should not edit the json in any way
opResult.setResult(dynamicSchema);
return opResult;
}
+
@Override
public OperationResult deleteIndex(String indexName) throws DocumentStoreOperationException {
@@ -96,9 +99,11 @@ public class StubEsController implements DocumentStoreInterface {
}
@Override
- public DocumentOperationResult createDocument(String indexName, DocumentStoreDataEntity document,
- boolean allowImplicitIndexCreation) throws DocumentStoreOperationException {
-
+ public DocumentOperationResult createDocument(String indexName,
+ DocumentStoreDataEntity document,
+ boolean allowImplicitIndexCreation)
+ throws DocumentStoreOperationException {
+
DocumentOperationResult opResult = buildSampleDocumentOperationResult();
if (indexName.equals(DOES_NOT_EXIST_INDEX)) {
@@ -116,9 +121,11 @@ public class StubEsController implements DocumentStoreInterface {
}
@Override
- public DocumentOperationResult updateDocument(String indexName, DocumentStoreDataEntity document,
- boolean allowImplicitIndexCreation) throws DocumentStoreOperationException {
-
+ public DocumentOperationResult updateDocument(String indexName,
+ DocumentStoreDataEntity document,
+ boolean allowImplicitIndexCreation)
+ throws DocumentStoreOperationException {
+
DocumentOperationResult opResult = buildSampleDocumentOperationResult();
if (indexName.equals(DOES_NOT_EXIST_INDEX)) {
@@ -136,41 +143,48 @@ public class StubEsController implements DocumentStoreInterface {
}
@Override
- public DocumentOperationResult deleteDocument(String indexName, DocumentStoreDataEntity document)
- throws DocumentStoreOperationException {
+ public DocumentOperationResult deleteDocument(String indexName,
+ DocumentStoreDataEntity document) throws DocumentStoreOperationException {
DocumentOperationResult opResult = buildSampleDocumentOperationResult();
+
if (indexName.equals(DOES_NOT_EXIST_INDEX)) {
opResult.setResultCode(404);
} else {
if (opResult.getDocument() != null) {
opResult.getDocument().setEtag(null);
opResult.getDocument().setUrl(null);
+ opResult.setResultVersion("1");
}
opResult.setResultCode(200);
opResult.setResult(indexName + "@" + document.getId());
+ opResult.setResultVersion("1");
}
return opResult;
}
@Override
- public DocumentOperationResult getDocument(String indexName, DocumentStoreDataEntity document)
- throws DocumentStoreOperationException {
+ public DocumentOperationResult getDocument(String indexName,
+ DocumentStoreDataEntity document) throws DocumentStoreOperationException {
DocumentOperationResult opResult = buildSampleDocumentOperationResult();
if (indexName.equals(DOES_NOT_EXIST_INDEX)) {
opResult.setResultCode(404);
+ // Adding it to make the tests pass.
+ opResult.setResultVersion ("1");
} else {
opResult.setResultCode(200);
+ // Adding it to make the tests pass.
+ opResult.setResultVersion ("1");
}
return opResult;
}
@Override
- public SearchOperationResult search(String indexName, String queryText)
- throws DocumentStoreOperationException {
+ public SearchOperationResult search(String indexName,
+ String queryText) throws DocumentStoreOperationException {
SearchOperationResult opResult = buildSampleSearchOperationResult();
@@ -185,8 +199,8 @@ public class StubEsController implements DocumentStoreInterface {
}
@Override
- public SearchOperationResult searchWithPayload(String indexName, String query)
- throws DocumentStoreOperationException {
+ public SearchOperationResult searchWithPayload(String indexName,
+ String query) throws DocumentStoreOperationException {
SearchOperationResult opResult = buildSampleSearchOperationResult();
if (indexName.equals(DOES_NOT_EXIST_INDEX)) {
@@ -201,7 +215,7 @@ public class StubEsController implements DocumentStoreInterface {
@Override
public SearchOperationResult suggestionQueryWithPayload(String indexName, String query)
- throws DocumentStoreOperationException {
+ throws DocumentStoreOperationException {
SearchOperationResult opResult = new SearchOperationResult();
if (indexName.equals(DOES_NOT_EXIST_INDEX)) {
@@ -215,8 +229,7 @@ public class StubEsController implements DocumentStoreInterface {
}
@Override
- public OperationResult performBulkOperations(BulkRequest[] requests)
- throws DocumentStoreOperationException {
+ public OperationResult performBulkOperations(BulkRequest[] requests) throws DocumentStoreOperationException {
OperationResult opResult = new OperationResult();
opResult.setResultCode(200);
@@ -256,4 +269,4 @@ public class StubEsController implements DocumentStoreInterface {
}
-}
+} \ No newline at end of file