002306694974271238a5c0333d7f35871645c3bb
[so.git] /
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.eq;
26 import static org.mockito.Mockito.verify;
27
28 import java.net.URI;
29 import java.net.URISyntaxException;
30
31 import org.junit.Before;
32 import org.junit.Test;
33 import org.junit.runner.RunWith;
34 import org.mockito.InjectMocks;
35 import org.mockito.Mock;
36 import org.mockito.junit.MockitoJUnitRunner;
37 import org.onap.sdnc.northbound.client.model.GenericResourceApiGcTopologyOperationInformation;
38 import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration;
39 import org.onap.so.bpmn.common.data.TestDataSetup;
40 import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
41 import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
42 import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
43 import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance;
44 import org.onap.so.bpmn.servicedecomposition.bbobjects.VpnBondingLink;
45 import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
46 import org.onap.so.client.exception.BadResponseException;
47 import org.onap.so.client.exception.MapperException;
48 import org.onap.so.client.sdnc.SDNCClient;
49 import org.onap.so.client.sdnc.beans.SDNCSvcAction;
50 import org.onap.so.client.sdnc.mapper.GCTopologyOperationRequestMapper;
51
52 @RunWith(MockitoJUnitRunner.Silent.class)
53 public class SDNCConfigurationResourcesTest extends TestDataSetup{
54         
55         @InjectMocks
56     private SDNCConfigurationResources sdncConfigurationResources = new SDNCConfigurationResources();
57         
58         @Mock
59         private GCTopologyOperationRequestMapper MOCK_gcTopologyMapper ;
60         
61         @Mock
62         protected SDNCClient MOCK_sdncClient;
63         
64     private RequestContext requestContext;
65     private ServiceInstance serviceInstance;
66     private VpnBondingLink vpnBondingLink;
67     private GenericVnf vnf;
68     private Customer customer;
69
70     @Before
71     public void setUp(){
72         customer = buildCustomer();
73         requestContext = buildRequestContext();
74         serviceInstance = buildServiceInstance();
75         vpnBondingLink = buildVpnBondingLink();  
76         vnf = vpnBondingLink.getInfrastructureServiceProxy().getServiceInstance().getVnfs().get(0);
77     }
78
79     @Test
80     public void activateVnrConfigurationTest() throws BadResponseException, MapperException, URISyntaxException {
81         GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.activateVnrConfiguration(serviceInstance,requestContext,customer,vpnBondingLink.getVnrConfiguration(),vnf,"uuid",new URI("http://localhost"));       
82         verify(MOCK_gcTopologyMapper).assignOrActivateVnrReqMapper(
83                         eq(SDNCSvcAction.ACTIVATE), eq(GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE),
84                         eq(serviceInstance), eq(requestContext), eq(customer), any(Configuration.class), any(GenericVnf.class), any(String.class), any(URI.class));
85
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         verify(MOCK_gcTopologyMapper).assignOrActivateVnrReqMapper(
92                         eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATEGENERICCONFIGURATIONINSTANCE),
93                         eq(serviceInstance), eq(requestContext), eq(customer), any(Configuration.class), any(GenericVnf.class), any(String.class), any(URI.class));
94
95     }
96
97     @Test
98     public void unAssignVnrConfigurationTest() throws BadResponseException, MapperException , URISyntaxException{
99         GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.unAssignVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration(),"uuid",new URI("http://localhost"));
100         verify(MOCK_gcTopologyMapper).deactivateOrUnassignVnrReqMapper(
101                         eq(SDNCSvcAction.UNASSIGN), eq(serviceInstance), eq(requestContext), any(Configuration.class), any(String.class), any(URI.class));
102
103     }
104
105     @Test
106     public void deactivateVnrConfigurationTest() throws BadResponseException, MapperException , URISyntaxException{
107         GenericResourceApiGcTopologyOperationInformation response = sdncConfigurationResources.deactivateVnrConfiguration(serviceInstance,requestContext,vpnBondingLink.getVnrConfiguration(),"uuid",new URI("http://localhost"));      
108         verify(MOCK_gcTopologyMapper).deactivateOrUnassignVnrReqMapper(
109                         eq(SDNCSvcAction.DEACTIVATE), eq(serviceInstance), eq(requestContext), any(Configuration.class), any(String.class), any(URI.class));
110
111     }
112 }