import org.glassfish.jersey.server.ResourceConfig;
import org.onap.logging.filter.base.Constants;
import org.onap.logging.filter.base.ONAPComponents;
+import org.onap.so.adapters.catalogdb.rest.BuildingBlockRollbackRestImpl;
import org.onap.so.adapters.catalogdb.rest.CatalogDbAdapterRest;
import org.onap.so.adapters.catalogdb.rest.ServiceRestImpl;
import org.onap.so.adapters.catalogdb.rest.VnfRestImpl;
register(AcceptHeaderOpenApiResource.class);
register(ServiceRestImpl.class);
register(VnfRestImpl.class);
+ register(BuildingBlockRollbackRestImpl.class);
OpenAPI oas = new OpenAPI();
Info info = new Info();
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Bell Canada
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb.rest;
+
+import io.swagger.v3.oas.annotations.OpenAPIDefinition;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.info.Info;
+import io.swagger.v3.oas.annotations.media.ArraySchema;
+import io.swagger.v3.oas.annotations.media.Content;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.responses.ApiResponse;
+import java.util.List;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import org.onap.so.db.catalog.beans.BuildingBlockRollback;
+import org.onap.so.db.catalog.data.repository.BuildingBlockRollbackRepository;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.transaction.annotation.Transactional;
+
+
+@OpenAPIDefinition(info = @Info(title = "/v1", description = "model"))
+@Path("/v1/buildingBlockRollback")
+@Component
+public class BuildingBlockRollbackRestImpl {
+
+ @Autowired
+ private BuildingBlockRollbackRepository bbRollbackRepo;
+
+ @GET
+ @Path("/{id}")
+ @Produces({MediaType.APPLICATION_JSON})
+ @Transactional(readOnly = true)
+ public BuildingBlockRollback findService(@PathParam("id") Integer id) {
+ return bbRollbackRepo.findOneById(id);
+ }
+
+ @GET
+ @Operation(description = "Look up BuildingBlock Rollback List", responses = @ApiResponse(
+ content = @Content(array = @ArraySchema(schema = @Schema(implementation = BuildingBlockRollback.class)))))
+ @Produces({MediaType.APPLICATION_JSON})
+ @Transactional(readOnly = true)
+ public List<BuildingBlockRollback> getBBRollbackList() {
+ return bbRollbackRepo.findAll();
+ }
+}
--- /dev/null
+use catalogdb;
+
+CREATE TABLE IF NOT EXISTS `building_block_rollback` (
+ `ID` INT NOT NULL AUTO_INCREMENT,
+ `BUILDING_BLOCK_NAME` varchar(200) NOT NULL,
+ `ACTION` varchar(200) null,
+ `ROLLBACK_BUILDING_BLOCK_NAME` varchar(200) NOT NULL,
+ `ROLLBACK_ACTION` varchar(200) NULL,
+ PRIMARY KEY (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
import org.onap.so.db.request.client.RequestsDbClient;
import org.springframework.core.env.Environment;
+// deprecated because of task SO-3772, this class will be deleted after all its usage is removed
+@Deprecated
@RunWith(MockitoJUnitRunner.Silent.class)
public abstract class BaseTaskTest extends TestDataSetup {
@Mock
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
-import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.common.InjectionHelper;
import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.aaiclient.client.aai.AAIResourcesClient;
-import org.onap.so.client.aai.mapper.AAIObjectMapper;
import org.onap.so.client.exception.BBObjectNotFoundException;
import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.client.orchestration.AAIVnfResources;
-import org.springframework.beans.factory.annotation.Autowired;
-
-
-public class AAIFlagTasksTest extends BaseTaskTest {
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class AAIFlagTasksTest extends TestDataSetup {
+ @Mock
+ protected AAIResourcesClient MOCK_aaiResourcesClient;
+ @Mock
+ protected InjectionHelper MOCK_injectionHelper;
+ @Mock
+ protected ExceptionBuilder exceptionUtil;
+ @Mock
+ protected AAIVnfResources aaiVnfResources;
+ @Mock
+ protected ExtractPojosForBB extractPojosForBBMock;
@InjectMocks
- private AAIFlagTasks aaiFlagTasks = new AAIFlagTasks();
-
- private GenericVnf genericVnf;
+ private AAIFlagTasks aaiFlagTasks;
@Before
public void before() throws BBObjectNotFoundException {
- genericVnf = setGenericVnf();
+ GenericVnf genericVnf = setGenericVnf();
doReturn(MOCK_aaiResourcesClient).when(MOCK_injectionHelper).getAaiClient();
- when(extractPojosForBB.extractByKey(any(), any())).thenReturn(genericVnf);
+ when(extractPojosForBBMock.extractByKey(any(), any())).thenReturn(genericVnf);
}
@Test
- public void checkVnfInMaintTestTrue() throws Exception {
+ public void checkVnfInMaintTestTrue() {
doThrow(new BpmnError("VNF is in maintenance in A&AI")).when(exceptionUtil)
.buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
doReturn(false).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
}
@Test
- public void checkVnfInMaintTestFalse() throws Exception {
+ public void checkVnfInMaintTestFalse() {
doReturn(false).when(aaiVnfResources).checkInMaintFlag(isA(String.class));
aaiFlagTasks.checkVnfInMaintFlag(execution);
verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class),
}
@Test
- public void modifyVnfInMaintFlagTest() throws Exception {
+ public void modifyVnfInMaintFlagTest() {
doNothing().when(aaiVnfResources).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
aaiFlagTasks.modifyVnfInMaintFlag(execution, true);
verify(aaiVnfResources, times(1)).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
}
@Test
- public void checkVnfClosedLoopDisabledTestTrue() throws Exception {
+ public void checkVnfClosedLoopDisabledTestTrue() {
doThrow(new BpmnError("VNF Closed Loop Disabled in A&AI")).when(exceptionUtil)
.buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(String.class));
doReturn(false).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
}
@Test
- public void checkVnfClosedLoopDisabledTestFalse() throws Exception {
+ public void checkVnfClosedLoopDisabledTestFalse() {
doReturn(false).when(aaiVnfResources).checkVnfClosedLoopDisabledFlag(isA(String.class));
aaiFlagTasks.checkVnfClosedLoopDisabledFlag(execution);
verify(exceptionUtil, times(0)).buildAndThrowWorkflowException(any(BuildingBlockExecution.class),
}
@Test
- public void modifyVnfClosedLoopDisabledFlagTest() throws Exception {
+ public void modifyVnfClosedLoopDisabledFlagTest() {
doNothing().when(aaiVnfResources).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
aaiFlagTasks.modifyVnfClosedLoopDisabledFlag(execution, true);
verify(aaiVnfResources, times(1)).updateObjectVnf(ArgumentMatchers.any(GenericVnf.class));
import java.util.Optional;
import java.util.TreeSet;
import java.util.stream.Collectors;
-import com.google.common.base.Strings;
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.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
import org.mockito.Captor;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
import org.mockito.Mockito;
-import org.onap.so.bpmn.BaseTaskTest;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer;
import org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule;
import org.onap.aaiclient.client.aai.entities.uri.AAIBaseResourceUri;
import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri;
+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.client.orchestration.AAIConfigurationResources;
+import org.onap.so.client.orchestration.AAIInstanceGroupResources;
+import org.onap.so.client.orchestration.AAINetworkResources;
+import org.onap.so.client.orchestration.AAIPnfResources;
+import org.onap.so.client.orchestration.AAIServiceInstanceResources;
+import org.onap.so.client.orchestration.AAIVfModuleResources;
+import org.onap.so.client.orchestration.AAIVnfResources;
+import org.onap.so.client.orchestration.AAIVolumeGroupResources;
+import org.onap.so.client.orchestration.AAIVpnBindingResources;
import org.onap.so.db.catalog.beans.OrchestrationStatus;
-
-public class AAICreateTasksTest extends BaseTaskTest {
-
+import org.springframework.core.env.Environment;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class AAICreateTasksTest extends TestDataSetup {
+
+ @Mock
+ protected ExceptionBuilder exceptionUtil;
+ @Mock
+ protected AAIServiceInstanceResources aaiServiceInstanceResources;
+ @Mock
+ protected AAIVolumeGroupResources aaiVolumeGroupResources;
+ @Mock
+ protected AAIVnfResources aaiVnfResources;
+ @Mock
+ protected AAINetworkResources aaiNetworkResources;
+ @Mock
+ protected AAIVfModuleResources aaiVfModuleResources;
+ @Mock
+ protected AAIPnfResources aaiPnfResources;
+ @Mock
+ protected AAIVpnBindingResources aaiVpnBindingResources;
+ @Mock
+ protected AAIInstanceGroupResources aaiInstanceGroupResources;
+ @Mock
+ protected AAIConfigurationResources aaiConfigurationResources;
+ @Mock
+ protected Environment env;
+ @Mock
+ protected ExtractPojosForBB extractPojosForBBMock;
@InjectMocks
- private AAICreateTasks aaiCreateTasks = new AAICreateTasks();
-
+ private AAICreateTasks aaiCreateTasks;
private ServiceInstance serviceInstance;
private L3Network network;
configuration = setConfiguration();
instanceGroup = setInstanceGroupVnf();
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
.thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID)))
+ .thenReturn(vfModule);
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID)))
+ .thenReturn(network);
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
.thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
.thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID)))
.thenReturn(configuration);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)))
.thenReturn(instanceGroup);
}
@Test
- public void createServiceInstanceTest() throws Exception {
+ public void createServiceInstanceTest() {
doReturn(false).when(aaiServiceInstanceResources).checkInstanceServiceNameInUse(serviceInstance);
doNothing().when(aaiServiceInstanceResources).createServiceInstance(serviceInstance, customer);
aaiCreateTasks.createServiceInstance(execution);
}
@Test
- public void createServiceInstanceExceptionTest() throws Exception {
+ public void createServiceInstanceExceptionTest() {
expectedException.expect(BpmnError.class);
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "notfound");
}
@Test
- public void createVolumeGroupTest() throws Exception {
+ public void createVolumeGroupTest() {
volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
execution.setVariable("aLaCarte", Boolean.FALSE);
doNothing().when(aaiVolumeGroupResources).createVolumeGroup(volumeGroup, cloudRegion);
}
@Test
- public void createVolumeGroupExceptionTest() throws Exception {
+ public void createVolumeGroupExceptionTest() {
expectedException.expect(BpmnError.class);
volumeGroup.setOrchestrationStatus(OrchestrationStatus.PRECREATED);
}
@Test
- public void createPlatformTest() throws Exception {
+ public void createPlatformTest() {
doNothing().when(aaiVnfResources).createPlatformandConnectVnf(genericVnf.getPlatform(), genericVnf);
aaiCreateTasks.createPlatform(execution);
ArgumentCaptor<Platform> platformCaptor = ArgumentCaptor.forClass(Platform.class);
}
@Test
- public void createPlatformNetworkTest() throws Exception {
+ public void createPlatformNetworkTest() {
doNothing().when(aaiNetworkResources).createPlatformAndConnectNetwork(network.getPlatform(), network);
aaiCreateTasks.createPlatformForNetwork(execution);
ArgumentCaptor<Platform> platformCaptor = ArgumentCaptor.forClass(Platform.class);
}
@Test
- public void createLineOfBusinessTest() throws Exception {
+ public void createLineOfBusinessTest() {
doNothing().when(aaiVnfResources).createLineOfBusinessandConnectVnf(genericVnf.getLineOfBusiness(), genericVnf);
aaiCreateTasks.createLineOfBusiness(execution);
}
@Test
- public void splitCDL_Test() throws Exception {
+ public void splitCDL_Test() {
List<String> strings = aaiCreateTasks.splitCDL("Test");
assertEquals(strings.get(0), "Test");
}
@Test
- public void createProjectExceptionTest() throws Exception {
+ public void createProjectExceptionTest() {
expectedException.expect(BpmnError.class);
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, "notfound");
}
@Test
- public void createProjectNullProjectNameTest() throws Exception {
+ public void createProjectNullProjectNameTest() {
serviceInstance.getProject().setProjectName(null);
doNothing().when(aaiServiceInstanceResources)
.createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
}
@Test
- public void createProjectEmptyProjectNameTest() throws Exception {
+ public void createProjectEmptyProjectNameTest() {
serviceInstance.getProject().setProjectName("");
doNothing().when(aaiServiceInstanceResources)
.createProjectandConnectServiceInstance(serviceInstance.getProject(), serviceInstance);
}
@Test
- public void createOwningEntityTest() throws Exception {
+ public void createOwningEntityTest() {
doReturn(true).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
doNothing().when(aaiServiceInstanceResources)
.connectOwningEntityandServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
}
@Test
- public void createOwningEntityNotExistsOwningEntityTest() throws Exception {
+ public void createOwningEntityNotExistsOwningEntityTest() {
doReturn(false).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
doNothing().when(aaiServiceInstanceResources)
.createOwningEntityandConnectServiceInstance(serviceInstance.getOwningEntity(), serviceInstance);
}
@Test
- public void createOwningEntityNullOwningEntityNameTest() throws Exception {
+ public void createOwningEntityNullOwningEntityNameTest() {
expectedException.expect(BpmnError.class);
serviceInstance.getOwningEntity().setOwningEntityName(null);
}
@Test
- public void createOwningEntityEmptyOwningEntityNameTest() throws Exception {
+ public void createOwningEntityEmptyOwningEntityNameTest() {
expectedException.expect(BpmnError.class);
serviceInstance.getOwningEntity().setOwningEntityName("");
}
@Test
- public void createOwningEntityExceptionTest() throws Exception {
+ public void createOwningEntityExceptionTest() {
expectedException.expect(BpmnError.class);
doReturn(true).when(aaiServiceInstanceResources).existsOwningEntity(serviceInstance.getOwningEntity());
}
@Test
- public void createVnfTest() throws Exception {
+ public void createVnfTest() {
doNothing().when(aaiVnfResources).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
execution.setVariable("aLaCarte", Boolean.FALSE);
aaiCreateTasks.createVnf(execution);
public void createVnfExceptionTest() throws Exception {
expectedException.expect(BpmnError.class);
lookupKeyMap.put(ResourceKey.GENERIC_VNF_ID, "notfound");
- doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(any(),
+ doThrow(BBObjectNotFoundException.class).when(extractPojosForBBMock).extractByKey(any(),
ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID));
doNothing().when(aaiVnfResources).createVnfandConnectServiceInstance(genericVnf, serviceInstance);
aaiCreateTasks.createVnf(execution);
@Test
public void createPnfShouldCallCreatePnfAndConnectServiceInstance() throws BBObjectNotFoundException {
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.PNF))).thenReturn(pnf);
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.PNF))).thenReturn(pnf);
aaiCreateTasks.createPnf(execution);
verify(aaiPnfResources, times(1)).createPnfAndConnectServiceInstance(pnf, serviceInstance);
}
@Test
public void createPnfShouldThrowBpmnErrorWhenPnfIsNotFound() throws BBObjectNotFoundException {
expectedException.expect(BpmnError.class);
- doThrow(BBObjectNotFoundException.class).when(extractPojosForBB).extractByKey(execution, ResourceKey.PNF);
+ doThrow(BBObjectNotFoundException.class).when(extractPojosForBBMock).extractByKey(execution, ResourceKey.PNF);
aaiCreateTasks.createPnf(execution);
}
newVfModule.setModuleIndex(null);
newVfModule.getModelInfoVfModule().setModelInvariantUUID("testModelInvariantUUID1");
doNothing().when(aaiVfModuleResources).createVfModule(newVfModule, genericVnf);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID)))
.thenReturn(newVfModule);
assertEquals(null, newVfModule.getModuleIndex());
}
@Test
- public void createVfModuleExceptionTest() throws Exception {
+ public void createVfModuleExceptionTest() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiVfModuleResources).createVfModule(vfModule, genericVnf);
}
@Test
- public void connectVfModuleToVolumeGroupTest() throws Exception {
+ public void connectVfModuleToVolumeGroupTest() {
doNothing().when(aaiVfModuleResources).connectVfModuleToVolumeGroup(genericVnf, vfModule, volumeGroup,
cloudRegion);
aaiCreateTasks.connectVfModuleToVolumeGroup(execution);
}
@Test
- public void createNetworkTest() throws Exception {
+ public void createNetworkTest() {
network.getModelInfoNetwork().setNeutronNetworkType("PROVIDER");
execution.setVariable("aLaCarte", Boolean.FALSE);
doNothing().when(aaiNetworkResources).createNetworkConnectToServiceInstance(network, serviceInstance);
}
@Test
- public void createNetworkExceptionTest() throws Exception {
+ public void createNetworkExceptionTest() {
expectedException.expect(BpmnError.class);
lookupKeyMap.put(ResourceKey.NETWORK_ID, "notfound");
}
@Test
- public void createNetworkCollectionTest() throws Exception {
+ public void createNetworkCollectionTest() {
doNothing().when(aaiNetworkResources).createNetworkCollection(serviceInstance.getCollection());
execution.setVariable("networkCollectionName", "testNetworkCollectionName");
aaiCreateTasks.createNetworkCollection(execution);
}
@Test
- public void createNetworkCollectionInstanceGroupTest() throws Exception {
+ public void createNetworkCollectionInstanceGroupTest() {
doNothing().when(aaiNetworkResources)
.createNetworkInstanceGroup(serviceInstance.getCollection().getInstanceGroup());
execution.setVariable("aLaCarte", Boolean.FALSE);
}
@Test
- public void connectNetworkToNetworkCollectionServiceInstanceTest() throws Exception {
+ public void connectNetworkToNetworkCollectionServiceInstanceTest() {
doNothing().when(aaiNetworkResources).connectNetworkToNetworkCollectionServiceInstance(network,
serviceInstance);
aaiCreateTasks.connectNetworkToNetworkCollectionServiceInstance(execution);
}
@Test
- public void connectNetworkToNetworkCollectionInstanceGroupTest() throws Exception {
+ public void connectNetworkToNetworkCollectionInstanceGroupTest() {
doNothing().when(aaiNetworkResources).connectNetworkToNetworkCollectionInstanceGroup(network,
serviceInstance.getCollection().getInstanceGroup());
aaiCreateTasks.connectNetworkToNetworkCollectionInstanceGroup(execution);
gBBInput.setServiceInstance(serviceInstance);
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
.thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID)))
.thenReturn(serviceInstance);
// verify connection call was not executednetwork
exception.expect(BpmnError.class);
}
@Test
- public void connectNetworkToCloudRegionTest() throws Exception {
+ public void connectNetworkToCloudRegionTest() {
gBBInput = execution.getGeneralBuildingBlock();
doNothing().when(aaiNetworkResources).connectNetworkToCloudRegion(network, gBBInput.getCloudRegion());
aaiCreateTasks.connectNetworkToCloudRegion(execution);
}
@Test
- public void connectNetworkToTenantTest() throws Exception {
+ public void connectNetworkToTenantTest() {
gBBInput = execution.getGeneralBuildingBlock();
doNothing().when(aaiNetworkResources).connectNetworkToTenant(network, gBBInput.getCloudRegion());
aaiCreateTasks.connectNetworkToTenant(execution);
}
@Test
- public void createConfigurationTest() throws Exception {
+ public void createConfigurationTest() {
gBBInput = execution.getGeneralBuildingBlock();
doNothing().when(aaiConfigurationResources).createConfiguration(configuration);
execution.setVariable("aLaCarte", Boolean.FALSE);
}
@Test
- public void connectVnfToCloudRegionTest() throws Exception {
+ public void connectVnfToCloudRegionTest() {
gBBInput = execution.getGeneralBuildingBlock();
doNothing().when(aaiVnfResources).connectVnfToCloudRegion(genericVnf, gBBInput.getCloudRegion());
aaiCreateTasks.connectVnfToCloudRegion(execution);
}
@Test
- public void connectNoneToVnfToCloudRegionTest() throws Exception {
+ public void connectNoneToVnfToCloudRegionTest() {
String[] arr = new String[1];
arr[0] = "test25Region2";
doReturn(arr).when(env).getProperty("mso.bpmn.cloudRegionIdsToSkipAddingVnfEdgesTo", String[].class);
}
@Test
- public void connectVnfTenantTest() throws Exception {
+ public void connectVnfTenantTest() {
gBBInput = execution.getGeneralBuildingBlock();
doNothing().when(aaiVnfResources).connectVnfToTenant(genericVnf, gBBInput.getCloudRegion());
aaiCreateTasks.connectVnfToTenant(execution);
}
@Test
- public void createInstanceGroupVnfTest() throws Exception {
+ public void createInstanceGroupVnfTest() {
doReturn(false).when(aaiInstanceGroupResources)
.checkInstanceGroupNameInUse(instanceGroup.getInstanceGroupName());
doNothing().when(aaiInstanceGroupResources).createInstanceGroupandConnectServiceInstance(instanceGroup,
}
@Test
- public void createInstanceGroupVnfExceptionTest() throws Exception {
+ public void createInstanceGroupVnfExceptionTest() {
expectedException.expect(BpmnError.class);
doThrow(RuntimeException.class).when(aaiInstanceGroupResources)
.createInstanceGroupandConnectServiceInstance(instanceGroup, serviceInstance);
}
@Test
- public void createNetworkPolicyNeedToCreateAllTest() throws Exception {
+ public void createNetworkPolicyNeedToCreateAllTest() {
execution.setVariable("heatStackId", "testHeatStackId");
execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123,ED456");
Optional<NetworkPolicy> networkPolicy = Optional.empty();
}
@Test
- public void createNetworkPolicyNeedToCreateNoneTest() throws Exception {
+ public void createNetworkPolicyNeedToCreateNoneTest() {
execution.setVariable("heatStackId", "testHeatStackId");
execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123");
NetworkPolicy networkPolicy = new NetworkPolicy();
}
@Test
- public void createNetworkPolicyNoNetworkPoliciesTest() throws Exception {
+ public void createNetworkPolicyNoNetworkPoliciesTest() {
execution.setVariable("heatStackId", "testHeatStackId");
aaiCreateTasks.createNetworkPolicies(execution);
verify(aaiNetworkResources, times(0)).createNetworkPolicy(any(NetworkPolicy.class));
}
@Test
- public void createVfModuleGetLowestIndexTest() throws Exception {
+ public void createVfModuleGetLowestIndexTest() {
GenericVnf vnf = new GenericVnf();
ModelInfoGenericVnf vnfInfo = new ModelInfoGenericVnf();
vnf.setModelInfoGenericVnf(vnfInfo);
import org.camunda.bpm.engine.delegate.BpmnError;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers;
import org.mockito.Captor;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.aai.domain.yang.NetworkPolicies;
-import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion;
import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.aaiclient.client.aai.entities.AAIResultWrapper;
import org.onap.aaiclient.client.aai.entities.uri.AAIBaseResourceUri;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
import org.onap.so.client.exception.BBObjectNotFoundException;
-
-
-public class AAIDeleteTasksTest extends BaseTaskTest {
+import org.onap.so.client.exception.ExceptionBuilder;
+import org.onap.so.client.orchestration.AAIConfigurationResources;
+import org.onap.so.client.orchestration.AAIInstanceGroupResources;
+import org.onap.so.client.orchestration.AAINetworkResources;
+import org.onap.so.client.orchestration.AAIServiceInstanceResources;
+import org.onap.so.client.orchestration.AAIVfModuleResources;
+import org.onap.so.client.orchestration.AAIVnfResources;
+import org.onap.so.client.orchestration.AAIVolumeGroupResources;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class AAIDeleteTasksTest extends TestDataSetup {
private final static String JSON_FILE_LOCATION = "src/test/resources/__files/BuildingBlocks/";
+ @Mock
+ protected ExceptionBuilder exceptionUtil;
+ @Mock
+ protected AAIVfModuleResources aaiVfModuleResources;
+ @Mock
+ protected AAIServiceInstanceResources aaiServiceInstanceResources;
+ @Mock
+ protected AAIVnfResources aaiVnfResources;
+ @Mock
+ protected AAINetworkResources aaiNetworkResources;
+ @Mock
+ protected AAIVolumeGroupResources aaiVolumeGroupResources;
+ @Mock
+ protected AAIConfigurationResources aaiConfigurationResources;
+ @Mock
+ protected AAIInstanceGroupResources aaiInstanceGroupResources;
+ @Mock
+ protected ExtractPojosForBB extractPojosForBBMock;
@InjectMocks
- private AAIDeleteTasks aaiDeleteTasks = new AAIDeleteTasks();
+ private AAIDeleteTasks aaiDeleteTasks;
private L3Network network;
private ServiceInstance serviceInstance;
configuration = setConfiguration();
instanceGroup = setInstanceGroupVnf();
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
.thenReturn(genericVnf);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID))).thenReturn(vfModule);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID))).thenReturn(network);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID)))
+ .thenReturn(vfModule);
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.NETWORK_ID)))
+ .thenReturn(network);
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VOLUME_GROUP_ID)))
.thenReturn(volumeGroup);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.SERVICE_INSTANCE_ID)))
.thenReturn(serviceInstance);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.CONFIGURATION_ID)))
.thenReturn(configuration);
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.INSTANCE_GROUP_ID)))
.thenReturn(instanceGroup);
}
@Test
- public void deleteConfigurationTest() throws Exception {
+ public void deleteConfigurationTest() {
gBBInput = execution.getGeneralBuildingBlock();
doNothing().when(aaiConfigurationResources).deleteConfiguration(configuration);
aaiDeleteTasks.deleteConfiguration(execution);
}
@Test
- public void deleteInstanceGroupVnfTest() throws Exception {
+ public void deleteInstanceGroupVnfTest() {
doNothing().when(aaiInstanceGroupResources).deleteInstanceGroup(instanceGroup);
aaiDeleteTasks.deleteInstanceGroupVnf(execution);
verify(aaiInstanceGroupResources, times(1)).deleteInstanceGroup(instanceGroup);
}
@Test
- public void deleteNetworkPolicyNeedToDeleteNoneTest() throws Exception {
+ public void deleteNetworkPolicyNeedToDeleteNoneTest() {
execution.setVariable("contrailNetworkPolicyFqdnList", "ABC123");
Optional<NetworkPolicies> networkPolicies = Optional.empty();
doReturn(networkPolicies).when(aaiNetworkResources).getNetworkPolicies(any(AAIBaseResourceUri.class));
}
@Test
- public void deleteNetworkPolicyNoNetworkPoliciesTest() throws Exception {
+ public void deleteNetworkPolicyNoNetworkPoliciesTest() {
aaiDeleteTasks.deleteNetworkPolicies(execution);
verify(aaiNetworkResources, times(0)).deleteNetworkPolicy(any(String.class));
}
package org.onap.so.bpmn.infrastructure.activity;
-
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.doReturn;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Spy;
-import org.onap.so.bpmn.BaseTaskTest;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.core.WorkflowException;
import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionBBFailure;
import org.onap.so.bpmn.servicedecomposition.entities.BuildingBlock;
import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock;
import org.onap.so.client.exception.ExceptionBuilder;
-public class ExecuteActivityTest extends BaseTaskTest {
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class ExecuteActivityTest extends TestDataSetup {
@InjectMocks
- protected ExecuteActivity executeActivity = new ExecuteActivity();
+ protected ExecuteActivity executeActivity;
@InjectMocks
@Spy
}
@Test
- public void buildAndThrowException_Test() throws Exception {
+ public void buildAndThrowException_Test() {
doNothing().when(workflowActionBBFailure).updateRequestStatusToFailed(execution);
doReturn("Process key").when(exceptionBuilder).getProcessKey(execution);
thrown.expect(BpmnError.class);
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.ArgumentMatchers;
import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.onap.appc.client.lcm.model.Action;
-import org.onap.so.bpmn.BaseTaskTest;
import org.onap.so.bpmn.common.BuildingBlockExecution;
+import org.onap.so.bpmn.common.data.TestDataSetup;
import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf;
import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
import org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.appc.ApplicationControllerAction;
import org.onap.so.client.exception.BBObjectNotFoundException;
+import org.onap.so.client.exception.ExceptionBuilder;
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
-
-public class GenericVnfHealthCheckTest extends BaseTaskTest {
-
+import org.onap.so.db.catalog.client.CatalogDbClient;
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class GenericVnfHealthCheckTest extends TestDataSetup {
+
+ @Mock
+ protected ExceptionBuilder exceptionUtil;
+ @Mock
+ protected CatalogDbClient catalogDbClient;
+ @Mock
+ protected ApplicationControllerAction appCClient;
+ @Mock
+ protected ExtractPojosForBB extractPojosForBBMock;
@InjectMocks
- private GenericVnfHealthCheck genericVnfHealthCheck = new GenericVnfHealthCheck();
+ private GenericVnfHealthCheck genericVnfHealthCheck;
private GenericVnf genericVnf;
private RequestContext requestContext;
doThrow(new BpmnError("BPMN Error")).when(exceptionUtil)
.buildAndThrowWorkflowException(any(BuildingBlockExecution.class), eq(7000), any(Exception.class));
- when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
+ when(extractPojosForBBMock.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.GENERIC_VNF_ID)))
.thenReturn(genericVnf);
}
@Test
- public void setParamsForGenericVnfHealthCheckTest() throws Exception {
+ public void setParamsForGenericVnfHealthCheckTest() {
ControllerSelectionReference controllerSelectionReference = new ControllerSelectionReference();
controllerSelectionReference.setControllerName("testName");
controllerSelectionReference.setActionCategory("testAction");
}
@Test
- public void callAppcClientTest() throws Exception {
+ public void callAppcClientTest() {
Action action = Action.HealthCheck;
String vnfId = genericVnf.getVnfId();
String payload = "{\"testName\":\"testValue\",}";
String controllerType = "testType";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ HashMap<String, String> payloadInfo = new HashMap<>();
payloadInfo.put("vnfName", "testVnfName");
payloadInfo.put("vfModuleId", "testVfModuleId");
payloadInfo.put("oamIpAddress", "testOamIpAddress");
}
@Test
- public void callAppcClientExceptionTest() throws Exception {
+ public void callAppcClientExceptionTest() {
expectedException.expect(BpmnError.class);
Action action = Action.HealthCheck;
String vnfId = genericVnf.getVnfId();
String payload = "{\"testName\":\"testValue\",}";
String controllerType = "testType";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ HashMap<String, String> payloadInfo = new HashMap<>();
payloadInfo.put("vnfName", "testVnfName");
payloadInfo.put("vfModuleId", "testVfModuleId");
payloadInfo.put("oamIpAddress", "testOamIpAddress");
String vnfId = genericVnf.getVnfId();
String payload = "{\"testName\":\"testValue\",}";
String controllerType = "testType";
- HashMap<String, String> payloadInfo = new HashMap<String, String>();
+ HashMap<String, String> payloadInfo = new HashMap<>();
payloadInfo.put("vnfName", "testVnfName");
payloadInfo.put("vfModuleId", "testVfModuleId");
payloadInfo.put("oamIpAddress", "testOamIpAddress");
html_last_updated_fmt = '%d-%b-%y %H:%M'
def setup(app):
- app.add_stylesheet("css/ribbon.css")
+ app.add_css_file("css/ribbon.css")
-tox
-Sphinx
-doc8
-docutils
-setuptools
-six
-sphinx_rtd_theme>=0.4.3
-sphinxcontrib-blockdiag
-sphinxcontrib-needs>=0.2.3
-sphinxcontrib-nwdiag
-sphinxcontrib-seqdiag
-sphinxcontrib-swaggerdoc
-sphinxcontrib-plantuml
-sphinx_bootstrap_theme
lfdocs-conf
[tox]
minversion = 1.6
-envlist = docs,
+envlist = docs
skipsdist = true
[testenv:docs]
basepython = python3
-deps = -r{toxinidir}/requirements-docs.txt
+deps =
+ -r{toxinidir}/requirements-docs.txt
+ -chttps://git.onap.org/doc/plain/etc/upper-constraints.os.txt
+ -chttps://git.onap.org/doc/plain/etc/upper-constraints.onap.txt
commands =
sphinx-build -b html -n -d {envtmpdir}/doctrees ./ {toxinidir}/_build/html
echo "Generated docs available in {toxinidir}/_build/html"
[testenv:docs-linkcheck]
basepython = python3
-#deps = -r{toxinidir}/requirements-docs.txt
+deps =
+ -r{toxinidir}/requirements-docs.txt
+ -chttps://git.onap.org/doc/plain/etc/upper-constraints.os.txt
+ -chttps://git.onap.org/doc/plain/etc/upper-constraints.onap.txt
commands = echo "Link Checking not enforced"
#commands = sphinx-build -b linkcheck -d {envtmpdir}/doctrees ./ {toxinidir}/_build/linkcheck
whitelist_externals = echo
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2021 Bell Canada. All rights reserved.
+ * ================================================================================
+ * 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.db.catalog.beans;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.openpojo.business.annotation.BusinessKey;
+import java.io.Serializable;
+import java.util.Objects;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.GeneratedValue;
+import javax.persistence.GenerationType;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import uk.co.blackpepper.bowman.annotation.RemoteResource;
+
+@Entity
+@RemoteResource("/buildingBlockRollback")
+@Table(name = "building_block_rollback")
+public class BuildingBlockRollback implements Serializable {
+
+ private static final long serialVersionUID = 1;
+
+ @Id
+ @BusinessKey
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "ID", nullable = false, updatable = false)
+ private Integer id;
+
+ @BusinessKey
+ @JsonProperty("building_block_name")
+ @Column(name = "BUILDING_BLOCK_NAME", nullable = false, length = 200)
+ private String buildingBlockName;
+
+ @BusinessKey
+ @JsonProperty("action")
+ @Column(name = "ACTION", length = 200)
+ private String action;
+
+ @BusinessKey
+ @JsonProperty("rollback_building_block_name")
+ @Column(name = "ROLLBACK_BUILDING_BLOCK_NAME", nullable = false, length = 200)
+ private String rollbackBuildingBlockName;
+
+ @BusinessKey
+ @JsonProperty("rollback_action")
+ @Column(name = "ROLLBACK_ACTION", length = 200)
+ private String rollbackAction;
+
+ public Integer getId() {
+ return id;
+ }
+
+ public void setId(Integer id) {
+ this.id = id;
+ }
+
+ public String getBuildingBlockName() {
+ return buildingBlockName;
+ }
+
+ public void setBuildingBlockName(String buildingBlockName) {
+ this.buildingBlockName = buildingBlockName;
+ }
+
+ public String getAction() {
+ return action;
+ }
+
+ public void setAction(String action) {
+ this.action = action;
+ }
+
+ public String getRollbackBuildingBlockName() {
+ return rollbackBuildingBlockName;
+ }
+
+ public void setRollbackBuildingBlockName(String rollbackBuildingBlockName) {
+ this.rollbackBuildingBlockName = rollbackBuildingBlockName;
+ }
+
+ public String getRollbackAction() {
+ return rollbackAction;
+ }
+
+ public void setRollbackAction(String rollbackAction) {
+ this.rollbackAction = rollbackAction;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ BuildingBlockRollback that = (BuildingBlockRollback) o;
+ return id.equals(that.id) && buildingBlockName.equals(that.buildingBlockName)
+ && Objects.equals(action, that.action)
+ && rollbackBuildingBlockName.equals(that.rollbackBuildingBlockName)
+ && Objects.equals(rollbackAction, that.rollbackAction);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, buildingBlockName, action, rollbackBuildingBlockName, rollbackAction);
+ }
+
+ @Override
+ public String toString() {
+ return "BuildingBlockRollback{" + "id='" + id + '\'' + ", buildingBlockName='" + buildingBlockName + '\''
+ + ", action='" + action + '\'' + ", rollbackBuildingBlockName='" + rollbackBuildingBlockName + '\''
+ + ", rollbackAction='" + rollbackAction + '\'' + '}';
+ }
+}
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.PostConstruct;
import javax.persistence.EntityNotFoundException;
import org.onap.logging.filter.spring.SpringClientPayloadFilter;
import org.onap.so.db.catalog.beans.BBNameSelectionReference;
import org.onap.so.db.catalog.beans.BuildingBlockDetail;
+import org.onap.so.db.catalog.beans.BuildingBlockRollback;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.CloudifyManager;
import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
private static final String WORKFLOW = "/workflow";
private static final String BB_NAME_SELECTION_REFERENCE = "/bbNameSelectionReference";
private static final String PROCESSING_FLAGS = "/processingFlags";
+ private static final String BB_ROLLBACK = "/buildingBlockRollback";
private static final String SEARCH = "/search";
private String pnfResourceURI;
private String pnfResourceCustomizationURI;
private String workflowURI;
+ private String buildingBlockRollbacksURI;
private final Client<Service> serviceClient;
private final Client<ProcessingFlags> processingFlagsClient;
+ private final Client<BuildingBlockRollback> buildingBlockRollbackClient;
+
@Value("${mso.catalog.db.spring.endpoint:#{null}}")
private String endpoint;
pnfResourceURI = endpoint + PNF_RESOURCE + URI_SEPARATOR;
pnfResourceCustomizationURI = endpoint + PNF_RESOURCE_CUSTOMIZATION + URI_SEPARATOR;
workflowURI = endpoint + WORKFLOW + URI_SEPARATOR;
-
+ buildingBlockRollbacksURI = endpoint + BB_ROLLBACK + URI_SEPARATOR;
}
public CatalogDbClient() {
bbNameSelectionReferenceClient = clientFactory.create(BBNameSelectionReference.class);
processingFlagsClient = clientFactory.create(ProcessingFlags.class);
networkResourceClient = clientFactory.create(NetworkResource.class);
+ buildingBlockRollbackClient = clientFactory.create(BuildingBlockRollback.class);
}
public CatalogDbClient(String baseUri, String auth) {
bbNameSelectionReferenceClient = clientFactory.create(BBNameSelectionReference.class);
processingFlagsClient = clientFactory.create(ProcessingFlags.class);
networkResourceClient = clientFactory.create(NetworkResource.class);
+ buildingBlockRollbackClient = clientFactory.create(BuildingBlockRollback.class);
}
public NetworkCollectionResourceCustomization getNetworkCollectionResourceCustomizationByID(
getUri(UriBuilder.fromUri(findProcessingFlagsByFlag).queryParam(FLAG, flag).build().toString()));
}
+ // TODO: redo using buildingBlockRollbackClient
+ public List<BuildingBlockRollback> getBuildingBlockRollbackEntries() {
+ try {
+ HttpEntity<?> entity = getHttpEntity();
+ return restTemplate.exchange(
+ UriComponentsBuilder.fromUriString(endpoint + "/ecomp/mso/catalog/v1/buildingBlockRollback").build()
+ .encode().toString(),
+ HttpMethod.GET, entity, new ParameterizedTypeReference<List<BuildingBlockRollback>>() {}).getBody();
+ } catch (HttpClientErrorException e) {
+ logger.error("Error Calling catalog database", e);
+ throw e;
+ }
+ }
+
public String getEndpoint() {
return endpoint;
}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2021 Bell Canada
+ * ================================================================================
+ * 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.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.db.catalog.data.repository;
+
+import java.util.List;
+import org.onap.so.db.catalog.beans.BuildingBlockRollback;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
+
+@RepositoryRestResource(collectionResourceRel = "buildingBlockRollback", path = "buildingBlockRollback")
+public interface BuildingBlockRollbackRepository extends JpaRepository<BuildingBlockRollback, Integer> {
+
+ List<BuildingBlockRollback> findAll();
+
+ BuildingBlockRollback findOneById(Integer ID);
+}
PRIMARY KEY (`ID`),
UNIQUE KEY `UK_processing_flags` (`FLAG`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+CREATE TABLE IF NOT EXISTS `building_block_rollback` (
+ `ID` INT NOT NULL AUTO_INCREMENT,
+ `BUILDING_BLOCK_NAME` varchar(200) NOT NULL,
+ `ACTION` varchar(200) null,
+ `ROLLBACK_BUILDING_BLOCK_NAME` varchar(200) NOT NULL,
+ `ROLLBACK_ACTION` varchar(200) NULL,
+ PRIMARY KEY (`ID`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;