2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017-2018 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 * ============LICENSE_END=========================================================
24 package org.onap.appc.design.validator;
27 import java.io.InputStream;
28 import java.util.ArrayList;
29 import java.util.Enumeration;
30 import java.util.Properties;
31 import org.apache.commons.io.FileUtils;
32 import org.junit.Before;
33 import org.junit.Ignore;
34 import org.junit.Test;
35 import org.onap.appc.design.dbervices.DbService;
36 import org.onap.appc.design.dbervices.DesignDBService;
37 import org.onap.appc.design.propertyServices.PropertyUpdateService;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40 import junit.framework.Assert;
41 import org.powermock.reflect.Whitebox;
43 public class TestDBService {
45 private final org.slf4j.Logger logger = LoggerFactory.getLogger(TestDBService.class);
47 @Ignore("Test is taking 60 seconds")
49 public void testGetDesigns() {
51 String payload = "{\"userID\": \"0000\", \"vnf-type\" : \"DesigTest-VNF\" }";
52 DesignDBService dbservice = DesignDBService.initialise();
53 dbservice.execute("getDesigns", payload, "1234");
54 } catch (Exception e) {
58 @Ignore("Test is taking 120 seconds")
60 public void testGetStatus() {
62 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
63 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 + " } ";
64 DesignDBService dbservice = DesignDBService.initialise();
65 DbService db = new DbService();
66 Whitebox.invokeMethod(db, "getDbLibService");
67 dbservice.execute("getStatus", payload, "1234");
68 } catch (Exception e) {
72 @Ignore("Test is taking 120 seconds")
74 public void testUploadArtifact() {
76 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
77 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 + " } ";
78 DesignDBService dbservice = DesignDBService.initialise();
79 DbService db = new DbService();
80 Whitebox.invokeMethod(db, "getDbLibService");
81 dbservice.execute("uploadArtifact", payload, "1234");
82 } catch (Exception e) {
86 @Ignore("Test is taking 120 seconds")
88 public void testGetArtifact() {
90 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
91 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 + " } ";
92 DesignDBService design = DesignDBService.initialise();
93 DbService db = new DbService();
94 Whitebox.invokeMethod(db, "getDbLibService");
95 design.execute("getArtifact", payload, "1234");
96 } catch (Exception e) {
100 @Ignore("Test is taking 120 seconds")
102 public void testSetIncart() {
104 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
105 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 + " } ";
106 DesignDBService design = DesignDBService.initialise();
107 DbService db = new DbService();
108 Whitebox.invokeMethod(db, "getDbLibService");
109 design.execute("setInCart", payload, "1234");
110 } catch (Exception e) {
114 @Ignore("Test is taking 120 seconds")
116 public void testSetProtocolReference() {
118 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
119 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 + " } ";
120 DesignDBService design = DesignDBService.initialise();
121 DbService db = new DbService();
122 Whitebox.invokeMethod(db, "getDbLibService");
123 design.execute("setProtocolReference", payload, "1234");
124 } catch (Exception e) {
128 @Ignore("Test is taking 120 seconds")
130 public void testSetStatus() {
132 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
133 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 + " } ";
134 DesignDBService design = DesignDBService.initialise();
135 DbService db = new DbService();
136 Whitebox.invokeMethod(db, "getDbLibService");
137 design.execute("setStatus", payload, "1234");
138 } catch (Exception e) {
142 @Ignore("Test is taking 120 seconds")
144 public void testGetArtifactReference() {
146 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
147 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 + " } ";
148 DesignDBService design = DesignDBService.initialise();
149 DbService db = new DbService();
150 Whitebox.invokeMethod(db, "getDbLibService");
151 design.execute("getArtifactReference", payload, "1234");
152 } catch (Exception e) {
156 @Ignore("Test is taking 120 seconds")
158 public void testGetGuiReference() {
160 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
161 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 + " } ";
162 DesignDBService design = DesignDBService.initialise();
163 DbService db = new DbService();
164 Whitebox.invokeMethod(db, "getDbLibService");
165 design.execute("getGuiReference", payload, "1234");
166 } catch (Exception e) {
171 public void testPropertyUpdateService() {
172 PropertyUpdateService ps = new PropertyUpdateService();
176 public void testLinkstatusRelationShip() {
178 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
179 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 + " } ";
180 DesignDBService design = DesignDBService.initialise();
181 Whitebox.invokeMethod(design, "linkstatusRelationShip", 1, 1, payload);
182 } catch (Exception e) {
187 public void testGetSDCReferenceID() {
190 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
191 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 + " } ";
192 DesignDBService design = DesignDBService.initialise();
193 Whitebox.invokeMethod(design, "getSDCReferenceID", payload);
194 } catch (Exception e) {
199 public void testGetDataFromActionStatus() {
201 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
202 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 + " } ";
203 DesignDBService design = DesignDBService.initialise();
204 Whitebox.invokeMethod(design, "getDataFromActionStatus", payload, "Test");
205 } catch (Exception e) {
210 public void testSetActionStatus() {
212 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
213 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 + " } ";
214 DesignDBService design = DesignDBService.initialise();
215 Whitebox.invokeMethod(design, "setActionStatus", payload, "Accepted");
216 } catch (Exception e) {
221 public void testGetSDCArtifactIDbyRequestID() {
223 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
224 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 + " } ";
225 DesignDBService design = DesignDBService.initialise();
226 Whitebox.invokeMethod(design, "getSDCArtifactIDbyRequestID", "0");
227 } catch (Exception e) {
232 public void testCreateArtifactTrackingRecord() {
234 String content = FileUtils.readFileToString(new File("src/test/resources/uploadArtifact"));
235 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 + " } ";
236 DesignDBService design = DesignDBService.initialise();
237 Whitebox.invokeMethod(design, "createArtifactTrackingRecord",payload,"0",1,1);
238 } catch (Exception e) {