aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorrv871f <richard.vondadelszen@amdocs.com>2018-03-16 11:59:32 -0400
committerrv871f <richard.vondadelszen@amdocs.com>2018-03-16 12:02:30 -0400
commit1d1fbefced829fed4f3d6bb4123f9df8c9cb8d3c (patch)
tree1504fc245a6a7518be0f27a51431091fc3582b14 /src/test
parentd6348739c632fb69c8833078effbb902adc7f702 (diff)
Adding pass through shema creation
Issue-ID: AAI-888 Change-Id: Ifc094758682b39a5f2c5607bccd418de6e36d841 Signed-off-by: rv871f <richard.vondadelszen@amdocs.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/aai/sa/rest/IndexApiTest.java19
-rw-r--r--src/test/java/org/onap/aai/sa/rest/SearchServiceApiHarness.java12
-rw-r--r--src/test/java/org/onap/aai/sa/rest/StubEsController.java8
-rw-r--r--src/test/resources/json/dynamicIndex.json15
4 files changed, 53 insertions, 1 deletions
diff --git a/src/test/java/org/onap/aai/sa/rest/IndexApiTest.java b/src/test/java/org/onap/aai/sa/rest/IndexApiTest.java
index 6292cbe..f63ddbd 100644
--- a/src/test/java/org/onap/aai/sa/rest/IndexApiTest.java
+++ b/src/test/java/org/onap/aai/sa/rest/IndexApiTest.java
@@ -45,7 +45,7 @@ public class IndexApiTest extends JerseyTest {
private final String TOP_URI = "/test/indexes/";
private final String SIMPLE_DOC_SCHEMA_JSON = "src/test/resources/json/simpleDocument.json";
-
+ private final String DYNAMIC_INDEX_PAYLOAD = "src/test/resources/json/dynamicIndex.json";
@Override
protected Application configure() {
@@ -166,6 +166,23 @@ public class IndexApiTest extends JerseyTest {
tokenizedResult[2].equals(EXPECTED_MAPPINGS));
}
+ /**
+ * Tests the dynamic shcema creation flow that send the request
+ * JSON to the data store without any JSON validation against a schema
+ *
+ * @throws IOException
+ */
+ @Test
+ public void createDynamicIndexTest() throws IOException {
+ String indexName = "super-ultra-dynamic-mega-index";
+ String dynamicUri = TOP_URI + "dynamic/";
+ File indexFile = new File(DYNAMIC_INDEX_PAYLOAD);
+ String indexPayload = TestUtils.readFileToString(indexFile);
+
+ String result = target(dynamicUri + indexName).request().put(Entity.json(indexPayload), String.class);
+
+ assertEquals(indexPayload, result);
+ }
/**
* This test validates that a 'create index' request with an improperly
diff --git a/src/test/java/org/onap/aai/sa/rest/SearchServiceApiHarness.java b/src/test/java/org/onap/aai/sa/rest/SearchServiceApiHarness.java
index 80c058d..b15ccc8 100644
--- a/src/test/java/org/onap/aai/sa/rest/SearchServiceApiHarness.java
+++ b/src/test/java/org/onap/aai/sa/rest/SearchServiceApiHarness.java
@@ -63,6 +63,18 @@ public class SearchServiceApiHarness extends SearchServiceApi {
return super.processCreateIndex(requestBody, request, headers, index);
}
+ @PUT
+ @Path("/indexes/dynamic/{index}")
+ @Consumes({MediaType.APPLICATION_JSON})
+ @Override
+ public Response processCreateDynamicIndex(String requestBody,
+ @Context HttpServletRequest request,
+ @Context HttpHeaders headers,
+ @PathParam("index") String index) {
+
+ return super.processCreateDynamicIndex(requestBody, request, headers, index);
+ }
+
@DELETE
@Path("/indexes/{index}")
@Consumes({MediaType.APPLICATION_JSON})
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 326d03a..d5d77ab 100644
--- a/src/test/java/org/onap/aai/sa/rest/StubEsController.java
+++ b/src/test/java/org/onap/aai/sa/rest/StubEsController.java
@@ -73,6 +73,14 @@ public class StubEsController implements DocumentStoreInterface {
return opResult;
}
+ @Override
+ 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
+ opResult.setResult(dynamicSchema);
+ return opResult;
+ }
@Override
public OperationResult deleteIndex(String indexName) throws DocumentStoreOperationException {
diff --git a/src/test/resources/json/dynamicIndex.json b/src/test/resources/json/dynamicIndex.json
new file mode 100644
index 0000000..1ac1cce
--- /dev/null
+++ b/src/test/resources/json/dynamicIndex.json
@@ -0,0 +1,15 @@
+{
+ "mappings": {
+ "dynamic_templates": [{
+ "strings": {
+ "match_mapping_type": "string",
+ "match": "*",
+ "mapping": {
+ "type": "string",
+ "index": "not_analyzed"
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file