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