2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (c) 2022 Deutsche telekom
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=========================================================
22 package org.onap.so.bpmn.moi.tasks;
24 import com.fasterxml.jackson.core.JsonProcessingException;
25 import junit.framework.TestCase;
26 import org.camunda.bpm.engine.delegate.BpmnError;
27 import org.junit.Before;
28 import org.junit.Rule;
29 import org.junit.Test;
30 import org.junit.rules.ExpectedException;
31 import org.junit.runner.RunWith;
32 import org.mockito.Mock;
33 import org.mockito.junit.MockitoJUnitRunner;
34 import org.onap.aai.domain.yang.ServiceInstance;
35 import org.onap.aai.domain.yang.ServiceSubscription;
36 import org.onap.aai.domain.yang.SliceProfile;
37 import org.onap.aaiclient.client.aai.AAIRestClientImpl;
38 import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
39 import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory;
40 import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder;
41 import org.onap.so.bpmn.common.BuildingBlockExecution;
42 import org.onap.so.bpmn.common.InjectionHelper;
43 import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock;
44 import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
45 import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance;
46 import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
47 import org.onap.so.client.exception.BBObjectNotFoundException;
48 import org.onap.so.client.exception.ExceptionBuilder;
49 import org.onap.so.db.catalog.beans.OrchestrationStatus;
51 import static org.junit.Assert.*;
52 import static org.mockito.ArgumentMatchers.any;
53 import static org.mockito.ArgumentMatchers.eq;
54 import static org.mockito.Mockito.*;
55 import static org.mockito.Mockito.times;
57 @RunWith(MockitoJUnitRunner.Silent.class)
59 public class ModifyRANNssiBBTaskTest {
61 BuildingBlockExecution execution;
63 ServiceInstance serviceInstance;
65 private AAIResourceUri allotedResourceURI;
66 private org.onap.aai.domain.yang.Customer customer = new org.onap.aai.domain.yang.Customer();
68 private ModelInfoServiceInstance modelInfoServiceInstance;
70 protected ExtractPojosForBB extractPojosForBBMock;
73 protected InjectionHelper injectionHelper;
75 private String operationalState = "ENABLED";
76 private String administrativeState = "UNLOCKED";
77 private String serviceInstanceId = "123";
78 private ServiceSubscription serviceSubscription;
80 protected ExceptionBuilder exceptionUtil;
83 private String sliceProfileServiceInstanceId = "123";
85 private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl();
88 private GeneralBuildingBlock gBB = new GeneralBuildingBlock();
91 public ExpectedException expectedException = ExpectedException.none();
93 ModifyRANNssiBBTask modifyRANNssiBBTask = new ModifyRANNssiBBTask();
96 public void before() throws BBObjectNotFoundException {
97 serviceInstance.setServiceInstanceId("123");
98 modelInfoServiceInstance.setModelUuid("235");
99 ServiceInstance serviceInstance = new ServiceInstance();
100 when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.SERVICE_INSTANCE_ID)))
101 .thenReturn(serviceInstanceId);
102 when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ServiceInstance))).thenReturn(serviceInstance);
103 when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ModelInfoServiceInstance)))
104 .thenReturn(modelInfoServiceInstance);
105 when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.operationalState))).thenReturn(operationalState);
106 when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.administrativeState)))
107 .thenReturn(administrativeState);
108 serviceSubscription = new ServiceSubscription();
109 serviceSubscription.setServiceType(serviceType);
113 public void modifyNssiTest() throws JsonProcessingException {
115 doNothing().when(modifyRANNssiBBTask).modifyNssi(execution);
116 modifyRANNssiBBTask.modifyNssi(execution);
117 verify(modifyRANNssiBBTask, times(1)).modifyNssi(execution);