2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.so.client.orchestration;
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;
29 import java.net.URISyntaxException;
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;
52 @RunWith(MockitoJUnitRunner.Silent.class)
53 public class SDNCConfigurationResourcesTest extends TestDataSetup{
56 private SDNCConfigurationResources sdncConfigurationResources = new SDNCConfigurationResources();
59 private GCTopologyOperationRequestMapper MOCK_gcTopologyMapper ;
62 protected SDNCClient MOCK_sdncClient;
64 private RequestContext requestContext;
65 private ServiceInstance serviceInstance;
66 private VpnBondingLink vpnBondingLink;
67 private GenericVnf vnf;
68 private Customer customer;
72 customer = buildCustomer();
73 requestContext = buildRequestContext();
74 serviceInstance = buildServiceInstance();
75 vpnBondingLink = buildVpnBondingLink();
76 vnf = vpnBondingLink.getInfrastructureServiceProxy().getServiceInstance().getVnfs().get(0);
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));
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));
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));
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));