Added New Junit Cases for APPC Design Services 19/8819/1
authorAnand Chaturvedi <ac204h@att.com>
Thu, 24 Aug 2017 04:10:17 +0000 (00:10 -0400)
committerAnand Chaturvedi <ac204h@att.com>
Fri, 25 Aug 2017 17:39:30 +0000 (13:39 -0400)
Change-Id: Icc55aaadc1df1b8c368afaeb092a6c64a71202b7
Issue-ID: APPC-168
Signed-off-by: Anand Chaturvedi <ac204h@att.com>
appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestArifactHandlerClient.java
appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDBService.java [new file with mode: 0644]
appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDbResponse.java [new file with mode: 0644]
appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDesigndata.java
appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestEscapeUtils.java
appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java

index bc0720e..0ac893e 100644 (file)
@@ -1,59 +1,73 @@
-package org.openecomp.appc.design.validator;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.openecomp.appc.design.services.util.ArtifactHandlerClient;\r
-\r
-import junit.framework.Assert;\r
-\r
-import static org.mockito.Mockito.*;\r
-\r
-import java.io.File;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.util.Enumeration;\r
-import java.util.Properties;\r
-\r
-import org.apache.commons.io.FileUtils;\r
-\r
-public class TestArifactHandlerClient {\r
-       \r
-       @Test\r
-       public void testCreateArtifactData(){\r
-               try{\r
-               String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));\r
-               String payload = " { \"userID\": \"00000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\":  "  \r
-               + content + \r
-                " } ";\r
-               String requestID ="0000";\r
-               ArtifactHandlerClient ahi = new ArtifactHandlerClient();\r
-               String value =  ahi.createArtifactData(payload, requestID);\r
-               System.out.println(value);\r
-               Assert.assertTrue(!value.isEmpty());;\r
-               \r
-               \r
-               }catch(Exception e)\r
-               {\r
-                       e.printStackTrace();\r
-               }\r
-               \r
-       }\r
-       \r
-       \r
-       @Test\r
-       public void testExecute() throws Exception{\r
-               try{\r
-               String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));\r
-               String payload = " { \"userID\": \"00000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\":  "  \r
-               + content + \r
-                " } ";\r
-               String rpc = "Test_Configure";\r
-               \r
-                       ArtifactHandlerClient ahi = new ArtifactHandlerClient();\r
-                ahi.execute(payload, rpc);\r
-               }catch(Exception e)\r
-               {\r
-                       e.printStackTrace();\r
-               }\r
-       }\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ * 
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.design.validator;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.appc.design.services.util.ArtifactHandlerClient;
+import junit.framework.Assert;
+import static org.mockito.Mockito.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Enumeration;
+import java.util.Properties;
+import org.apache.commons.io.FileUtils;
+
+public class TestArifactHandlerClient {
+        
+    @Test
+    public void testCreateArtifactData(){
+        
+        try{
+        String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+        String payload = " { \"userID\": \"00000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\":  "  
+        + content + 
+         " } ";
+        String requestID ="0000";
+        ArtifactHandlerClient ahi = new ArtifactHandlerClient();
+        String value =  ahi.createArtifactData(payload, requestID);
+        Assert.assertTrue(!value.isEmpty());
+        }catch(Exception e)
+        {
+        }
+    }
+        
+    @Test
+    public void testExecute(){
+        
+        try{
+        String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+        String payload = " { \"userID\": \"00000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\":  "  
+        + content + 
+         " } ";
+        String rpc = "Post";
+        ArtifactHandlerClient ahi = new ArtifactHandlerClient();
+        ahi.execute(payload, rpc);
+        }catch(Exception e)
+        {
+        }
+    }
+}
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDBService.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDBService.java
new file mode 100644 (file)
index 0000000..d14abce
--- /dev/null
@@ -0,0 +1,232 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ * 
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.design.validator;
+
+import java.io.File;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Properties;
+import org.apache.commons.io.FileUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.appc.design.dbervices.DbService;
+import org.openecomp.appc.design.dbervices.DesignDBService;
+import org.openecomp.appc.design.propertyServices.PropertyUpdateService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import junit.framework.Assert;
+import org.powermock.reflect.Whitebox;
+
+public class TestDBService {
+
+    private final org.slf4j.Logger logger = LoggerFactory.getLogger(TestDBService.class);
+
+    @Test
+    public void testGetDesigns() {
+        try {
+            String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\" }";
+            DesignDBService dbservice = DesignDBService.initialise();
+            dbservice.execute("getDesigns", payload, "1234");
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    public void testGetStatus() {
+        try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService dbservice = DesignDBService.initialise();
+            DbService db = new DbService();
+            Whitebox.invokeMethod(db, "getDbLibService");
+            dbservice.execute("getStatus", payload, "1234");
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    public void testUploadArtifact() {
+        try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService dbservice = DesignDBService.initialise();
+            DbService db = new DbService();
+            Whitebox.invokeMethod(db, "getDbLibService");
+            dbservice.execute("uploadArtifact", payload, "1234");
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    public void testGetArtifact() {
+        try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService design = DesignDBService.initialise();
+            DbService db = new DbService();
+            Whitebox.invokeMethod(db, "getDbLibService");
+            design.execute("getArtifact", payload, "1234");
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    public void testSetIncart() {
+        try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\",\"action-level\":\"VNf\",\"protocol\":\"Test\", \"inCart\":\"Y\",\"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService design = DesignDBService.initialise();
+            DbService db = new DbService();
+            Whitebox.invokeMethod(db, "getDbLibService");
+            design.execute("setInCart", payload, "1234");
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    public void testSetProtocolReference() {
+        try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\",\"action-level\":\"VNf\",\"protocol\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService design = DesignDBService.initialise();
+            DbService db = new DbService();
+            Whitebox.invokeMethod(db, "getDbLibService");
+            design.execute("setProtocolReference", payload, "1234");
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    public void testSetStatus() {
+        try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService design = DesignDBService.initialise();
+            DbService db = new DbService();
+            Whitebox.invokeMethod(db, "getDbLibService");
+            design.execute("setStatus", payload, "1234");
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    public void testGetArtifactReference() {
+        try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService design = DesignDBService.initialise();
+            DbService db = new DbService();
+            Whitebox.invokeMethod(db, "getDbLibService");
+            design.execute("getArtifactReference", payload, "1234");
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    public void testGetGuiReference() {
+        try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService design = DesignDBService.initialise();
+            DbService db = new DbService();
+            Whitebox.invokeMethod(db, "getDbLibService");
+            design.execute("getGuiReference", payload, "1234");
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    public void testPropertyUpdateService() {
+        PropertyUpdateService ps = new PropertyUpdateService();
+    }
+
+    @Test
+    public void testLinkstatusRelationShip() {        
+        try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService design = DesignDBService.initialise();
+            Whitebox.invokeMethod(design, "linkstatusRelationShip", 1, 1, payload);
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    public void testGetASDCReferenceID() {
+        
+        try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService design = DesignDBService.initialise();
+            Whitebox.invokeMethod(design, "getASDCReferenceID", payload);
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    public void testGetDataFromActionStatus() {        
+        try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService design = DesignDBService.initialise();
+            Whitebox.invokeMethod(design, "getDataFromActionStatus", payload, "Test");
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    public void testSetActionStatus() {
+        try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService design = DesignDBService.initialise();
+            Whitebox.invokeMethod(design, "setActionStatus", payload, "Accepted");
+        } catch (Exception e) {
+        }
+    }
+        
+    @Test
+    public void testGetASDCArtifactIDbyRequestID() {
+        try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService design = DesignDBService.initialise();
+            Whitebox.invokeMethod(design, "getASDCArtifactIDbyRequestID", "0");
+        } catch (Exception e) {
+        }
+    }
+
+    @Test
+    public void testCreateArtifactTrackingRecord() {
+            try {
+            String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
+            String payload = " { \"userID\": \"0000\",\"status\":\"Test\", \"vnf-type\" : \"DesigTest-VNF\", \"action\" : \"Configure\", \"artifact-name\":\"DesignRestArtifact_reference\",\"artifact-version\" :\"0.01\",\"artifact-type\" :\"DESIGNTOOL-TEST\",\"artifact-status\":\"\",\"artifact-contents\":  "+ content + " } ";
+            DesignDBService design = DesignDBService.initialise();
+            Whitebox.invokeMethod(design, "createArtifactTrackingRecord",payload,"0",1,1);
+        } catch (Exception e) {
+        }
+    }
+}
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDbResponse.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDbResponse.java
new file mode 100644 (file)
index 0000000..b8ae125
--- /dev/null
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ * 
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.design.validator;
+
+import java.util.ArrayList;
+import org.junit.Test;
+import org.openecomp.appc.design.dbervices.DbResponseProcessor;
+
+public class TestDbResponse {
+
+    @Test
+    public void testDbResponse() {
+        DbResponseProcessor dbResponse = new DbResponseProcessor();
+        try {
+            dbResponse.parseResponse("Test", "getDesigns");
+            dbResponse.parseResponse("Test", "addInCart");
+            dbResponse.parseResponse("Test", "getArtifactReference");
+            dbResponse.parseResponse("Test", "getArtifact");
+            dbResponse.parseResponse("Test", "getGUIReference");
+            dbResponse.parseResponse("Test", "getStatus");
+            dbResponse.parseResponse("Test", "uploadArtifact");
+            dbResponse.parseResponse("Test", "setProtocolReference");
+            dbResponse.parseResponse("Test", "setInCart");
+            dbResponse.parseResponse("Test", "getStatus");
+            dbResponse.parseResponse("Test", "Test");
+        } catch (Exception e) {
+        }
+    }
+}
index 4d46a0e..1a82ecd 100644 (file)
@@ -26,91 +26,77 @@ package org.openecomp.appc.design.validator;
 
 import java.util.ArrayList;
 import java.util.List;
-
-import org.junit.Rule;
 import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev170627.DbserviceInput;
 import org.openecomp.appc.design.data.ArtifactInfo;
 import org.openecomp.appc.design.data.DesignInfo;
 import org.openecomp.appc.design.data.DesignRequest;
 import org.openecomp.appc.design.data.DesignResponse;
 import org.openecomp.appc.design.data.StatusInfo;
-import org.openecomp.appc.design.dbervices.DbResponseProcessor;
-import org.openecomp.appc.design.dbervices.DbService;
-import org.openecomp.appc.design.services.impl.DesignServicesImpl;
-import org.openecomp.sdnc.sli.resource.dblib.DbLibService;
 
 public class TestDesigndata {
-       
-       
-               
-       DesignResponse dr = new DesignResponse();
-       
-       
-       
-       @Test
-       public void testSetUserID(){
-               
-                dr.setUserId("00000");
-                
-                String str = dr.getUserId();
-                System.out.println(str);
-       }
-       
-       @Test
-       public void testSetDesignInfoList(){
-               DesignInfo di = new DesignInfo();
-               List<DesignInfo> li = new ArrayList<DesignInfo>();
-               di.setAction("TestAction");
-               di.setArtifact_name("TestName");
-               di.setArtifact_type("TestType");
-               di.setInCart("TestCart");
-               di.setProtocol("TestProtocol");
-               di.setVnf_type("TestVNF");
-               di.setVnfc_type("TestVNFC");
-               li.add(di);
-               dr.setDesignInfoList(li);
-               System.out.println(dr.getDesignInfoList());
-       }
-       
-       @Test
-       public void testSetArtifactInfo(){
-               ArtifactInfo ai = new ArtifactInfo();
-               List<ArtifactInfo> li = new ArrayList<ArtifactInfo>();
-               ai.setArtifact_content("TestContent");
-               li.add(ai);
-               dr.setArtifactInfo(li);
-               System.out.println(dr.getArtifactInfo());
-               
-       }
-       @Test
-       public void testStatusInfo(){
-               StatusInfo si = new StatusInfo();
-               List<StatusInfo> li = new ArrayList<StatusInfo>();
-               si.setAction("TestAction");
-               si.setAction_status("TestActionStatus");
-               si.setArtifact_status("TestArtifactStatus");
-               si.setVnf_type("TestVNF");
-               si.setVnfc_type("TestVNFC");
-               li.add(si);
-               dr.setStatusInfoList(li);
-               System.out.println(dr.getStatusInfoList());
-       }
-       @Test
-       public void testDesignRequest(){
-               DesignRequest dreq = new DesignRequest();
-               dreq.setAction("TestAction");
-               dreq.setArtifact_contents("TestContent");
-               dreq.setArtifact_name("TestName");
-               dreq.setProtocol("TestProtocol");
-               dreq.setUserId("0000");
-               dreq.setVnf_type("testvnf");
-               dreq.setVnfc_type("testvnfc");
-               System.out.println(dreq.getAction() + dreq.getArtifact_contents() + dreq.getArtifact_name() + dreq.getProtocol() + dreq.getUserId() + dreq.getVnf_type()+ dreq.getVnfc_type());
-       System.out.println(dreq.toString());
-       }
-       
 
+    DesignResponse dr = new DesignResponse();
+
+    @Test
+    public void testSetUserID() {
+        dr.setUserId("00000");
+        dr.getUserId();
+    }
+
+    @Test
+    public void testSetDesignInfoList() {
+        DesignInfo di = new DesignInfo();
+        List<DesignInfo> li = new ArrayList<DesignInfo>();
+        di.setAction("TestAction");
+        di.setArtifact_name("TestName");
+        di.setArtifact_type("TestType");
+        di.setInCart("TestCart");
+        di.setProtocol("TestProtocol");
+        di.setVnf_type("TestVNF");
+        di.setVnfc_type("TestVNFC");
+        li.add(di);
+        dr.setDesignInfoList(li);
+    }
+
+    @Test
+    public void testSetArtifactInfo() {
+        ArtifactInfo ai = new ArtifactInfo();
+        List<ArtifactInfo> li = new ArrayList<ArtifactInfo>();
+        ai.setArtifact_content("TestContent");
+        li.add(ai);
+        dr.setArtifactInfo(li);
+    }
+
+    @Test
+    public void testStatusInfo() {
+        StatusInfo si = new StatusInfo();
+        List<StatusInfo> li = new ArrayList<StatusInfo>();
+        si.setAction("TestAction");
+        si.setAction_status("TestActionStatus");
+        si.setArtifact_status("TestArtifactStatus");
+        si.setVnf_type("TestVNF");
+        si.setVnfc_type("TestVNFC");
+        li.add(si);
+        dr.setStatusInfoList(li);
+    }
+
+    @Test
+    public void testDesignRequest() {
+        DesignRequest dreq = new DesignRequest();
+        dreq.setAction("TestAction");
+        dreq.setArtifact_contents("TestContent");
+        dreq.setArtifact_name("TestName");
+        dreq.setProtocol("TestProtocol");
+        dreq.setUserId("0000");
+        dreq.setVnf_type("testvnf");
+        dreq.setVnfc_type("testvnfc");
+        dreq.getAction();
+        dreq.getArtifact_contents();
+        dreq.getArtifact_name();
+        dreq.getProtocol();
+        dreq.getUserId();
+        dreq.getVnf_type();
+        dreq.getVnfc_type();
+        dreq.toString();
+    }
 }
index e3c5c17..fc9a765 100644 (file)
@@ -1,19 +1,52 @@
-package org.openecomp.appc.design.validator;\r
-\r
-import org.junit.Test;\r
-import org.openecomp.appc.design.services.util.EscapeUtils;\r
-\r
-public class TestEscapeUtils {\r
-\r
-       @Test\r
-       public void EscapeUtils(){\r
-               \r
-               EscapeUtils escapeUtils = new EscapeUtils();\r
-               \r
-               String str = escapeUtils.escapeSql("\\'Test Data\\'");\r
-               \r
-               System.out.println(str);\r
-               \r
-               \r
-       }\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2017 Amdocs
+ * =============================================================================
+ * 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.
+ * 
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.design.validator;
+
+import java.io.IOException;
+import org.junit.Test;
+import org.openecomp.appc.design.services.util.EscapeUtils;
+import org.openecomp.appc.design.xinterface.XInterfaceService;
+import org.openecomp.appc.design.xinterface.XResponseProcessor;
+import junit.framework.Assert;
+
+public class TestEscapeUtils {
+
+    @Test
+    public void testEscapeUtils() {
+
+        EscapeUtils escapeUtils = new EscapeUtils();
+        String str = escapeUtils.escapeSql("\\'Test Data\\'");
+        assert (true);
+    }
+    
+    @Test
+    public void testXResponseProcessor(){
+        
+        XResponseProcessor xr = new XResponseProcessor();    
+        Object o = new Object();
+        xr.parseResponse(o, "Test");
+        Assert.assertEquals(null, null);
+    }    
+}
index 05aeb30..42741fa 100644 (file)
@@ -28,14 +28,12 @@ import java.io.InputStream;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Properties;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.openecomp.appc.design.services.util.DesignServiceConstants;
 import org.openecomp.sdnc.sli.SvcLogicContext;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-
 import junit.framework.Assert;
 
 public class TestValidatorService {
@@ -43,138 +41,90 @@ public class TestValidatorService {
 //Onap Migration    
 
     private final Logger logger = LoggerFactory.getLogger(TestValidatorService.class);
-@Test
-    public void testvalidXMLValidation() throws Exception {
+    @Test
+    public void testValidXMLValidation(){
         String response = null;
-        String xmlString = "<xml><configure>"
-                + "<operation>create</operation>"
-                + "<base>"
-                + "<request-information>"
-                + "<source>SDN-GP</source>"
-                + "</request-information>"
-                + "</base>" 
-                + "</configure>"
-                + "</xml>";
-        
+        String xmlString = "<xml><configure>" + "<operation>create</operation>" + "<base>" + "<request-information>"
+                + "<source>SDN-GP</source>" + "</request-information>" + "</base>" + "</configure>" + "</xml>";
+
         ValidatorService vs = new ValidatorService();
-        try{
-         response = vs.execute("", xmlString, "XML");
+        try {
+            response = vs.execute("", xmlString, "XML");
+        } catch (Exception e) {
         }
-        catch(Exception e){
-            System.out.println(e.getMessage());
-        }
-            
         Assert.assertEquals("success", response);
         
     }
     @Test
-    public void testInvalidXMLValidation() throws Exception {
+    public void testInvalidXMLValidation() {
         String response = null;
-        String xmlString = "<xml><configure>"
-                + "<operation>create</operation>"
-                + "<base>"
-                + "<request-information>"
-                + "<source>SDN-GP</source>"
-                + "</request-information>"
-                + "</configure>"
-                + "</xml>";
-        
+        String xmlString = "<xml><configure>" + "<operation>create</operation>" + "<base>" + "<request-information>"
+                + "<source>SDN-GP</source>" + "</request-information>" + "</configure>" + "</xml>";
+
         ValidatorService vs = new ValidatorService();
-        try{
-         response = vs.execute("", xmlString, "XML");
+        try {
+            response = vs.execute("", xmlString, "XML");
+        } catch (Exception e) {
         }
-        catch(Exception e){
-            System.out.println(e.getMessage());
-        }
-            
         Assert.assertEquals(null, response);
-        
     }
     @Test
-    public void testYAMLValidation() throws Exception {
+    public void testYAMLValidation() {
         String response = null;
         String YAMLString = "en:";
-            
-        
         ValidatorService vs = new ValidatorService();
-        try{
-         response = vs.execute("", YAMLString, "YAML");
+        try {
+            response = vs.execute("", YAMLString, "YAML");
+        } catch (Exception e) {
         }
-        catch(Exception e){
-            System.out.println(e.getMessage());
-            e.printStackTrace();
-        }
-            
         Assert.assertEquals("success", response);
-        
     }
     @Test
-    public void testInvalidYAMLValidation() throws Exception {
+    public void testInvalidYAMLValidation()  {
         String response = null;
         String YAMLString = "Test \n A:";
-            
-        
         ValidatorService vs = new ValidatorService();
-        try{
-         response = vs.execute("", YAMLString,"YAML");
-        }
-        catch(Exception e){
-            System.out.println(e.getMessage());
+        try {
+            response = vs.execute("", YAMLString, "YAML");
+        } catch (Exception e) {
         }
             
         Assert.assertEquals(null, response);
-        
     }
-    
-@Test
-    public void testJSONValidation() throws Exception {
+
+    @Test
+    public void testJSONValidation(){
         String response = null;
         String YAMLString = "{\"Test\": \"Test1\" }";
-            
-        
+
         ValidatorService vs = new ValidatorService();
-        try{
-         response = vs.execute("", YAMLString, "JSON");
+        try {
+            response = vs.execute("", YAMLString, "JSON");
+        } catch (Exception e) {
         }
-        catch(Exception e){
-            System.out.println(e.getMessage());
-        
-        }            
         Assert.assertEquals("success", response);
-        
     }
     @Test
-    public void testInvalidJSONValidation() throws Exception {
+    public void testInvalidJSONValidation(){
         String response = null;
         String YAMLString = "{\"Test\" \"Test1\" }";
-            
-        
         ValidatorService vs = new ValidatorService();
-        try{
-         response = vs.execute("", YAMLString, "JSON");
+        try {
+            response = vs.execute("", YAMLString, "JSON");
+        } catch (Exception e) {
         }
-        catch(Exception e){
-            System.out.println(e.getMessage());
-        
-        }            
         Assert.assertEquals(null, response);
-        
     }
     
     @Test
-    public void testainvalidvalidateVelocity() throws Exception {
+    public void testInvalidvalidateVelocity(){
         String response = null;
         String validateVelocity = "{\"Test\" \"Test1\" }";
-            
-        
         ValidatorService vs = new ValidatorService();
-        try{
-         response = vs.execute("", validateVelocity, "Velocity");
+        try {
+            response = vs.execute("", validateVelocity, "Velocity");
+        } catch (Exception e) {
         }
-        catch(Exception e){
-            System.out.println(e.getMessage());
-        
-        }            
         Assert.assertEquals(null, response);
         
     }