diff options
Diffstat (limited to 'src/test/java')
3 files changed, 38 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 { |