2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.apihandlerinfra;
23 import static org.junit.Assert.assertTrue;
27 import org.apache.http.HttpResponse;
28 import org.apache.http.ProtocolVersion;
29 import org.apache.http.client.ClientProtocolException;
30 import org.apache.http.entity.BasicHttpEntity;
31 import org.apache.http.message.BasicHttpResponse;
32 import org.junit.AfterClass;
33 import org.junit.BeforeClass;
34 import org.junit.Test;
35 import org.openecomp.mso.apihandler.common.CamundaClient;
36 import org.openecomp.mso.apihandlerinfra.volumebeans.ActionType;
37 import org.openecomp.mso.apihandlerinfra.volumebeans.RequestStatusType;
38 import org.openecomp.mso.apihandlerinfra.volumebeans.VolumeRequest;
39 import org.openecomp.mso.db.catalog.CatalogDatabase;
40 import org.openecomp.mso.db.catalog.beans.NetworkRecipe;
41 import org.openecomp.mso.db.catalog.beans.VfModule;
42 import org.openecomp.mso.db.catalog.beans.VnfResource;
43 import org.openecomp.mso.properties.MsoPropertiesFactory;
44 import org.openecomp.mso.requestsdb.InfraActiveRequests;
45 import org.openecomp.mso.requestsdb.InfraRequests;
46 import org.openecomp.mso.requestsdb.RequestsDatabase;
48 import javax.ws.rs.core.Response;
49 import java.io.ByteArrayInputStream;
50 import java.io.IOException;
51 import java.io.InputStream;
52 import java.sql.Timestamp;
53 import java.time.LocalDateTime;
54 import java.util.Collections;
55 import java.util.List;
57 public class VolumeInfoHandlerTest {
59 VolumeInfoHandler handler = new VolumeInfoHandler();
61 private static MockUp<RequestsDatabase> mockRDB;
64 public static void setUp() throws Exception {
65 MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
66 msoPropertiesFactory.removeAllMsoProperties();
67 msoPropertiesFactory.initializeMsoProperties(Constants.MSO_PROP_APIHANDLER_INFRA, "src/test/resources/mso.apihandler-infra.properties");
69 mockRDB = new MockUp<RequestsDatabase>() {
71 public List<InfraActiveRequests> getRequestListFromInfraActive (String queryAttributeName,
74 final InfraActiveRequests requests = new InfraActiveRequests();
75 requests.setAction(ActionType.CREATE.name());
76 requests.setRequestStatus(RequestStatusType.IN_PROGRESS.name());
77 requests.setStartTime(Timestamp.valueOf(LocalDateTime.now()));
78 return Collections.singletonList(requests);
81 public InfraActiveRequests getRequestFromInfraActive (String requestId, String requestType) {
82 final InfraActiveRequests requests = new InfraActiveRequests();
83 requests.setAction(ActionType.CREATE.name());
84 requests.setRequestStatus(RequestStatusType.IN_PROGRESS.name());
85 requests.setStartTime(Timestamp.valueOf(LocalDateTime.now()));
93 public static void tearDown() {
98 public void fillVnfRequestTestV3(){
99 VolumeRequest qr = new VolumeRequest();
100 InfraRequests ar = new InfraRequests();
101 ar.setVnfId("2990102");
102 ar.setVnfParams("test");
103 handler.fillVolumeRequest(qr, ar, "v3");
104 String vnfid = (String)qr.getVolumeParams();
105 assertTrue(vnfid.equals("test"));
109 public void fillVnfRequestTestV2(){
110 VolumeRequest qr = new VolumeRequest();
111 InfraRequests ar = new InfraRequests();
112 ar.setVnfId("2990102");
113 ar.setVnfParams("test");
114 handler.fillVolumeRequest(qr, ar, "v2");
115 String vnfid = (String)qr.getVolumeParams();
116 assertTrue(vnfid.equals("test"));
120 public void queryFilters() {
121 final Response response = handler.queryFilters("vnf-type", "svc-type", "aicNode", "tenant-id",
122 "vg-id", "vg-name", "v3");
126 public void queryFilters2() {
127 final Response response = handler.queryFilters(null, "svc-type", "aicNode", "tenant-id",
128 "vg-id", "vg-name", "v3");
132 public void getRequest() {
133 final Response response = handler.getRequest("request-id", "v3");