Format Java code to ONAP standard
[aai/search-data-service.git] / src / test / java / org / onap / aai / sa / rest / DocumentTest.java
index efff07b..9fa5fe1 100644 (file)
@@ -71,7 +71,7 @@ public class DocumentTest {
     DocumentApi documentApi;\r
 \r
     @Before\r
-    public void setUp(){\r
+    public void setUp() {\r
         MockitoAnnotations.initMocks(this);\r
         documentApi = new DocumentApi(searchServiceApi);\r
     }\r
@@ -80,14 +80,14 @@ public class DocumentTest {
     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.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
+    public void testProcessPost_NullContent() {\r
         String transactionId = "transactionId-1";\r
         String remoteAddr = "http://127.0.0.1";\r
         String content = null;\r
@@ -97,10 +97,10 @@ public class DocumentTest {
         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
-        ResponseEntity<String> response = documentApi.processPost(content, request, headers, httpResponse, "index",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processPost(content, request, headers, httpResponse, "index", documentStore);\r
         Assert.assertNotNull(response);\r
-        Assert.assertTrue( HttpStatus.BAD_REQUEST.value () == response.getStatusCodeValue ());\r
+        Assert.assertTrue(HttpStatus.BAD_REQUEST.value() == response.getStatusCodeValue());\r
     }\r
 \r
     @Test\r
@@ -117,12 +117,13 @@ public class DocumentTest {
         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
-        ResponseEntity response = documentApi.processPost(content, request, headers, httpResponse, "index",\r
-                documentStore);\r
+        ResponseEntity response =\r
+                documentApi.processPost(content, request, headers, httpResponse, "index", documentStore);\r
         Assert.assertNotNull(response);\r
-        Assert.assertTrue(HttpStatus.FORBIDDEN.value () == response.getStatusCodeValue ());\r
+        Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
     }\r
-//\r
+\r
+    //\r
     @Test\r
     public void testProcessPost_ValidRequest() throws Exception {\r
         String transactionId = "transactionId-1";\r
@@ -144,12 +145,13 @@ public class DocumentTest {
         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
-        ResponseEntity<String> response = documentApi.processPost(content, request, headers, httpResponse, "index",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processPost(content, request, headers, httpResponse, "index", documentStore);\r
         Assert.assertNotNull(response);\r
-        Assert.assertTrue(HttpStatus.INTERNAL_SERVER_ERROR.value () == response.getStatusCodeValue ());\r
+        Assert.assertTrue(HttpStatus.INTERNAL_SERVER_ERROR.value() == response.getStatusCodeValue());\r
     }\r
-//\r
+\r
+    //\r
     @Test\r
     public void testProcessSearchWithGet_Created() throws Exception {\r
         String transactionId = "transactionId-1";\r
@@ -170,13 +172,14 @@ public class DocumentTest {
                 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
-        ResponseEntity<String>response = documentApi.processSearchWithGet(content, request, headers, "index-1",\r
-                "query-text", documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processSearchWithGet(content, request, headers, "index-1", "query-text", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.CREATED.value() == response.getStatusCodeValue());\r
 \r
     }\r
-//\r
+\r
+    //\r
     @Test\r
     public void testProcessSearchWithGet_ValidateThrowsException() throws Exception {\r
         String transactionId = "transactionId-1";\r
@@ -197,13 +200,14 @@ public class DocumentTest {
                 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
-        ResponseEntity<String>response = documentApi.processSearchWithGet(content, request, headers, "index-1",\r
-                "query-text", documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processSearchWithGet(content, request, headers, "index-1", "query-text", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
 \r
     }\r
-//\r
+\r
+    //\r
     @Test\r
     public void testProcessSearchWithGet_ValidateIsFalse() throws Exception {\r
         String transactionId = "transactionId-1";\r
@@ -224,8 +228,8 @@ public class DocumentTest {
                 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
-        ResponseEntity<String>response = documentApi.processSearchWithGet(content, request, headers, "index-1",\r
-                "query-text", documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processSearchWithGet(content, request, headers, "index-1", "query-text", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
 \r
@@ -251,15 +255,15 @@ public class DocumentTest {
                 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
-        ResponseEntity<String>response = documentApi.processSearchWithGet(content, request, headers, "index-1",\r
-                "query-text", documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processSearchWithGet(content, request, headers, "index-1", "query-text", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FOUND.value() == response.getStatusCodeValue());\r
 \r
     }\r
 \r
     @Test\r
-    public void testProcessPut_NullContent(){\r
+    public void testProcessPut_NullContent() {\r
         String transactionId = "transactionId-1";\r
         String remoteAddr = "http://127.0.0.1";\r
         String content = null;\r
@@ -269,8 +273,8 @@ public class DocumentTest {
         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
-        ResponseEntity<String>response = documentApi.processPut(content, request, headers, httpResponse, "index","id-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processPut(content, request, headers, httpResponse, "index", "id-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.BAD_REQUEST.value() == response.getStatusCodeValue());\r
     }\r
@@ -289,8 +293,8 @@ public class DocumentTest {
         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
-        ResponseEntity<String>response = documentApi.processPut(content, request, headers, httpResponse, "index","id-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processPut(content, request, headers, httpResponse, "index", "id-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
     }\r
@@ -309,8 +313,8 @@ public class DocumentTest {
         Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
                 Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
                 .thenReturn(false);\r
-        ResponseEntity<String>response = documentApi.processPut(content, request, headers, httpResponse, "index","id-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processPut(content, request, headers, httpResponse, "index", "id-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
     }\r
@@ -336,8 +340,8 @@ public class DocumentTest {
                 .thenReturn(true);\r
         Mockito.when(documentStore.updateDocument(Mockito.anyString(), Mockito.any(DocumentStoreDataEntity.class),\r
                 Mockito.anyBoolean())).thenReturn(result);\r
-        ResponseEntity<String>response = documentApi.processPut(content, request, headers, httpResponse, "index","id-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processPut(content, request, headers, httpResponse, "index", "id-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FOUND.value() == response.getStatusCodeValue());\r
     }\r
@@ -356,8 +360,8 @@ public class DocumentTest {
         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
-        ResponseEntity<String>response = documentApi.processDelete(content, request, headers, httpResponse, "index","id-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processDelete(content, request, headers, httpResponse, "index", "id-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
     }\r
@@ -376,8 +380,8 @@ public class DocumentTest {
         Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
                 Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
                 .thenReturn(false);\r
-        ResponseEntity<String>response = documentApi.processDelete(content, request, headers, httpResponse, "index","id-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processDelete(content, request, headers, httpResponse, "index", "id-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
     }\r
@@ -403,8 +407,8 @@ public class DocumentTest {
                 .thenReturn(true);\r
         Mockito.when(documentStore.deleteDocument(Mockito.anyString(), Mockito.any(DocumentStoreDataEntity.class)))\r
                 .thenReturn(result);\r
-        ResponseEntity<String>response = documentApi.processDelete(content, request, headers, httpResponse, "index","id-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processDelete(content, request, headers, httpResponse, "index", "id-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FOUND.value() == response.getStatusCodeValue());\r
     }\r
@@ -423,8 +427,8 @@ public class DocumentTest {
         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
-        ResponseEntity<String>response = documentApi.processGet(content, request, headers, httpResponse, "index","id-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processGet(content, request, headers, httpResponse, "index", "id-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
     }\r
@@ -443,8 +447,8 @@ public class DocumentTest {
         Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
                 Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
                 .thenReturn(false);\r
-        ResponseEntity<String>response = documentApi.processGet(content, request, headers, httpResponse, "index","id-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processGet(content, request, headers, httpResponse, "index", "id-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
     }\r
@@ -469,14 +473,14 @@ public class DocumentTest {
                 .thenReturn(true);\r
         Mockito.when(documentStore.getDocument(Mockito.anyString(), Mockito.any(DocumentStoreDataEntity.class)))\r
                 .thenReturn(result);\r
-        ResponseEntity<String>response = documentApi.processGet(content, request, headers, httpResponse, "index","id-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.processGet(content, request, headers, httpResponse, "index", "id-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FOUND.value() == response.getStatusCodeValue());\r
     }\r
 \r
     @Test\r
-    public void testQueryWithGetWithPayload_NullContent(){\r
+    public void testQueryWithGetWithPayload_NullContent() {\r
         String transactionId = "transactionId-1";\r
         String remoteAddr = "http://127.0.0.1";\r
         String content = null;\r
@@ -486,8 +490,8 @@ public class DocumentTest {
         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
-        ResponseEntity<String>response = documentApi.queryWithGetWithPayload(content, request, headers, "index-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.queryWithGetWithPayload(content, request, headers, "index-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.BAD_REQUEST.value() == response.getStatusCodeValue());\r
     }\r
@@ -506,8 +510,8 @@ public class DocumentTest {
         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
-        ResponseEntity<String>response = documentApi.queryWithGetWithPayload(content, request, headers, "index-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.queryWithGetWithPayload(content, request, headers, "index-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
     }\r
@@ -526,8 +530,8 @@ public class DocumentTest {
         Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
                 Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
                 .thenReturn(false);\r
-        ResponseEntity<String>response = documentApi.queryWithGetWithPayload(content, request, headers, "index-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                documentApi.queryWithGetWithPayload(content, request, headers, "index-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
     }\r
@@ -545,8 +549,8 @@ public class DocumentTest {
         Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
                 Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
                 .thenReturn(false);\r
-        ResponseEntity<String>response = indexApi.processCreateIndex("document-1", request, headers, "index-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                indexApi.processCreateIndex("document-1", request, headers, "index-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
     }\r
@@ -564,8 +568,8 @@ public class DocumentTest {
         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
-        ResponseEntity<String>response = indexApi.processCreateIndex("document-1", request, headers, "index-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                indexApi.processCreateIndex("document-1", request, headers, "index-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
     }\r
@@ -574,7 +578,7 @@ public class DocumentTest {
     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
+        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
@@ -584,8 +588,8 @@ public class DocumentTest {
         Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
                 Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
                 .thenReturn(true);\r
-        ResponseEntity<String>response = indexApi.processCreateIndex(documentSchema, request, headers, "index-1",\r
-                documentStore);\r
+        ResponseEntity<String> response =\r
+                indexApi.processCreateIndex(documentSchema, request, headers, "index-1", documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.INTERNAL_SERVER_ERROR.value() == response.getStatusCodeValue());\r
     }\r
@@ -603,7 +607,7 @@ public class DocumentTest {
         Mockito.when(searchServiceApi.validateRequest(Mockito.any(HttpHeaders.class),\r
                 Mockito.any(HttpServletRequest.class), Mockito.any(ApiUtils.Action.class), Mockito.anyString()))\r
                 .thenReturn(false);\r
-        ResponseEntity<String>response = indexApi.processDelete("document-1", request, headers, documentStore);\r
+        ResponseEntity<String> response = indexApi.processDelete("document-1", request, headers, documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
     }\r
@@ -621,7 +625,7 @@ public class DocumentTest {
         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
-        ResponseEntity<String>response = indexApi.processDelete("document-1", request, headers, documentStore);\r
+        ResponseEntity<String> response = indexApi.processDelete("document-1", request, headers, documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.FORBIDDEN.value() == response.getStatusCodeValue());\r
     }\r
@@ -640,7 +644,7 @@ public class DocumentTest {
                 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
-        ResponseEntity<String>response = indexApi.processDelete("document-1", request, headers, documentStore);\r
+        ResponseEntity<String> response = indexApi.processDelete("document-1", request, headers, documentStore);\r
         Assert.assertNotNull(response);\r
         Assert.assertTrue(HttpStatus.INTERNAL_SERVER_ERROR.value() == response.getStatusCodeValue());\r
     }\r