98c1f185fe403e27634fea66c12a15170a681dfd
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / bpmn / infrastructure / flowspecific / tasks / UnassignVnfTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 - 2018 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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.onap.so.bpmn.infrastructure.flowspecific.tasks;
22
23 import static org.mockito.Matchers.eq;
24 import static org.mockito.Mockito.times;
25 import static org.mockito.Mockito.verify;
26
27 import org.camunda.bpm.engine.delegate.BpmnError;
28 import org.junit.Test;
29 import org.onap.so.bpmn.BaseTaskTest;
30 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
31 import org.onap.so.bpmn.servicedecomposition.bbobjects.InstanceGroup;
32 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoInstanceGroup;
33 import org.springframework.beans.factory.annotation.Autowired;
34
35 public class UnassignVnfTest extends BaseTaskTest{
36         @Autowired
37         private UnassignVnf unassignVnf;
38
39         @Test
40         public void deleteInstanceGroupsSunnyDayTest() throws Exception {
41                 GenericVnf genericVnf = setGenericVnf();
42                 
43                 ModelInfoInstanceGroup modelVnfc = new ModelInfoInstanceGroup();
44                 modelVnfc.setType("VNFC");
45                 
46                 InstanceGroup instanceGroup1 = new InstanceGroup();
47                 instanceGroup1.setId("test-001");
48                 instanceGroup1.setModelInfoInstanceGroup(modelVnfc);
49                 genericVnf.getInstanceGroups().add(instanceGroup1);
50                 
51                 InstanceGroup instanceGroup2 = new InstanceGroup();
52                 instanceGroup2.setId("test-002");
53                 instanceGroup2.setModelInfoInstanceGroup(modelVnfc);
54                 genericVnf.getInstanceGroups().add(instanceGroup2);
55                 
56                 unassignVnf.deleteInstanceGroups(execution);
57                 verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup1));
58                 verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(eq(instanceGroup2));    
59         }
60         
61         @Test
62         public void deletecreateVnfcInstanceGroupExceptionTest() throws Exception {
63                 expectedException.expect(BpmnError.class);
64                 
65                 unassignVnf.deleteInstanceGroups(execution);
66         }
67 }