Code changes to fix Exception 97/36797/1
authorBalaji, Ramya (rb111y) <rb111y@att.com>
Mon, 19 Mar 2018 16:50:52 +0000 (12:50 -0400)
committerBalaji, Ramya (rb111y) <rb111y@att.com>
Mon, 19 Mar 2018 17:18:33 +0000 (13:18 -0400)
Reverted changes to method name in Transaction.java
to getuId() as this caused incorrect attributes
to be added to the generated JSON. Added unit test
to ensure this works as expected in the future.

Issue-ID: APPC-760
Change-Id: I07adcda0b5f04bd00efc113b94c68f48af13ad78
Signed-off-by: Balaji, Ramya (rb111y) <rb111y@att.com>
appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/data/Transaction.java
appc-config/appc-flow-controller/provider/src/main/java/org/onap/appc/flow/controller/executorImpl/RestExecutor.java
appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/MapperTest.java [new file with mode: 0644]
appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/TransactionHandlerTest.java

index 2eb75ff..327028f 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP : APPC
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-18 AT&T Intellectual Property. All rights reserved.
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -77,7 +77,7 @@ public class Transaction {
 
     private String status = "PENDING";
 
-    public String getId() {
+    public String getuId() {
         return uId;
     }
 
index 2f64a21..d18f2a3 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP : APPC
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-18 AT&T Intellectual Property. All rights reserved.
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -65,7 +65,7 @@ public class RestExecutor implements FlowExecutorInterface {
                     HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
                     new HTTPSProperties(getHostnameVerifier(), sslContext));
             client = createClient(defaultClientConfig);
-            client.addFilter(new HTTPBasicAuthFilter(transaction.getId(), transaction.getPswd()));
+            client.addFilter(new HTTPBasicAuthFilter(transaction.getuId(), transaction.getPswd()));
             WebResource webResource = client.resource(new URI(transaction.getExecutionEndPoint()));
             webResource.setProperty("Content-Type", "application/json;charset=UTF-8");
 
diff --git a/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/MapperTest.java b/appc-config/appc-flow-controller/provider/src/test/java/org/onap/appc/flow/controller/node/MapperTest.java
new file mode 100644 (file)
index 0000000..dfeb497
--- /dev/null
@@ -0,0 +1,67 @@
+/*-\r
+ * ============LICENSE_START=======================================================\r
+ * ONAP : APPC\r
+ * ================================================================================\r
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.\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
+ *\r
+ *  * ============LICENSE_END=========================================================\r
+ */\r
+\r
+package org.onap.appc.flow.controller.node;\r
+\r
+import static org.junit.Assert.assertEquals;\r
+\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
+import org.junit.Test;\r
+import org.onap.appc.flow.controller.data.Transaction;\r
+import org.onap.appc.flow.controller.data.Transactions;\r
+\r
+import com.fasterxml.jackson.core.JsonProcessingException;\r
+import com.fasterxml.jackson.databind.ObjectMapper;\r
+\r
+/*\r
+ * Adding this test case to ensure that JSON mapping works as expected.\r
+ * Add or modify test case if changes are made to class attributes.\r
+ *\r
+*/\r
+public class MapperTest {\r
+\r
+    @Test\r
+    public void testsIfJsonGenerationisValid() throws JsonProcessingException {\r
+\r
+        Transaction t = new Transaction();\r
+        Transactions transactions = new Transactions();\r
+        t.setAction("testAction");\r
+        t.setTransactionId(100);\r
+        t.setActionLevel("testActionLevel");\r
+        t.setExecutionRPC("testMethod");\r
+        List<Transaction> tList = new ArrayList<Transaction>();\r
+        tList.add(t);\r
+        transactions.setTransactions(tList);\r
+        Transactions trans = transactions;\r
+        ObjectMapper mapper = new ObjectMapper();\r
+        String flowSequence = mapper.writeValueAsString(trans);\r
+        String compareString = "{\"transactions\":[{\"executionType\":null,\"uId\":null,\"statusCode\":null,\"pswd\":null,"\r
+                + "\"executionEndPoint\":null,\"executionModule\":null,\"executionRPC\":\"testMethod\","\r
+                + "\"status\":\"PENDING\",\"transaction-id\":100,\"action\":\"testAction\","\r
+                + "\"action-level\":\"testActionLevel\",\"action-identifier\":null,"\r
+                + "\"parameters\":null,\"state\":null,\"precheck\":null,\"payload\":null,\"responses\":null}]}";\r
+        assertEquals(flowSequence, compareString);\r
+\r
+    }\r
+\r
+}\r
index f16dd65..637a9ea 100644 (file)
@@ -1,3 +1,24 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ *  * ============LICENSE_END=========================================================
+ */
+
 package org.onap.appc.flow.controller.node;
 
 import static org.mockito.Mockito.mock;
@@ -69,8 +90,8 @@ public class TransactionHandlerTest {
     Assert.assertEquals(INPUT_REQUEST_ACTION, transaction.getAction());
     Assert.assertEquals("input-ra-type", transaction.getExecutionRPC());
     Assert.assertEquals("some uri", transaction.getExecutionEndPoint());
-    Assert.assertEquals("rest-user", transaction.getId());
+    Assert.assertEquals("rest-user", transaction.getuId());
     Assert.assertEquals("rest-pass", transaction.getPswd());
   }
 
-}
\ No newline at end of file
+}