2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Copyright (C) 2017 Amdocs
8 * =============================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
25 package org.openecomp.appc.design.validator;
28 import java.io.InputStream;
29 import java.util.ArrayList;
30 import java.util.Enumeration;
31 import java.util.Properties;
32 import org.apache.commons.io.FileUtils;
33 import org.junit.Before;
34 import org.junit.Ignore;
35 import org.junit.Test;
36 import org.openecomp.appc.design.dbervices.DbService;
37 import org.openecomp.appc.design.dbervices.DesignDBService;
38 import org.openecomp.appc.design.propertyServices.PropertyUpdateService;
39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory;
41 import junit.framework.Assert;
42 import org.powermock.reflect.Whitebox;
44 public class TestDBService {
46 private final org.slf4j.Logger logger = LoggerFactory.getLogger(TestDBService.class);
48 @Ignore("Test is taking 60 seconds")
50 public void testGetDesigns() {
52 String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\" }";
53 DesignDBService dbservice = DesignDBService.initialise();
54 dbservice.execute("getDesigns", payload, "1234");
55 } catch (Exception e) {
59 @Ignore("Test is taking 120 seconds")
61 public void testGetStatus() {
63 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
64 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 + " } ";
65 DesignDBService dbservice = DesignDBService.initialise();
66 DbService db = new DbService();
67 Whitebox.invokeMethod(db, "getDbLibService");
68 dbservice.execute("getStatus", payload, "1234");
69 } catch (Exception e) {
73 @Ignore("Test is taking 120 seconds")
75 public void testUploadArtifact() {
77 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
78 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 + " } ";
79 DesignDBService dbservice = DesignDBService.initialise();
80 DbService db = new DbService();
81 Whitebox.invokeMethod(db, "getDbLibService");
82 dbservice.execute("uploadArtifact", payload, "1234");
83 } catch (Exception e) {
87 @Ignore("Test is taking 120 seconds")
89 public void testGetArtifact() {
91 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
92 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 + " } ";
93 DesignDBService design = DesignDBService.initialise();
94 DbService db = new DbService();
95 Whitebox.invokeMethod(db, "getDbLibService");
96 design.execute("getArtifact", payload, "1234");
97 } catch (Exception e) {
101 @Ignore("Test is taking 120 seconds")
103 public void testSetIncart() {
105 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
106 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 + " } ";
107 DesignDBService design = DesignDBService.initialise();
108 DbService db = new DbService();
109 Whitebox.invokeMethod(db, "getDbLibService");
110 design.execute("setInCart", payload, "1234");
111 } catch (Exception e) {
115 @Ignore("Test is taking 120 seconds")
117 public void testSetProtocolReference() {
119 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
120 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 + " } ";
121 DesignDBService design = DesignDBService.initialise();
122 DbService db = new DbService();
123 Whitebox.invokeMethod(db, "getDbLibService");
124 design.execute("setProtocolReference", payload, "1234");
125 } catch (Exception e) {
129 @Ignore("Test is taking 120 seconds")
131 public void testSetStatus() {
133 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
134 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 + " } ";
135 DesignDBService design = DesignDBService.initialise();
136 DbService db = new DbService();
137 Whitebox.invokeMethod(db, "getDbLibService");
138 design.execute("setStatus", payload, "1234");
139 } catch (Exception e) {
143 @Ignore("Test is taking 120 seconds")
145 public void testGetArtifactReference() {
147 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
148 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 + " } ";
149 DesignDBService design = DesignDBService.initialise();
150 DbService db = new DbService();
151 Whitebox.invokeMethod(db, "getDbLibService");
152 design.execute("getArtifactReference", payload, "1234");
153 } catch (Exception e) {
157 @Ignore("Test is taking 120 seconds")
159 public void testGetGuiReference() {
161 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
162 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 + " } ";
163 DesignDBService design = DesignDBService.initialise();
164 DbService db = new DbService();
165 Whitebox.invokeMethod(db, "getDbLibService");
166 design.execute("getGuiReference", payload, "1234");
167 } catch (Exception e) {
172 public void testPropertyUpdateService() {
173 PropertyUpdateService ps = new PropertyUpdateService();
177 public void testLinkstatusRelationShip() {
179 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
180 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 + " } ";
181 DesignDBService design = DesignDBService.initialise();
182 Whitebox.invokeMethod(design, "linkstatusRelationShip", 1, 1, payload);
183 } catch (Exception e) {
188 public void testGetSDCReferenceID() {
191 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
192 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 + " } ";
193 DesignDBService design = DesignDBService.initialise();
194 Whitebox.invokeMethod(design, "getSDCReferenceID", payload);
195 } catch (Exception e) {
200 public void testGetDataFromActionStatus() {
202 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
203 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 + " } ";
204 DesignDBService design = DesignDBService.initialise();
205 Whitebox.invokeMethod(design, "getDataFromActionStatus", payload, "Test");
206 } catch (Exception e) {
211 public void testSetActionStatus() {
213 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
214 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 + " } ";
215 DesignDBService design = DesignDBService.initialise();
216 Whitebox.invokeMethod(design, "setActionStatus", payload, "Accepted");
217 } catch (Exception e) {
222 public void testGetSDCArtifactIDbyRequestID() {
224 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
225 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 + " } ";
226 DesignDBService design = DesignDBService.initialise();
227 Whitebox.invokeMethod(design, "getSDCArtifactIDbyRequestID", "0");
228 } catch (Exception e) {
233 public void testCreateArtifactTrackingRecord() {
235 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
236 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 + " } ";
237 DesignDBService design = DesignDBService.initialise();
238 Whitebox.invokeMethod(design, "createArtifactTrackingRecord",payload,"0",1,1);
239 } catch (Exception e) {