2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.openecomp.mso.adapters.vnf;
24 import java.util.HashMap;
27 import javax.xml.ws.Holder;
29 import org.junit.Test;
30 import org.openecomp.mso.adapters.vnf.exceptions.VnfException;
31 import org.openecomp.mso.entity.MsoRequest;
32 import org.openecomp.mso.openstack.beans.VnfRollback;
34 public class MsoVnfPluginAdapterImplTest {
36 @Test(expected = NullPointerException.class)
37 public void queryVnfNullPointerExceptionTest() throws Exception {
38 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
39 MsoRequest msoRequest = new MsoRequest();
40 msoRequest.setRequestId("12345");
41 msoRequest.setServiceInstanceId("12345");
43 instance.queryVnf("siteid", "1234", "vfname",
44 msoRequest, new Holder<>(), new Holder<>(), new Holder<>(),
48 @Test(expected = VnfException.class)
49 public void deleteVnfVnfExceptionTest() throws Exception {
50 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
51 MsoRequest msoRequest = new MsoRequest();
52 msoRequest.setRequestId("12345");
53 msoRequest.setServiceInstanceId("12345");
55 instance.deleteVnf("12344", "234", "vnfname", msoRequest);
60 public void rollbackVnf() throws Exception {
61 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
62 MsoRequest msoRequest = new MsoRequest();
63 msoRequest.setRequestId("12345");
64 msoRequest.setServiceInstanceId("12345");
66 VnfRollback vnfRollback = new VnfRollback();
67 vnfRollback.setModelCustomizationUuid("1234");
68 vnfRollback.setVfModuleStackId("2134");
69 vnfRollback.setVnfId("123");
70 vnfRollback.setModelCustomizationUuid("1234");
72 instance.rollbackVnf(vnfRollback);
75 @Test(expected = VnfException.class)
76 public void createVfModuleVnfException() throws Exception {
77 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
78 MsoRequest msoRequest = new MsoRequest();
79 msoRequest.setRequestId("12345");
80 msoRequest.setServiceInstanceId("12345");
82 instance.createVfModule("123", "123", "vf", "v1", "module-005", "create", "3245", "234", "123", new HashMap<>(), true, true, msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
85 @Test(expected = VnfException.class)
86 public void updateVfModuleVnfException() throws Exception {
87 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
88 MsoRequest msoRequest = new MsoRequest();
89 msoRequest.setRequestId("12345");
90 msoRequest.setServiceInstanceId("12345");
92 instance.updateVfModule("123", "1234", "fw", "v2", "vnf1", "create", "123", "12", "233", "234", new HashMap<>(), msoRequest, new Holder<>(), new Holder<>());
96 public void healthCheckVNFTest() {
97 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
98 instance.healthCheck();
102 public void createVnfTest() {
103 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
104 MsoRequest msoRequest = new MsoRequest();
105 msoRequest.setRequestId("12345");
106 msoRequest.setServiceInstanceId("12345");
108 Map<String, String> map = new HashMap<>();
109 map.put("key1", "value1");
111 instance.createVnf("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
112 "volumeGroupHeatStackId|1", map,
113 Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<>(),
115 } catch (Exception e) {
120 public void updateVnfTest() {
121 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
122 MsoRequest msoRequest = new MsoRequest();
123 msoRequest.setRequestId("12345");
124 msoRequest.setServiceInstanceId("12345");
126 Map<String, String> map = new HashMap<>();
128 map.put("key1", "value1");
130 instance.updateVnf("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
131 "volumeGroupHeatStackId|1", map, msoRequest, new Holder<>(),
133 } catch (Exception e) {
139 public void deleteVnfTest() {
140 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
141 MsoRequest msoRequest = new MsoRequest();
142 msoRequest.setRequestId("12345");
143 msoRequest.setServiceInstanceId("12345");
145 instance.deleteVnf("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest);
146 } catch (Exception e) {