summaryrefslogtreecommitdiffstats
path: root/bpmn/MSOCommonBPMN
diff options
context:
space:
mode:
authorBenjamin, Max (mb388a) <mb388a@us.att.com>2019-04-21 11:11:21 -0400
committerBenjamin, Max (mb388a) <mb388a@us.att.com>2019-04-21 20:05:17 -0400
commit7328b3f1e9eb1804911dfe9dcede792fd711d51f (patch)
tree2a38d037a1f9deffc9984bb977de7e8653547409 /bpmn/MSOCommonBPMN
parent0a355f91e1da586f70450329d8620b823d59b9e5 (diff)
Status message for create vf module event audit
Added appc to application-test due to new dependency in openstack Updated exception class to inject mock into class for junits. Added error handling support for when create audit fails. Added error handling for when create audit fails and added test Updated test schema file to create table and added field. Updated pom file to relfect typo in change made. Updated locaton of pojos for audit code Updated test schema file to create table and added field. Updated pom file to relfect typo in change made. Comitting files that i forgot to stage from previous commit Updated locaton of pojos for audit code Additional fixes including vnfcname and null check Fixed bug in delete audit failure check and reverted gateway change. Change-Id: I993ce377dd6407960a65b4940d83d8162b24633c Issue-ID: SO-1792 Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn/MSOCommonBPMN')
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java2
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java9
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java78
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java1
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java73
5 files changed, 154 insertions, 9 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java
index c087d586e7..83a44cfe8b 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/BuildingBlockExecution.java
@@ -9,7 +9,7 @@
* 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.
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java
index 31fef7c6f7..734262aa55 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/DelegateExecutionImpl.java
@@ -112,10 +112,6 @@ public class DelegateExecutionImpl implements BuildingBlockExecution, Serializab
return this.get("flowToBeCalled");
}
- @JsonIgnore
- public DelegateExecution getDelegateExecution() {
- return this.execution;
- }
public void setDelegateExecution(final DelegateExecution execution) {
this.execution = execution;
@@ -126,6 +122,11 @@ public class DelegateExecutionImpl implements BuildingBlockExecution, Serializab
});
}
+ @JsonIgnore
+ public DelegateExecution getDelegateExecution() {
+ return this.execution;
+ }
+
@SuppressWarnings("unchecked")
protected <T> T get(final String key) {
final Object value = this.execution.getVariable(key);
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java
index ae5e41f7ce..b69ab151c4 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java
@@ -22,21 +22,40 @@
package org.onap.so.client.exception;
+import java.io.IOException;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.aai.domain.yang.LInterface;
+import org.onap.aai.domain.yang.Vserver;
import org.onap.so.bpmn.common.BuildingBlockExecution;
import org.onap.so.bpmn.common.DelegateExecutionImpl;
import org.onap.so.bpmn.core.WorkflowException;
import org.onap.so.logger.ErrorCode;
+import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
import org.onap.so.logger.MessageEnum;
+import org.onap.so.objects.audit.AAIObjectAudit;
+import org.onap.so.objects.audit.AAIObjectAuditList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
+
@Component
public class ExceptionBuilder {
private static final Logger logger = LoggerFactory.getLogger(ExceptionBuilder.class);
+
+ protected ExtractPojosForBB getExtractPojosForBB() {
+ return new ExtractPojosForBB();
+ }
+
public void buildAndThrowWorkflowException(BuildingBlockExecution execution, int errorCode, Exception exception) {
String msg = "Exception in %s.%s ";
try {
@@ -132,4 +151,63 @@ public class ExceptionBuilder {
return execution.getProcessEngineServices().getRepositoryService()
.getProcessDefinition(execution.getProcessDefinitionId()).getKey();
}
+
+ public void processAuditException(DelegateExecutionImpl execution) {
+ logger.info("Building a WorkflowException for Subflow");
+
+ StringBuilder errorMessage = new StringBuilder();
+ String processKey = getProcessKey(execution.getDelegateExecution());
+ try {
+ ExtractPojosForBB extractPojosForBB = getExtractPojosForBB();
+ VfModule module = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
+ String cloudRegionId = execution.getGeneralBuildingBlock().getCloudRegion().getLcpCloudRegionId();
+
+ GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
+ String auditListString = (String) execution.getVariable("auditInventoryResult");
+ AAIObjectAuditList auditList =
+ objectMapper.getMapper().readValue(auditListString, AAIObjectAuditList.class);
+
+ errorMessage = errorMessage.append(auditList.getAuditType() + " VF-Module " + module.getVfModuleId()
+ + " failed due to incomplete A&AI vserver inventory population after stack "
+ + auditList.getHeatStackName() + " was successfully " + auditList.getAuditType()
+ + "d in cloud region " + cloudRegionId + ". MSO Audit indicates that AIC RO did not "
+ + auditList.getAuditType() + " ");
+
+ Stream<AAIObjectAudit> vServerLInterfaceAuditStream = auditList.getAuditList().stream()
+ .filter(auditObject -> auditObject.getAaiObjectType().equals(AAIObjectType.VSERVER.typeName())
+ || auditObject.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName()));
+ List<AAIObjectAudit> filteredAuditStream =
+ vServerLInterfaceAuditStream.filter(a -> !a.isDoesObjectExist()).collect(Collectors.toList());
+
+ for (AAIObjectAudit object : filteredAuditStream) {
+ if (object.getAaiObjectType().equals(AAIObjectType.L_INTERFACE.typeName())) {
+ LInterface li = objectMapper.getMapper().convertValue(object.getAaiObject(), LInterface.class);
+ errorMessage = errorMessage
+ .append(AAIObjectType.L_INTERFACE.typeName() + " " + li.getInterfaceId() + ", ");
+ } else {
+ Vserver vs = objectMapper.getMapper().convertValue(object.getAaiObject(), Vserver.class);
+ errorMessage =
+ errorMessage.append(AAIObjectType.VSERVER.typeName() + " " + vs.getVserverId() + ", ");
+ }
+ }
+
+ if (errorMessage.length() > 0) {
+ errorMessage.setLength(errorMessage.length() - 2);
+ errorMessage = errorMessage.append(" in AAI. ");
+ }
+
+ } catch (IOException | BBObjectNotFoundException e) {
+ errorMessage = errorMessage.append("process objects in AAI. ");
+ }
+
+ errorMessage.append(
+ "Recommendation - Wait for nightly RO Audit to run and fix the data issue and resume vf-module creation in VID. If problem persists then report problem to AIC/RO Ops.");
+
+ WorkflowException exception = new WorkflowException(processKey, 400, errorMessage.toString());
+ execution.setVariable("WorkflowException", exception);
+ execution.setVariable("WorkflowExceptionErrorMessage", errorMessage);
+ logger.info("Outgoing WorkflowException is {}", exception);
+ logger.info("Throwing MSOWorkflowException");
+ throw new BpmnError("AAIInventoryFailure");
+ }
}
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
index 79a94d5298..3bb417741f 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/BuildingBlockTestDataSetup.java
@@ -325,6 +325,7 @@ public class BuildingBlockTestDataSetup {
gBBInput.setCustomer(buildCustomer());
}
gBBInput.getCustomer().getServiceSubscription().getServiceInstances().add(serviceInstance);
+ gBBInput.setServiceInstance(serviceInstance);
lookupKeyMap.put(ResourceKey.SERVICE_INSTANCE_ID, serviceInstance.getServiceInstanceId());
return serviceInstance;
diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java
index ef066853ca..4ade9dbe32 100644
--- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java
+++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -21,17 +21,66 @@
package org.onap.so.client.exception;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.when;
import org.camunda.bpm.engine.delegate.BpmnError;
+import org.junit.Before;
import org.junit.Test;
-import org.onap.so.bpmn.mock.FileUtil;
+import org.mockito.ArgumentMatchers;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.Spy;
+import org.onap.aai.domain.yang.Vserver;
import org.onap.so.BaseTest;
+import org.onap.so.bpmn.common.DelegateExecutionImpl;
+import org.onap.so.bpmn.core.WorkflowException;
+import org.onap.so.bpmn.mock.FileUtil;
+import org.onap.so.bpmn.servicedecomposition.entities.ResourceKey;
+import org.onap.so.bpmn.servicedecomposition.tasks.ExtractPojosForBB;
+import org.onap.so.client.aai.AAIObjectType;
+import org.onap.so.client.graphinventory.GraphInventoryCommonObjectMapperProvider;
+import org.onap.so.objects.audit.AAIObjectAudit;
+import org.onap.so.objects.audit.AAIObjectAuditList;
+import org.springframework.beans.BeanUtils;
+import com.fasterxml.jackson.core.JsonProcessingException;
public class ExceptionBuilderTest extends BaseTest {
private static final String RESOURCE_PATH = "__files/";
private static final String VALID_ERROR_MESSAGE = "{test error message}";
+ @Mock
+ protected ExtractPojosForBB extractPojosForBB;
+
+ @Spy
+ @InjectMocks
+ private ExceptionBuilder exceptionBuilder = new ExceptionBuilder();
+
+ GraphInventoryCommonObjectMapperProvider objectMapper = new GraphInventoryCommonObjectMapperProvider();
+
+ @Before
+ public void before() throws BBObjectNotFoundException, JsonProcessingException {
+ setCloudRegion();
+ when(extractPojosForBB.extractByKey(any(), ArgumentMatchers.eq(ResourceKey.VF_MODULE_ID)))
+ .thenReturn(buildVfModule());
+ AAIObjectAuditList auditList = new AAIObjectAuditList();
+ auditList.setAuditType("create");
+ auditList.setHeatStackName("testStackName");
+ AAIObjectAudit vserver = new AAIObjectAudit();
+ vserver.setAaiObjectType(AAIObjectType.VSERVER.typeName());
+ vserver.setDoesObjectExist(false);
+ Vserver vs = new Vserver();
+ vs.setVserverId("testVServerId");
+ Vserver vServerShallow = new Vserver();
+ BeanUtils.copyProperties(vs, vServerShallow, "LInterfaces");
+ vserver.setAaiObject(vServerShallow);
+ auditList.getAuditList().add(vserver);
+
+ execution.setVariable("auditInventoryResult", objectMapper.getMapper().writeValueAsString(auditList));
+ }
+
@Test
public void buildAndThrowWorkflowExceptionTest() {
@@ -77,4 +126,20 @@ public class ExceptionBuilderTest extends BaseTest {
assertEquals("MSOWorkflowException", bpmnException.getErrorCode());
}
}
+
+ @Test
+ public void processAuditExceptionTest() {
+ try {
+ Mockito.doReturn(extractPojosForBB).when(exceptionBuilder).getExtractPojosForBB();
+ exceptionBuilder.processAuditException((DelegateExecutionImpl) execution);
+ } catch (BpmnError bpmnException) {
+ assertEquals("AAIInventoryFailure", bpmnException.getErrorCode());
+ WorkflowException we = execution.getVariable("WorkflowException");
+ assertNotNull(we);
+ assertEquals(
+ "create VF-Module testVfModuleId1 failed due to incomplete A&AI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that AIC RO did not create vserver testVServerId in AAI. Recommendation - Wait for nightly RO Audit to run and fix the data issue and resume vf-module creation in VID. If problem persists then report problem to AIC/RO Ops.",
+ we.getErrorMessage());
+ }
+ }
+
}