Merge 'origin/casablanca' into master
[so.git] / bpmn / so-bpmn-tasks / src / test / java / org / onap / so / client / orchestration / SDNCConfigurationResourcesTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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
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.client.orchestration;
22
23 import static org.junit.Assert.assertNotNull;
24 import static org.mockito.ArgumentMatchers.any;
25 import static org.mockito.ArgumentMatchers.isA;
26 import static org.mockito.Mockito.doReturn;
27 import static org.mockito.Mockito.times;
28 import static org.mockito.Mockito.verify;
29
30 import java.net.URI;
31 import java.net.URISyntaxException;
32
33 import org.junit.Before;
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.mockito.InjectMocks;
37 import org.mockito.Mock;
38 import org.mockito.Mockito;
39 import org.mockito.Spy;
40 import org.mockito.junit.MockitoJUnitRunner;
41 import org.onap.so.bpmn.common.data.TestDataSetup;
42 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
43 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
44 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
45 import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink;
46 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
47 import org.onap.so.client.exception.BadResponseException;
48 import org.onap.so.client.exception.MapperException;
49 import org.onap.so.client.sdnc.SDNCClient;
50 import org.onap.so.client.sdnc.endpoint.SDNCTopology;
51 import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper;
52
53 import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation;
54
55 @RunWith(MockitoJUnitRunner.Silent.class)
56 public class SDNCConfigurationResourcesTest extends TestDataSetup{
57         
58         @InjectMocks
59     private SDNCConfigurationResources sdncConfigurationResources = new SDNCConfigurationResources();
60         
61         @Spy
62         GCTopologyOperationRequestMapper MOCK_gcTopologyMapper ;
63         
64         @Mock
65         protected SDNCClient MOCK_sdncClient;
66         
67     private RequestContext requestContext;
68     private ServiceInstance serviceInstance;
69     private VpnBondingLink vpnBondingLink;
70     private GenericVnf vnf;
71     private Customer customer;
72
73     @Before
74     public void setUp(){
75         customer = buildCustomer();
76         requestContext = buildRequestContext();
77         serviceInstance = buildServiceInstance();
78         vpnBondingLink = buildVpnBondingLink();  
79         vnf = vpnBondingLink.getInfrastructureServiceProxy().getServiceInstance().getVnfs().get(0);
80     }
81
82     @Test
83     public void activateVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException {
84         GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.activateVnrConfiguration(serviceInstance,requestContext,customer,vpnBondingLink.getVnrConfiguration(),vnf,"uuid",new URI("http://localhost"));       
85         assertNotNull(response);
86     }
87
88     @Test
89     public void assignVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException {
90         GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.assignVnrConfiguration(serviceInstance,requestContext,customer,vpnBondingLink.getVnrConfiguration(),vnf,"uuid",new URI("http://localhost"));    
91         assertNotNull(response);
92     }
93
94     @Test
95     public void unAssignVnrConfigurationTest() throws BadResponseException, MapperException , URISyntaxException{
96         GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.unAssignVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration(),"uuid",new URI("http://localhost"));
97         assertNotNull(response);
98     }
99
100     @Test
101     public void deactivateVnrConfigurationTest() throws BadResponseException, MapperException , URISyntaxException{
102         GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.deactivateVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration(),"uuid",new URI("http://localhost"));      
103         assertNotNull(response);
104     }
105 }