Add unit tests to increase sonar coverage 69/27669/1
authoraditya <ag282f@att.com>
Mon, 8 Jan 2018 21:41:05 +0000 (15:41 -0600)
committeraditya <ag282f@att.com>
Mon, 8 Jan 2018 21:46:25 +0000 (15:46 -0600)
Add unit tests to auth, rest and searchdbabstraction.
Add search_policy.json to src/test/resources to support junits.

Issue-ID: AAI-608

Change-Id: I295623d1735136bf4723d87ab4df21f8c124a414
Signed-off-by: Aditya Gajulapalli <ag282f@att.com>
src/test/java/org/onap/aai/sa/auth/SearchDbServiceAuthTest.java [new file with mode: 0644]
src/test/java/org/onap/aai/sa/rest/BulkRequestTest.java [new file with mode: 0644]
src/test/java/org/onap/aai/sa/rest/DocumentTest.java [new file with mode: 0644]
src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/config/ElasticSearchConfigTest.java [new file with mode: 0644]
src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchResultItemTest.java [new file with mode: 0644]
src/test/java/org/onap/aai/sa/searchdbabstraction/searchapi/RangeQueryTest.java [new file with mode: 0644]
src/test/java/org/onap/aai/sa/searchdbabstraction/searchapi/TermQueryTest.java [new file with mode: 0644]
src/test/resources/json/search_policy.json [new file with mode: 0644]

