aboutsummaryrefslogtreecommitdiffstats
path: root/appc-inbound/appc-design-services/provider
diff options
context:
space:
mode:
Diffstat (limited to 'appc-inbound/appc-design-services/provider')
-rwxr-xr-xappc-inbound/appc-design-services/provider/pom.xml22
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestArifactHandlerClient.java59
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDBService.java48
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDesigndata.java116
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestEscapeUtils.java19
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java136
-rw-r--r--appc-inbound/appc-design-services/provider/src/test/resources/transactionModel.json19
7 files changed, 371 insertions, 48 deletions
diff --git a/appc-inbound/appc-design-services/provider/pom.xml b/appc-inbound/appc-design-services/provider/pom.xml
index 52878d833..9776ad820 100755
--- a/appc-inbound/appc-design-services/provider/pom.xml
+++ b/appc-inbound/appc-design-services/provider/pom.xml
@@ -28,6 +28,12 @@
<dependencies>
<dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>1.9.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.openecomp.appc</groupId>
<artifactId>appc-design-services-model</artifactId>
</dependency>
@@ -124,5 +130,21 @@
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-javaagent</artifactId>
+ <version>1.6.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4-rule-agent</artifactId>
+ <version>1.6.5</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito-common</artifactId>
+ <version>1.6.5</version>
+ </dependency>
</dependencies>
</project>
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestArifactHandlerClient.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestArifactHandlerClient.java
new file mode 100644
index 000000000..bc0720eff
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestArifactHandlerClient.java
@@ -0,0 +1,59 @@
+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);
+ System.out.println(value);
+ Assert.assertTrue(!value.isEmpty());;
+
+
+ }catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+
+
+ @Test
+ public void testExecute() throws Exception{
+ 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 = "Test_Configure";
+
+ ArtifactHandlerClient ahi = new ArtifactHandlerClient();
+ ahi.execute(payload, rpc);
+ }catch(Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
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
deleted file mode 100644
index 81a620afa..000000000
--- a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDBService.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * ============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.Enumeration;
-import java.util.HashMap;
-import java.util.Properties;
-
-import org.apache.commons.io.FileUtils;
-import org.junit.Before;
-import org.junit.Test;
-import org.openecomp.appc.design.dbervices.DesignDBService;
-import org.openecomp.appc.design.services.util.DesignServiceConstants;
-import org.openecomp.appc.design.services.util.EscapeUtils;
-import org.openecomp.sdnc.sli.SvcLogicContext;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import junit.framework.Assert;
-
-public class TestDBService {
-
-//Onap Migration
-}
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDesigndata.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDesigndata.java
new file mode 100644
index 000000000..4d46a0e45
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestDesigndata.java
@@ -0,0 +1,116 @@
+/*-
+ * ============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 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());
+ }
+
+
+}
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestEscapeUtils.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestEscapeUtils.java
new file mode 100644
index 000000000..e3c5c17f4
--- /dev/null
+++ b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestEscapeUtils.java
@@ -0,0 +1,19 @@
+package org.openecomp.appc.design.validator;
+
+import org.junit.Test;
+import org.openecomp.appc.design.services.util.EscapeUtils;
+
+public class TestEscapeUtils {
+
+ @Test
+ public void EscapeUtils(){
+
+ EscapeUtils escapeUtils = new EscapeUtils();
+
+ String str = escapeUtils.escapeSql("\\'Test Data\\'");
+
+ System.out.println(str);
+
+
+ }
+}
diff --git a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java
index 1757c3c94..05aeb3008 100644
--- a/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java
+++ b/appc-inbound/appc-design-services/provider/src/test/java/org/openecomp/appc/design/validator/TestValidatorService.java
@@ -42,4 +42,140 @@ public class TestValidatorService {
//Onap Migration
+ private final Logger logger = LoggerFactory.getLogger(TestValidatorService.class);
+@Test
+ public void testvalidXMLValidation() throws Exception {
+ String response = null;
+ 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");
+ }
+ catch(Exception e){
+ System.out.println(e.getMessage());
+ }
+
+ Assert.assertEquals("success", response);
+
+ }
+ @Test
+ public void testInvalidXMLValidation() throws Exception {
+ String response = null;
+ 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");
+ }
+ catch(Exception e){
+ System.out.println(e.getMessage());
+ }
+
+ Assert.assertEquals(null, response);
+
+ }
+ @Test
+ public void testYAMLValidation() throws Exception {
+ String response = null;
+ String YAMLString = "en:";
+
+
+ ValidatorService vs = new ValidatorService();
+ try{
+ response = vs.execute("", YAMLString, "YAML");
+ }
+ catch(Exception e){
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+
+ Assert.assertEquals("success", response);
+
+ }
+ @Test
+ public void testInvalidYAMLValidation() throws Exception {
+ 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());
+ }
+
+ Assert.assertEquals(null, response);
+
+ }
+
+@Test
+ public void testJSONValidation() throws Exception {
+ String response = null;
+ String YAMLString = "{\"Test\": \"Test1\" }";
+
+
+ ValidatorService vs = new ValidatorService();
+ try{
+ response = vs.execute("", YAMLString, "JSON");
+ }
+ catch(Exception e){
+ System.out.println(e.getMessage());
+
+ }
+ Assert.assertEquals("success", response);
+
+ }
+ @Test
+ public void testInvalidJSONValidation() throws Exception {
+ String response = null;
+ String YAMLString = "{\"Test\" \"Test1\" }";
+
+
+ ValidatorService vs = new ValidatorService();
+ try{
+ response = vs.execute("", YAMLString, "JSON");
+ }
+ catch(Exception e){
+ System.out.println(e.getMessage());
+
+ }
+ Assert.assertEquals(null, response);
+
+ }
+
+ @Test
+ public void testainvalidvalidateVelocity() throws Exception {
+ String response = null;
+ String validateVelocity = "{\"Test\" \"Test1\" }";
+
+
+ ValidatorService vs = new ValidatorService();
+ try{
+ response = vs.execute("", validateVelocity, "Velocity");
+ }
+ catch(Exception e){
+ System.out.println(e.getMessage());
+
+ }
+ Assert.assertEquals(null, response);
+
+ }
}
diff --git a/appc-inbound/appc-design-services/provider/src/test/resources/transactionModel.json b/appc-inbound/appc-design-services/provider/src/test/resources/transactionModel.json
index e69de29bb..a82eaf0f1 100644
--- a/appc-inbound/appc-design-services/provider/src/test/resources/transactionModel.json
+++ b/appc-inbound/appc-design-services/provider/src/test/resources/transactionModel.json
@@ -0,0 +1,19 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 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=========================================================
+ */