Merge "Reorder modifiers"
[so.git] / adapters / mso-vnf-adapter / src / test / java / org / openecomp / mso / adapters / vnf / MsoVnfPluginAdapterImplTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
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=========================================================
20  */
21
22 package org.openecomp.mso.adapters.vnf;
23
24 import java.util.HashMap;
25 import java.util.Map;
26
27 import javax.xml.ws.Holder;
28
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;
33
34 public class MsoVnfPluginAdapterImplTest {
35
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");
42
43         instance.queryVnf("siteid", "1234", "vfname",
44                 msoRequest, new Holder<>(), new Holder<>(), new Holder<>(),
45                 new Holder<>());
46     }
47
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");
54
55         instance.deleteVnf("12344", "234", "vnfname", msoRequest);
56
57     }
58
59         @Test
60         public void rollbackVnf() throws Exception {
61                 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
62                 MsoRequest msoRequest = new MsoRequest();
63                 msoRequest.setRequestId("12345");
64                 msoRequest.setServiceInstanceId("12345");
65
66         VnfRollback vnfRollback = new VnfRollback();
67         vnfRollback.setModelCustomizationUuid("1234");
68         vnfRollback.setVfModuleStackId("2134");
69         vnfRollback.setVnfId("123");
70         vnfRollback.setModelCustomizationUuid("1234");
71
72         instance.rollbackVnf(vnfRollback);
73         }
74
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");
81
82                 instance.createVfModule("123", "123", "vf", "v1", "module-005", "create", "3245", "234", "123", new HashMap<>(), true, true, msoRequest, new Holder<>(), new Holder<>(), new Holder<>());
83         }
84
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");
91
92                 instance.updateVfModule("123", "1234", "fw", "v2", "vnf1", "create", "123", "12", "233", "234", new HashMap<>(), msoRequest, new Holder<>(), new Holder<>());
93         }
94
95         @Test
96         public void healthCheckVNFTest() {
97                 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
98                 instance.healthCheck();
99         }
100
101         @Test
102         public void createVnfTest() {
103                 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
104                 MsoRequest msoRequest = new MsoRequest();
105                 msoRequest.setRequestId("12345");
106                 msoRequest.setServiceInstanceId("12345");
107
108                 Map<String, String> map = new HashMap<>();
109                 map.put("key1", "value1");
110                 try {
111                         instance.createVnf("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
112                                         "volumeGroupHeatStackId|1", map,
113                                         Boolean.FALSE, Boolean.TRUE, msoRequest, new Holder<>(), new Holder<>(),
114                 new Holder<>());
115                 } catch (Exception e) {
116                 }
117         }
118
119         @Test
120         public void updateVnfTest() {
121                 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
122                 MsoRequest msoRequest = new MsoRequest();
123                 msoRequest.setRequestId("12345");
124                 msoRequest.setServiceInstanceId("12345");
125
126                 Map<String, String> map = new HashMap<>();
127                 
128                 map.put("key1", "value1");
129                 try {
130                         instance.updateVnf("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vnf", "1", "vSAMP12", "VFMOD",
131                                         "volumeGroupHeatStackId|1",  map, msoRequest, new Holder<>(),
132                 new Holder<>());
133                 } catch (Exception e) {
134
135                 }
136         }
137
138         @Test
139         public void deleteVnfTest() {
140                 MsoVnfPluginAdapterImpl instance = new MsoVnfPluginAdapterImpl();
141                 MsoRequest msoRequest = new MsoRequest();
142                 msoRequest.setRequestId("12345");
143                 msoRequest.setServiceInstanceId("12345");
144                 try {
145                         instance.deleteVnf("mdt1", "88a6ca3ee0394ade9403f075db23167e", "vSAMP12", msoRequest);
146                 } catch (Exception e) {
147
148                 }
149         }
150
151 }