diff --git a/src/test/java/org/onap/aai/sa/auth/SearchDbServiceAuthTest.java b/src/test/java/org/onap/aai/sa/auth/SearchDbServiceAuthTest.java
new file mode 100644 (file)
index 0000000..acbbae5
--- /dev/null
@@ -0,0 +1,86 @@
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *       http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ */\r
+package org.onap.aai.sa.auth;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.Mock;\r
+import org.mockito.MockitoAnnotations;\r
+import org.onap.aai.sa.searchdbabstraction.util.SearchDbConstants;\r
+\r
+import javax.ws.rs.core.Cookie;\r
+import javax.ws.rs.core.HttpHeaders;\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.lang.reflect.Field;\r
+import java.lang.reflect.Modifier;\r
+\r
+public class SearchDbServiceAuthTest {\r
+\r
+    @Mock\r
+    HttpHeaders headers;\r
+\r
+    @Mock\r
+    Cookie mockedCookie;\r
+\r
+    @Before\r
+    public void setUp() throws NoSuchFieldException, IllegalAccessException, IOException {\r
+        MockitoAnnotations.initMocks(this);\r
+        System.setProperty("AJSC_HOME", new File(".").getCanonicalPath().replace('\\', '/'));\r
+        setFinalStatic(System.getProperty("AJSC_HOME")+"/src/test/resources/json/search_policy.json");\r
+    }\r
+\r
+    @Test\r
+    public void testAuthUser(){\r
+        SearchDbServiceAuth aaiAuth = new SearchDbServiceAuth();\r
+        String auth = aaiAuth.authUser(headers, "user-1", "function-1");\r
+        Assert.assertEquals(auth, "AAI_9101");\r
+    }\r
+\r
+    @Test\r
+    public void testAuthCookie_NullCookie(){\r
+        SearchDbServiceAuth aaiAuth = new SearchDbServiceAuth();\r
+        Cookie cookie = null;\r
+        Assert.assertFalse(aaiAuth.authCookie(cookie, "function-1", new StringBuilder("user-1")));\r
+    }\r
+\r
+    @Test\r
+    public void testAuthCookie_NotNullCookie(){\r
+        SearchDbServiceAuth aaiAuth = new SearchDbServiceAuth();\r
+        boolean retValue = aaiAuth.authCookie(mockedCookie, "GET:testFunction", new StringBuilder("testuser"));\r
+        Assert.assertTrue(retValue);\r
+    }\r
+\r
+    static void setFinalStatic(String fieldValue) throws NoSuchFieldException, SecurityException,\r
+            IllegalArgumentException, IllegalAccessException {\r
+        Field configField = SearchDbConstants.class.getDeclaredField("SDB_AUTH_CONFIG_FILENAME");\r
+        configField.setAccessible(true);\r
+\r
+        Field modifiersField = Field.class.getDeclaredField( "modifiers" );\r
+        modifiersField.setAccessible( true );\r
+        modifiersField.setInt( configField, configField.getModifiers() & ~Modifier.FINAL );\r
+\r
+        configField.set(null, fieldValue);\r
+    }\r
+}\r
diff --git a/src/test/java/org/onap/aai/sa/rest/BulkRequestTest.java b/src/test/java/org/onap/aai/sa/rest/BulkRequestTest.java
new file mode 100644 (file)
index 0000000..ae8f619
--- /dev/null
@@ -0,0 +1,143 @@
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *       http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ */\r
+package org.onap.aai.sa.rest;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+\r
+public class BulkRequestTest {\r
+\r
+    @Test\r
+    public void testBulkRequest_Delete(){\r
+        BulkRequest request = new BulkRequest();\r
+        BulkOperation operation = new BulkOperation();\r
+        Document document = new Document();\r
+        BulkMetaData metaData = getMetaData();\r
+        operation.setMetaData(metaData);\r
+        operation.setDocument(document);\r
+        Assert.assertNotNull(operation.getDocument());\r
+        Assert.assertNotNull(operation.getMetaData());\r
+        Assert.assertNotNull(operation.toString());\r
+\r
+        request.setDelete(operation);\r
+        Assert.assertNotNull(request.getDelete());\r
+        Assert.assertEquals(operation, request.getOperation());\r
+        Assert.assertEquals(BulkRequest.OperationType.DELETE, request.getOperationType());\r
+        Assert.assertTrue(request.toString().contains("delete:"));\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testBulkRequest_Update(){\r
+        BulkRequest request = new BulkRequest();\r
+        BulkOperation operation = new BulkOperation();\r
+        Document document = new Document();\r
+        BulkMetaData metaData = getMetaData();\r
+        operation.setMetaData(metaData);\r
+        operation.setDocument(document);\r
+        Assert.assertNotNull(operation.getDocument());\r
+        Assert.assertNotNull(operation.getMetaData());\r
+        Assert.assertNotNull(operation.toString());\r
+\r
+        request.setUpdate(operation);\r
+        Assert.assertNotNull(request.getUpdate());\r
+        Assert.assertEquals(operation, request.getOperation());\r
+        Assert.assertEquals(BulkRequest.OperationType.UPDATE, request.getOperationType());\r
+        Assert.assertTrue(request.toString().contains("update:"));\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testBulkRequest_Create(){\r
+        BulkRequest request = new BulkRequest();\r
+        BulkOperation operation = new BulkOperation();\r
+        Document document = new Document();\r
+        BulkMetaData metaData = getMetaData();\r
+        operation.setMetaData(metaData);\r
+        operation.setDocument(document);\r
+        Assert.assertNotNull(operation.getDocument());\r
+        Assert.assertNotNull(operation.getMetaData());\r
+        Assert.assertNotNull(operation.toString());\r
+\r
+        request.setCreate(operation);\r
+        Assert.assertNotNull(request.getCreate());\r
+        Assert.assertEquals(operation, request.getOperation());\r
+        Assert.assertEquals(BulkRequest.OperationType.CREATE, request.getOperationType());\r
+        Assert.assertTrue(request.toString().contains("create:"));\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testBulkRequest_Undefined(){\r
+        BulkRequest request = new BulkRequest();\r
+        Assert.assertNull(request.getOperation());\r
+        Assert.assertNull(request.getOperationType());\r
+        Assert.assertEquals("UNDEFINED", request.toString());\r
+    }\r
+    @Test\r
+    public void testGetIndex(){\r
+        BulkRequest request = new BulkRequest();\r
+        BulkOperation operation = new BulkOperation();\r
+        BulkMetaData metaData = new BulkMetaData();\r
+        metaData.setUrl("/test/indexes/index1");\r
+        operation.setMetaData(metaData);\r
+        request.setCreate(operation);\r
+        String index = request.getIndex();\r
+        Assert.assertEquals(index, "index1");\r
+    }\r
+\r
+    @Test\r
+    public void testGetId(){\r
+        BulkRequest request = new BulkRequest();\r
+        BulkOperation operation = new BulkOperation();\r
+        BulkMetaData metaData = new BulkMetaData();\r
+        metaData.setUrl("/test/documents/document1");\r
+        operation.setMetaData(metaData);\r
+        request.setCreate(operation);\r
+        String index = request.getId();\r
+        Assert.assertEquals(index, "document1");\r
+    }\r
+\r
+    @Test\r
+    public void testApiUtils(){\r
+        Assert.assertEquals("services/search-data-service/v1/search/indexes/index1",\r
+                ApiUtils.buildIndexUri("index1"));\r
+        Assert.assertEquals("services/search-data-service/v1/search/indexes/index1/documents/document1",\r
+                ApiUtils.buildDocumentUri("index1", "document1"));\r
+        Assert.assertTrue(ApiUtils.validateIndexUri("services/search-data-service/v1/search/indexes/index1"));\r
+        Assert.assertTrue(ApiUtils.validateDocumentUri\r
+                ("services/search-data-service/v1/search/indexes/index1/documents/document1", true));\r
+        Assert.assertTrue(ApiUtils.validateDocumentUri\r
+                ("services/search-data-service/v1/search/indexes/index1/documents/document1", false));\r
+    }\r
+\r
+    private BulkMetaData getMetaData() {\r
+        BulkMetaData metaData = new BulkMetaData();\r
+        metaData.setUrl("http://127.0.0.1");\r
+        metaData.setEtag("etag-1");\r
+        Assert.assertEquals(metaData.getUrl(), "http://127.0.0.1");\r
+        Assert.assertEquals(metaData.getEtag(), "etag-1");\r
+        Assert.assertNotNull(metaData.toString());\r
+        return metaData;\r
+    }\r
+}\r
diff --git a/src/test/java/org/onap/aai/sa/rest/DocumentTest.java b/src/test/java/org/onap/aai/sa/rest/DocumentTest.java
new file mode 100644 (file)
index 0000000..2f502f9
--- /dev/null
@@ -0,0 +1,644 @@
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *       http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ */\r
+package org.onap.aai.sa.rest;\r
+\r
+import com.fasterxml.jackson.core.JsonProcessingException;\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+import org.mockito.InjectMocks;\r
+import org.mockito.Mock;\r
+import org.mockito.Mockito;\r
+import org.mockito.MockitoAnnotations;\r
+import org.onap.aai.sa.searchdbabstraction.elasticsearch.dao.DocumentStoreDataEntity;\r
+import org.onap.aai.sa.searchdbabstraction.elasticsearch.dao.DocumentStoreInterface;\r
+import org.onap.aai.sa.searchdbabstraction.elasticsearch.exception.DocumentStoreOperationException;\r
+import org.onap.aai.sa.searchdbabstraction.entity.DocumentOperationResult;\r
+import org.onap.aai.sa.searchdbabstraction.entity.ErrorResult;\r
+import org.onap.aai.sa.searchdbabstraction.entity.SearchHits;\r
+import org.onap.aai.sa.searchdbabstraction.entity.SearchOperationResult;\r
+\r
+import javax.servlet.http.HttpServletRequest;\r
+import javax.servlet.http.HttpServletResponse;\r
+import javax.ws.rs.core.HttpHeaders;\r
+import javax.ws.rs.core.MultivaluedMap;\r
+import javax.ws.rs.core.Response;\r
+\r
+public class DocumentTest {\r
+\r
+    @Mock\r
+    SearchServiceApi searchServiceApi;\r
+\r
+    @Mock\r
+    HttpServletRequest request;\r
+\r
+    @Mock\r
+    HttpHeaders headers;\r
+\r
+    @Mock\r
+    HttpServletResponse httpResponse;\r
+\r
+    @Mock\r
+    DocumentStoreInterface documentStore;\r
+\r
+    @Mock\r
+    MultivaluedMap<String, String> multivaluedMap;\r
+\r
+    @InjectMocks\r
+    IndexApi indexApi;\r
+\r
+    DocumentApi documentApi;\r
+\r
+    @Before\r
+    public void setUp(){\r
+        MockitoAnnotations.initMocks(this);\r
+        documentApi = new DocumentApi(searchServiceApi);\r
+    }\r
+\r
+    @Test\r
+    public void testDocumentClass_AllMethods() throws JsonProcessingException {\r
+        Document doc = new Document();\r
+        doc.setField("name-1", "value-1");\r
+        Assert.assertTrue(doc.getFields().size()==1);\r
+        Assert.assertTrue(doc.toJson().contains("value-1"));\r
+        Assert.assertNotNull(doc.toString());\r
+        Assert.assertTrue(doc.toString().contains("name-1"));\r
+    }\r
+\r
+    @Test\r
+    public void testProcessPost_NullContent(){\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = null;\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Response response = documentApi.processPost(content, request, headers, httpResponse, "index",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.BAD_REQUEST.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessPost_NotNullContent() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenThrow(IllegalArgumentException.class);\r
+        Response response = documentApi.processPost(content, request, headers, httpResponse, "index",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessPost_ValidRequest() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        DocumentOperationResult result = new DocumentOperationResult();\r
+        result.setResultCode(150);\r
+        result.setError(new ErrorResult("type-1", "reason-1"));\r
+        result.setFailureCause("test-failure");\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(true);\r
+        Mockito.when(documentStore.createDocument(Mockito.anyString(), Mockito.any(DocumentStoreDataEntity.class),\r
+                Mockito.anyBoolean())).thenReturn(result);\r
+        Mockito.doNothing().when(httpResponse).setHeader(Mockito.anyString(), Mockito.anyString());\r
+        Response response = documentApi.processPost(content, request, headers, httpResponse, "index",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessSearchWithGet_Created() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        SearchOperationResult result = new SearchOperationResult();\r
+        result.setResultCode(201);\r
+        SearchHits hits = new SearchHits();\r
+        hits.setTotalHits("2");\r
+        result.setSearchResult(hits);\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(true);\r
+        Mockito.when(documentStore.search(Mockito.anyString(), Mockito.anyString())).thenReturn(result);\r
+        Response response = documentApi.processSearchWithGet(content, request, headers, "index-1",\r
+                "query-text", documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.CREATED.getStatusCode() == response.getStatus());\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testProcessSearchWithGet_ValidateThrowsException() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        SearchOperationResult result = new SearchOperationResult();\r
+        result.setResultCode(201);\r
+        SearchHits hits = new SearchHits();\r
+        hits.setTotalHits("2");\r
+        result.setSearchResult(hits);\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenThrow(IllegalArgumentException.class);\r
+        Mockito.when(documentStore.search(Mockito.anyString(), Mockito.anyString())).thenReturn(result);\r
+        Response response = documentApi.processSearchWithGet(content, request, headers, "index-1",\r
+                "query-text", documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testProcessSearchWithGet_ValidateIsFalse() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        SearchOperationResult result = new SearchOperationResult();\r
+        result.setResultCode(201);\r
+        SearchHits hits = new SearchHits();\r
+        hits.setTotalHits("2");\r
+        result.setSearchResult(hits);\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(false);\r
+        Mockito.when(documentStore.search(Mockito.anyString(), Mockito.anyString())).thenReturn(result);\r
+        Response response = documentApi.processSearchWithGet(content, request, headers, "index-1",\r
+                "query-text", documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testProcessSearchWithGet_InvalidResult() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        SearchOperationResult result = new SearchOperationResult();\r
+        result.setResultCode(302);\r
+        SearchHits hits = new SearchHits();\r
+        hits.setTotalHits("2");\r
+        result.setSearchResult(hits);\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(true);\r
+        Mockito.when(documentStore.search(Mockito.anyString(), Mockito.anyString())).thenReturn(result);\r
+        Response response = documentApi.processSearchWithGet(content, request, headers, "index-1",\r
+                "query-text", documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FOUND.getStatusCode() == response.getStatus());\r
+\r
+    }\r
+\r
+    @Test\r
+    public void testProcessPut_NullContent(){\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = null;\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Response response = documentApi.processPut(content, request, headers, httpResponse, "index","id-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.BAD_REQUEST.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessPut_RequestThrowsException() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenThrow(IllegalArgumentException.class);\r
+        Response response = documentApi.processPut(content, request, headers, httpResponse, "index","id-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessPut_RequestInvalid() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(false);\r
+        Response response = documentApi.processPut(content, request, headers, httpResponse, "index","id-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessPut_ResultInvalid() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        DocumentOperationResult result = new DocumentOperationResult();\r
+        result.setResultCode(302);\r
+        result.setError(new ErrorResult("type-1", "reason-1"));\r
+        result.setFailureCause("test-failure");\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(true);\r
+        Mockito.when(documentStore.updateDocument(Mockito.anyString(), Mockito.any(DocumentStoreDataEntity.class),\r
+                Mockito.anyBoolean())).thenReturn(result);\r
+        Response response = documentApi.processPut(content, request, headers, httpResponse, "index","id-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FOUND.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessDelete_RequestThrowsException() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenThrow(IllegalArgumentException.class);\r
+        Response response = documentApi.processDelete(content, request, headers, httpResponse, "index","id-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessDelete_RequestInvalid() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(false);\r
+        Response response = documentApi.processDelete(content, request, headers, httpResponse, "index","id-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessDelete_ResultInvalid() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        DocumentOperationResult result = new DocumentOperationResult();\r
+        result.setResultCode(302);\r
+        result.setError(new ErrorResult("type-1", "reason-1"));\r
+        result.setFailureCause("test-failure");\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(true);\r
+        Mockito.when(documentStore.deleteDocument(Mockito.anyString(), Mockito.any(DocumentStoreDataEntity.class)))\r
+                .thenReturn(result);\r
+        Response response = documentApi.processDelete(content, request, headers, httpResponse, "index","id-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FOUND.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessGet_RequestThrowsException() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenThrow(IllegalArgumentException.class);\r
+        Response response = documentApi.processGet(content, request, headers, httpResponse, "index","id-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessGet_RequestInvalid() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(false);\r
+        Response response = documentApi.processGet(content, request, headers, httpResponse, "index","id-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessGet_ResultInvalid() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        DocumentOperationResult result = new DocumentOperationResult();\r
+        result.setResultCode(302);\r
+        result.setError(new ErrorResult("type-1", "reason-1"));\r
+        result.setFailureCause("test-failure");\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(true);\r
+        Mockito.when(documentStore.getDocument(Mockito.anyString(), Mockito.any(DocumentStoreDataEntity.class)))\r
+                .thenReturn(result);\r
+        Response response = documentApi.processGet(content, request, headers, httpResponse, "index","id-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FOUND.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testQueryWithGetWithPayload_NullContent(){\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = null;\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Response response = documentApi.queryWithGetWithPayload(content, request, headers, "index-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.BAD_REQUEST.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testQueryWithGetWithPayload_RequestThrowsException() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenThrow(IllegalArgumentException.class);\r
+        Response response = documentApi.queryWithGetWithPayload(content, request, headers, "index-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testQueryWithGetWithPayload_RequestInvalid() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String content = "content";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(false);\r
+        Response response = documentApi.queryWithGetWithPayload(content, request, headers, "index-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testCreateProcessIndex_IndexApi_RequestInvalid() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(false);\r
+        Response response = indexApi.processCreateIndex("document-1", request, headers, "index-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testCreateProcessIndex_IndexApi_RequestThrowsException() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenThrow(IllegalArgumentException.class);\r
+        Response response = indexApi.processCreateIndex("document-1", request, headers, "index-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testCreateProcessIndex_IndexApi_NullDocument() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        String documentSchema= null;\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(true);\r
+        Response response = indexApi.processCreateIndex(documentSchema, request, headers, "index-1",\r
+                documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessDelete_IndexApi_RequestInvalid() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(false);\r
+        Response response = indexApi.processDelete("document-1", request, headers, documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessDelete_IndexApi_RequestThrowsException() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenThrow(IllegalArgumentException.class);\r
+        Response response = indexApi.processDelete("document-1", request, headers, documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.FORBIDDEN.getStatusCode() == response.getStatus());\r
+    }\r
+\r
+    @Test\r
+    public void testProcessDelete_IndexApi_DeleteIndexException() throws Exception {\r
+        String transactionId = "transactionId-1";\r
+        String remoteAddr = "http://127.0.0.1";\r
+        Mockito.when(headers.getRequestHeaders()).thenReturn(multivaluedMap);\r
+        Mockito.when(multivaluedMap.getFirst(Mockito.anyString())).thenReturn(transactionId);\r
+        Mockito.when(request.getRemoteAddr()).thenReturn(remoteAddr);\r
+        Mockito.when(request.getMethod()).thenReturn("testMethod");\r
+        Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer("http://127.0.0.1"));\r
+        Mockito.when(request.getRemoteHost()).thenReturn("localhost");\r
+        Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
+                Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
+                .thenReturn(true);\r
+        Mockito.when(documentStore.deleteIndex(Mockito.anyString())).thenThrow(DocumentStoreOperationException.class);\r
+        Response response = indexApi.processDelete("document-1", request, headers, documentStore);\r
+        Assert.assertNotNull(response);\r
+        Assert.assertTrue(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode() == response.getStatus());\r
+    }\r
+}\r
diff --git a/src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/config/ElasticSearchConfigTest.java b/src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/config/ElasticSearchConfigTest.java
new file mode 100644 (file)
index 0000000..305963d
--- /dev/null
@@ -0,0 +1,52 @@
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *       http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ */\r
+package org.onap.aai.sa.searchdbabstraction.elasticsearch.config;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Before;\r
+import org.junit.Test;\r
+\r
+import java.util.Properties;\r
+\r
+public class ElasticSearchConfigTest {\r
+\r
+    ElasticSearchConfig elasticSearchConfig;\r
+\r
+    @Before\r
+    public void setUp(){\r
+        Properties prop = new Properties();\r
+        prop.put("es.cluster-name", "cluster-1");\r
+        prop.put("es.ip-address", "127.0.0.1");\r
+        prop.put("es.http-port", "9001");\r
+        elasticSearchConfig = new ElasticSearchConfig(prop);\r
+    }\r
+\r
+    @Test\r
+    public void testAllGetMethods(){\r
+        Assert.assertEquals(elasticSearchConfig.getClusterName(), "cluster-1");\r
+        Assert.assertEquals(elasticSearchConfig.getIpAddress(), "127.0.0.1");\r
+        Assert.assertEquals(elasticSearchConfig.getHttpPort(), "9001");\r
+        Assert.assertEquals(elasticSearchConfig.getJavaApiPort(), "9300");\r
+        Assert.assertNotNull(elasticSearchConfig.toString());\r
+    }\r
+}\r
diff --git a/src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchResultItemTest.java b/src/test/java/org/onap/aai/sa/searchdbabstraction/elasticsearch/dao/ElasticSearchResultItemTest.java
new file mode 100644 (file)
index 0000000..3233d4b
--- /dev/null
@@ -0,0 +1,121 @@
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *       http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ */\r
+package org.onap.aai.sa.searchdbabstraction.elasticsearch.dao;\r
+\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+\r
+public class ElasticSearchResultItemTest {\r
+\r
+    @Test\r
+    public void testAllMethods(){\r
+        ElasticSearchShardStatus shardStatus = new ElasticSearchShardStatus();\r
+        shardStatus.setTotal(10);\r
+        shardStatus.setSuccessful(0);\r
+        shardStatus.setFailed(1);\r
+        Assert.assertEquals(shardStatus.getTotal(), 10);\r
+        Assert.assertEquals(shardStatus.getSuccessful(), 0);\r
+        Assert.assertEquals(shardStatus.getFailed(), 1);\r
+\r
+        ElasticSearchCause cause = new ElasticSearchCause();\r
+        cause.setType("type-1");\r
+        cause.setReason("reason-1");\r
+        Assert.assertEquals(cause.getType(), "type-1");\r
+        Assert.assertEquals(cause.getReason(), "reason-1");\r
+\r
+        ElasticSearchError error = new ElasticSearchError();\r
+        error.setType("type-1");\r
+        error.setReason("reason-1");\r
+        error.setCausedBy(cause);\r
+        Assert.assertEquals(error.getType(), "type-1");\r
+        Assert.assertEquals(error.getReason(), "reason-1");\r
+        Assert.assertNotNull(error.getCausedBy());\r
+        error.setAdditionalProperties("name-1", "value-1");\r
+        Assert.assertNotNull(error.getAdditionalProperties());\r
+\r
+        //Create Status\r
+        ElasticSearchResultItem resultItem1 = new ElasticSearchResultItem();\r
+        resultItem1.setCreate(getStatus(shardStatus, error));\r
+        Assert.assertNotNull(resultItem1.getCreate());\r
+        Assert.assertEquals(resultItem1.operationType(), "create");\r
+        Assert.assertEquals(resultItem1.operationStatus(), resultItem1.getCreate());\r
+        Assert.assertTrue(resultItem1.toString().contains("create"));\r
+        Assert.assertNotNull(resultItem1.toJson());\r
+\r
+        //Index Status\r
+        ElasticSearchResultItem resultItem2 = new ElasticSearchResultItem();\r
+        resultItem2.setIndex(getStatus(shardStatus, error));\r
+        Assert.assertNotNull(resultItem2.getIndex());\r
+        Assert.assertEquals(resultItem2.operationType(), "update");\r
+        Assert.assertEquals(resultItem2.operationStatus(), resultItem2.getIndex());\r
+        Assert.assertTrue(resultItem2.toString().contains("index"));\r
+        Assert.assertNotNull(resultItem2.toJson());\r
+\r
+        //Delete Status\r
+        ElasticSearchResultItem resultItem3 = new ElasticSearchResultItem();\r
+        resultItem3.setDelete(getStatus(shardStatus, error));\r
+        Assert.assertNotNull(resultItem3.getDelete());\r
+        Assert.assertEquals(resultItem3.operationType(), "delete");\r
+        Assert.assertEquals(resultItem3.operationStatus(), resultItem3.getDelete());\r
+        Assert.assertTrue(resultItem3.toString().contains("delete"));\r
+        Assert.assertNotNull(resultItem3.toJson());\r
+\r
+        //Unknown Status\r
+        ElasticSearchResultItem resultItem4 = new ElasticSearchResultItem();\r
+        Assert.assertEquals(resultItem4.operationType(), "unknown");\r
+        Assert.assertNull(resultItem4.operationStatus());\r
+\r
+        //ElasticSearchBulkOperationResult\r
+        ElasticSearchResultItem[] resultItems = {resultItem1, resultItem2, resultItem3};\r
+        ElasticSearchBulkOperationResult result = new ElasticSearchBulkOperationResult();\r
+        result.setErrors(true);\r
+        result.setTook(new Integer(10));\r
+        result.setItems(resultItems);\r
+        Assert.assertTrue(result.getErrors());\r
+        Assert.assertEquals(result.getTook(), new Integer(10));\r
+        Assert.assertNotNull(result.getItems());\r
+        Assert.assertNotNull(result.toString());\r
+    }\r
+\r
+    private ElasticSearchOperationStatus getStatus(ElasticSearchShardStatus shardStatus, ElasticSearchError error) {\r
+        ElasticSearchOperationStatus status = new ElasticSearchOperationStatus();\r
+        status.setIndex("index-1");\r
+        status.setType("type-1");\r
+        status.setId("id-1");\r
+        status.setVersion("1.0");\r
+        status.setShards(shardStatus);\r
+        status.setStatus(new Integer(1));\r
+        status.setError(error);\r
+        status.setAdditionalProperties("REQUEST_URL", "http://127.0.0.1");\r
+        Assert.assertEquals(status.getIndex(), "index-1");\r
+        Assert.assertEquals(status.getType(), "type-1");\r
+        Assert.assertEquals(status.getId(), "id-1");\r
+        Assert.assertEquals(status.getVersion(), "1.0");\r
+        Assert.assertEquals(status.getStatus(), new Integer(1));\r
+        Assert.assertNotNull(status.getShards());\r
+        Assert.assertNotNull(status.getError());\r
+        Assert.assertNotNull(status.getAdditionalProperties());\r
+        return status;\r
+    }\r
+\r
+}\r
diff --git a/src/test/java/org/onap/aai/sa/searchdbabstraction/searchapi/RangeQueryTest.java b/src/test/java/org/onap/aai/sa/searchdbabstraction/searchapi/RangeQueryTest.java
new file mode 100644 (file)
index 0000000..cd8e2c0
--- /dev/null
@@ -0,0 +1,153 @@
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *       http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ */\r
+package org.onap.aai.sa.searchdbabstraction.searchapi;\r
+\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+import org.onap.aai.sa.rest.TestUtils;\r
+\r
+import java.io.File;\r
+import java.io.IOException;\r
+import java.util.Date;\r
+\r
+public class RangeQueryTest {\r
+\r
+    @Test(expected=IllegalArgumentException.class)\r
+    public void testSetGt(){\r
+\r
+        RangeQuery rq = new RangeQuery();\r
+        rq.setLt(new String("2x"));\r
+        Assert.assertEquals("2x", rq.getLt());\r
+        Assert.assertNotNull(rq.toElasticSearch());\r
+        Assert.assertNotNull(rq.toString());\r
+        rq.setGt(new Integer(1));\r
+    }\r
+\r
+    @Test(expected=IllegalArgumentException.class)\r
+    public void testSetGte(){\r
+\r
+        RangeQuery rq = new RangeQuery();\r
+        rq.setGt(new Integer(1));\r
+        Assert.assertNotNull(rq.toElasticSearch());\r
+        Assert.assertNotNull(rq.toString());\r
+        rq.setGte(new Integer(1));\r
+    }\r
+\r
+    @Test(expected=IllegalArgumentException.class)\r
+    public void testSetLt(){\r
+\r
+        RangeQuery rq = new RangeQuery();\r
+        rq.setLt(new Integer(1));\r
+        rq.setFormat("format-1");\r
+        Assert.assertEquals(rq.getFormat(), "format-1");\r
+        Assert.assertNotNull(rq.toElasticSearch());\r
+        Assert.assertNotNull(rq.toString());\r
+\r
+        rq.setGt(new Integer(1));\r
+        Assert.assertNotNull(rq.toElasticSearch());\r
+        Assert.assertNotNull(rq.toString());\r
+        rq.setLt(new String("10"));\r
+    }\r
+\r
+    @Test(expected=IllegalArgumentException.class)\r
+    public void testSetLte(){\r
+        RangeQuery rq = new RangeQuery();\r
+        rq.setGt(new Integer(1));\r
+        rq.setTimeZone("CT");\r
+        Assert.assertEquals(rq.getTimeZone(), "CT");\r
+        Assert.assertNotNull(rq.toElasticSearch());\r
+        Assert.assertNotNull(rq.toString());\r
+\r
+        rq.setLte(new String("10"));\r
+    }\r
+\r
+    @Test\r
+    public void testSearchStatementAggregations() throws IOException {\r
+        File queryWithSubrangeFile = new File("src/test/resources/json/queries/query-with-subrange.json");\r
+        String queryWithSubrangeStr = TestUtils.readFileToString(queryWithSubrangeFile);\r
+\r
+        ObjectMapper mapper = new ObjectMapper();\r
+        SearchStatement ss = mapper.readValue(queryWithSubrangeStr, SearchStatement.class);\r
+\r
+        Aggregation a1 = getAggregationObject();\r
+        Aggregation a2 = getAggregationObject();\r
+        Aggregation[] aggs= new Aggregation[] {a1, a2};\r
+        ss.setAggregations(aggs);\r
+        Assert.assertNotNull(ss.toString());\r
+    }\r
+\r
+    private Aggregation getAggregationObject(){\r
+        Aggregation a = new Aggregation();\r
+\r
+        AggregationStatement as = new AggregationStatement();\r
+        DateHistogramAggregation dha = new DateHistogramAggregation();\r
+        dha.setField("field-1");\r
+        dha.setInterval("interval-1");\r
+        Assert.assertEquals(dha.getInterval(), "interval-1");\r
+        dha.setTimeZone("CT");\r
+        Assert.assertEquals(dha.getTimeZone(), "CT");\r
+        dha.setFormat("format-1");\r
+        Assert.assertEquals(dha.getFormat(), "format-1");\r
+        dha.setSize(10);\r
+        dha.setMinThreshold(1);\r
+        Assert.assertNotNull(dha.toElasticSearch());\r
+        Assert.assertNotNull(dha.toString());\r
+        as.setDateHist(dha);\r
+        as.toString();\r
+\r
+        as.getNestedPath();\r
+\r
+        DateRangeAggregation dra = new DateRangeAggregation();\r
+        dra.setField("field-1");\r
+        dra.setMinThreshold(1);\r
+        dra.setFormat("format-1");\r
+        Assert.assertEquals(dra.getFormat(), "format-1");\r
+        DateRange dr = new DateRange();\r
+        dr.setFromDate("01-12-2017");\r
+        Assert.assertEquals(dr.getFromDate(), "01-12-2017");\r
+        dr.setToDate("21-12-2017");\r
+        Assert.assertEquals(dr.getToDate(), "21-12-2017");\r
+        DateRange[] drs = {dr};\r
+        dra.setDateRanges(drs);\r
+        Assert.assertTrue(dra.getDateRanges().length==1);\r
+        Assert.assertNotNull(dra.toElasticSearch());\r
+        Assert.assertNotNull(dra.toString());\r
+        as.setDateRange(dra);\r
+        as.toString();\r
+\r
+        as.getNestedPath();\r
+\r
+        GroupByAggregation gba = new GroupByAggregation();\r
+        gba.setField("field-1");\r
+        gba.setMinThreshold(1);\r
+        Assert.assertNotNull(gba.toElasticSearch());\r
+        Assert.assertNotNull(gba.toString());\r
+        as.setGroupBy(gba);\r
+        Assert.assertNotNull(as.toString());\r
+\r
+        a.setStatement(as);\r
+        Assert.assertNotNull(a.toString());\r
+        return a;\r
+    }\r
+}\r
diff --git a/src/test/java/org/onap/aai/sa/searchdbabstraction/searchapi/TermQueryTest.java b/src/test/java/org/onap/aai/sa/searchdbabstraction/searchapi/TermQueryTest.java
new file mode 100644 (file)
index 0000000..fd16574
--- /dev/null
@@ -0,0 +1,68 @@
+/**\r
+ * ============LICENSE_START=======================================================\r
+ * org.onap.aai\r
+ * ================================================================================\r
+ * Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
+ * Copyright © 2017 Amdocs\r
+ * ================================================================================\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *       http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * ============LICENSE_END=========================================================\r
+ *\r
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ */\r
+package org.onap.aai.sa.searchdbabstraction.searchapi;\r
+\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+import org.junit.Assert;\r
+import org.junit.Test;\r
+\r
+import java.io.IOException;\r
+\r
+public class TermQueryTest {\r
+\r
+    @Test\r
+    public void testAllMethods() throws IOException {\r
+\r
+        String field = "searchTags.nested";\r
+        String stringValue = "theValue.nested";\r
+        String termQueryWithStringValueJson = "{\"field\": \"" + field + "\", \"value\": \"" + stringValue + "\"}";\r
+        String termQueryWithStringValueExpectedES = "{\"term\": {\"" + field + "\" : \"" + stringValue + "\"}}";\r
+\r
+        ObjectMapper mapper = new ObjectMapper();\r
+        TermQuery stringTermQuery = mapper.readValue(termQueryWithStringValueJson, TermQuery.class);\r
+        Assert.assertEquals(stringValue, stringTermQuery.getValue());\r
+        Assert.assertEquals("searchTags.nested", stringTermQuery.getField());\r
+        stringTermQuery.setOperator("operator-1");\r
+        Assert.assertEquals("operator-1", stringTermQuery.getOperator());\r
+        stringTermQuery.setSearchAnalyzer("search-1");\r
+        Assert.assertEquals("search-1", stringTermQuery.getSearchAnalyzer());\r
+\r
+        String field1 = "searchTags-1 searchTags.second";\r
+        String stringValue1 = "theValue-1 theValue.second";\r
+        String multiFieldTermQueryJSon = "{\"field\": \"" + field1 + "\", \"value\": \"" + stringValue1 + "\"}";\r
+        TermQuery multiFieldTermQuery = mapper.readValue(multiFieldTermQueryJSon, TermQuery.class);\r
+        multiFieldTermQuery.setOperator("and");\r
+        multiFieldTermQuery.setSearchAnalyzer("search-1");\r
+        Assert.assertNotNull(multiFieldTermQuery.toElasticSearch());\r
+        Assert.assertNotNull(multiFieldTermQuery.pathForNestedField(field1));\r
+\r
+        String field2 = "search11 search2";\r
+        String stringValue2 = "theValue1 theValue2";\r
+        String multiFieldTermJSon = "{\"field\": \"" + field2 + "\", \"value\": \"" + stringValue2 + "\"}";\r
+        TermQuery multiFieldTerm = mapper.readValue(multiFieldTermJSon, TermQuery.class);\r
+        multiFieldTerm.setOperator("or");\r
+        multiFieldTerm.setSearchAnalyzer("search-1");\r
+        Assert.assertNotNull(multiFieldTerm.toElasticSearch());\r
+    }\r
+\r
+}\r
diff --git a/src/test/resources/json/search_policy.json b/src/test/resources/json/search_policy.json
new file mode 100644 (file)
index 0000000..ab8d0e3
--- /dev/null
@@ -0,0 +1,37 @@
+{\r
+  "roles": [{\r
+    "name": "testRole",\r
+    "functions": [{\r
+      "name": "testFunction",\r
+      "methods": [{\r
+        "name": "GET"\r
+      }, {\r
+        "name": "DELETE"\r
+      }, {\r
+        "name": "PUT"\r
+      }\r
+      ]\r
+    }\r
+    ],\r
+    "users": [{\r
+      "username": "testUser"\r
+    }\r
+    ]\r
+  }, {\r
+    "name": "testBasicAuth",\r
+    "functions": [{\r
+      "name": "testBasicAuthFuncyion",\r
+      "methods": [{\r
+        "name": "GET"\r
+      }\r
+      ]\r
+    }\r
+    ],\r
+    "users": [{\r
+      "user": "testBasicAuthUser",\r
+      "pass": "OBF:1ytc1vu91v2p1rxf1mqh1v8s1z0d1msn1san1mqf1z0h1v9u1msl1rvf1v1p1vv11yta"\r
+    }\r
+    ]\r
+  }\r
+  ]\r
+}
\ No newline at end of file