From 09e2242fd1b3258d299018e501c10f124e5b3104 Mon Sep 17 00:00:00 2001 From: Abhishek Patil Date: Wed, 12 Apr 2023 18:51:19 +0530 Subject: Code changes in BPMN infra for RAN Slice Use case New module so-bomn-moi is created. New bpmn flows : AssignRANNssiBB ActivateRANNssiBB ModifyRANNssiBB DeleteRANNssiBB Issue-ID: SO-4039 Signed-off-by: Patil Change-Id: Ifad4e0a65dc810a753d30123a84c08081bcfd987 --- .../bpmn/moi/tasks/AssignRANNssiBBTasksTest.java | 162 +++++++++++++++++++++ .../so/bpmn/moi/tasks/DeleteRANNssiBBTaskTest.java | 101 +++++++++++++ .../onap/so/bpmn/moi/tasks/EnrichGBBTaskTest.java | 41 ++++++ .../so/bpmn/moi/tasks/ModifyRANNssiBBTaskTest.java | 121 +++++++++++++++ 4 files changed, 425 insertions(+) create mode 100644 bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasksTest.java create mode 100644 bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTaskTest.java create mode 100644 bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTaskTest.java create mode 100644 bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTaskTest.java (limited to 'bpmn/so-bpmn-moi/src/test/java/org') diff --git a/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasksTest.java b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasksTest.java new file mode 100644 index 0000000000..aaf0b8901a --- /dev/null +++ b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/AssignRANNssiBBTasksTest.java @@ -0,0 +1,162 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.onap.so.bpmn.moi.tasks; + +import com.fasterxml.jackson.databind.ObjectMapper; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.onap.aai.domain.yang.Customer; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.ServiceSubscription; +import org.onap.aaiclient.client.aai.AAIRestClientImpl; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.moi.util.SliceProfileAaiToMoiMapperUtil; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.exception.ExceptionBuilder; +import java.util.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; + +@RunWith(MockitoJUnitRunner.Silent.class) + +public class AssignRANNssiBBTasksTest { + @Mock + protected InjectionHelper injectionHelper; + @Mock + protected ObjectMapper mapper = new ObjectMapper(); + @Mock + protected AAIRestClientImpl aaiRestClient = new AAIRestClientImpl(); + @Mock + protected SliceProfileAaiToMoiMapperUtil mapperUtil; + @Mock + GeneralBuildingBlock gBB; + @Mock + ServiceInstance serviceInstance; + @Mock + protected ExceptionBuilder exceptionUtil; + @Mock + AssignRANNssiBBTasks assignRANNssiBBTasks; + @Mock + private BuildingBlockExecution execution; + @Mock + private ModelInfoServiceInstance modelInfoServiceInstance; + @Mock + protected ExtractPojosForBB extractPojosForBBMock; + + + private String operationalState; + private String administrativeState; + + private String sliceProfileServiceInstanceId = "215"; + + private String serviceInstanceId = "123"; + + Customer customerA = new Customer(); + + @Mock + private AAIResourceUri allotedResourceURI; + String serviceType; + + String globalCustomerId; + + private UUID allottedResourceUuidUuid = UUID.randomUUID(); + + @Rule + public final ExpectedException exception = ExpectedException.none(); + private ServiceSubscription serviceSubscription; + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + + @Before + public void before() throws BBObjectNotFoundException { + + serviceInstance.setServiceInstanceId("123"); + modelInfoServiceInstance.setModelUuid("235"); + ServiceInstance serviceInstance = new ServiceInstance(); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.SERVICE_INSTANCE_ID))) + .thenReturn(serviceInstanceId); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ServiceInstance))).thenReturn(serviceInstance); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ModelInfoServiceInstance))) + .thenReturn(modelInfoServiceInstance); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.operationalState))).thenReturn(operationalState); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.administrativeState))) + .thenReturn(administrativeState); + serviceSubscription = new ServiceSubscription(); + serviceSubscription.setServiceType(serviceType); + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil) + .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); + } + + @Test + public void createNssiTest() throws Exception { + doNothing().when(assignRANNssiBBTasks).createNssi(execution); + assignRANNssiBBTasks.createNssi(execution); + verify(assignRANNssiBBTasks, times(1)).createNssi(execution); + System.out.println("sucess"); + } + + @Test + public void createSliceProfileInstanceTest() { + doNothing().when(assignRANNssiBBTasks).createSliceProfileInstance(execution); + assignRANNssiBBTasks.createSliceProfileInstance(execution); + verify(assignRANNssiBBTasks, times(1)).createSliceProfileInstance(execution); + System.out.println("sucess"); + } + + @Test + public void allotResourcesTest() { + doNothing().when(assignRANNssiBBTasks).allotResources(execution); + assignRANNssiBBTasks.allotResources(execution); + verify(assignRANNssiBBTasks, times(1)).allotResources(execution); + } + + @Test + public void addSliceProfileToNssiTest() { + doNothing().when(assignRANNssiBBTasks).addSliceProfileToNssi(execution); + assignRANNssiBBTasks.addSliceProfileToNssi(execution); + verify(assignRANNssiBBTasks, times(1)).addSliceProfileToNssi(execution); + System.out.println("sucess"); + } + + @Test + public void activateNssiTest() { + doNothing().when(assignRANNssiBBTasks).activateNssi(execution); + assignRANNssiBBTasks.activateNssi(execution); + verify(assignRANNssiBBTasks, times(1)).activateNssi(execution); + } + +} diff --git a/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTaskTest.java b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTaskTest.java new file mode 100644 index 0000000000..5dd0f340ba --- /dev/null +++ b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/DeleteRANNssiBBTaskTest.java @@ -0,0 +1,101 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.moi.tasks; + +import com.fasterxml.jackson.core.JsonProcessingException; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.ServiceSubscription; +import org.onap.aaiclient.client.aai.AAIRestClientImpl; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.exception.ExceptionBuilder; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; + +@RunWith(MockitoJUnitRunner.Silent.class) + +public class DeleteRANNssiBBTaskTest { + + @Mock + BuildingBlockExecution execution; + @Mock + ModelInfoServiceInstance modelInfoServiceInstance; + @Mock + protected ExtractPojosForBB extractPojosForBBMock; + @Mock + protected ExceptionBuilder exceptionUtil; + @Mock + ServiceInstance serviceInstance; + private String operationalState; + private String administrativeState; + private String serviceInstanceId = "123"; + + private String sliceProfileServiceInstanceId = "123"; + + private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl(); + + private GeneralBuildingBlock gBB = new GeneralBuildingBlock(); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + @Mock + DeleteRANNssiBBTask deleteRANNssiBBTask; + + @Before + public void before() throws BBObjectNotFoundException { + + serviceInstance.setServiceInstanceId("123"); + modelInfoServiceInstance.setModelUuid("231"); + ServiceInstance serviceInstance = new ServiceInstance(); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.SERVICE_INSTANCE_ID))) + .thenReturn(serviceInstanceId); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ServiceInstance))).thenReturn(serviceInstance); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ModelInfoServiceInstance))) + .thenReturn(modelInfoServiceInstance); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.operationalState))).thenReturn(operationalState); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.administrativeState))) + .thenReturn(administrativeState); + doThrow(new BpmnError("BPMN Error")).when(exceptionUtil) + .buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class)); + } + + @Test + public void deleteNssiTest() throws JsonProcessingException { + doNothing().when(deleteRANNssiBBTask).deleteNssi(execution); + deleteRANNssiBBTask.deleteNssi(execution); + verify(deleteRANNssiBBTask, times(1)).deleteNssi(execution); + + } +} diff --git a/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTaskTest.java b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTaskTest.java new file mode 100644 index 0000000000..b48bb8cdee --- /dev/null +++ b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/EnrichGBBTaskTest.java @@ -0,0 +1,41 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.bpmn.moi.tasks; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mock; +import static org.junit.Assert.*; + +public class EnrichGBBTaskTest { + @Mock + DelegateExecution execution; + + @Before + public void setUp() throws Exception {} + + @Test + public void prepareOofRequest() {} + + @Test + public void processOOFAsyncResponse() {} +} diff --git a/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTaskTest.java b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTaskTest.java new file mode 100644 index 0000000000..c946d3b56c --- /dev/null +++ b/bpmn/so-bpmn-moi/src/test/java/org/onap/so/bpmn/moi/tasks/ModifyRANNssiBBTaskTest.java @@ -0,0 +1,121 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (c) 2022 Deutsche telekom + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + + +package org.onap.so.bpmn.moi.tasks; + +import com.fasterxml.jackson.core.JsonProcessingException; +import junit.framework.TestCase; +import org.camunda.bpm.engine.delegate.BpmnError; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.mockito.junit.MockitoJUnitRunner; +import org.onap.aai.domain.yang.ServiceInstance; +import org.onap.aai.domain.yang.ServiceSubscription; +import org.onap.aai.domain.yang.SliceProfile; +import org.onap.aaiclient.client.aai.AAIRestClientImpl; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.so.bpmn.common.BuildingBlockExecution; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey; +import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance; +import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB; +import org.onap.so.client.exception.BBObjectNotFoundException; +import org.onap.so.client.exception.ExceptionBuilder; +import org.onap.so.db.catalog.beans.OrchestrationStatus; +import java.util.*; +import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; +import static org.mockito.Mockito.times; + +@RunWith(MockitoJUnitRunner.Silent.class) + +public class ModifyRANNssiBBTaskTest { + @Mock + BuildingBlockExecution execution; + @Mock + ServiceInstance serviceInstance; + @Mock + private AAIResourceUri allotedResourceURI; + private org.onap.aai.domain.yang.Customer customer = new org.onap.aai.domain.yang.Customer(); + @Mock + private ModelInfoServiceInstance modelInfoServiceInstance; + @Mock + protected ExtractPojosForBB extractPojosForBBMock; + + @Mock + protected InjectionHelper injectionHelper; + + private String operationalState = "ENABLED"; + private String administrativeState = "UNLOCKED"; + private String serviceInstanceId = "123"; + private ServiceSubscription serviceSubscription; + @Mock + protected ExceptionBuilder exceptionUtil; + String serviceType; + + private String sliceProfileServiceInstanceId = "123"; + + private AAIRestClientImpl aaiRestClient = new AAIRestClientImpl(); + + @Mock + private GeneralBuildingBlock gBB = new GeneralBuildingBlock(); + + @Rule + public ExpectedException expectedException = ExpectedException.none(); + @Mock + ModifyRANNssiBBTask modifyRANNssiBBTask = new ModifyRANNssiBBTask(); + + @Before + public void before() throws BBObjectNotFoundException { + serviceInstance.setServiceInstanceId("123"); + modelInfoServiceInstance.setModelUuid("235"); + ServiceInstance serviceInstance = new ServiceInstance(); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.SERVICE_INSTANCE_ID))) + .thenReturn(serviceInstanceId); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ServiceInstance))).thenReturn(serviceInstance); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.ModelInfoServiceInstance))) + .thenReturn(modelInfoServiceInstance); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.operationalState))).thenReturn(operationalState); + when(extractPojosForBBMock.extractByKey(any(), eq(ResourceKey.administrativeState))) + .thenReturn(administrativeState); + serviceSubscription = new ServiceSubscription(); + serviceSubscription.setServiceType(serviceType); + } + + @Test + public void modifyNssiTest() throws JsonProcessingException { + + doNothing().when(modifyRANNssiBBTask).modifyNssi(execution); + modifyRANNssiBBTask.modifyNssi(execution); + verify(modifyRANNssiBBTask, times(1)).modifyNssi(execution); + } +} + + -- cgit 1.2.3-korg