summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Smokowski <ss835w@att.com>2019-05-31 16:50:35 +0000
committerGerrit Code Review <gerrit@onap.org>2019-05-31 16:50:35 +0000
commitbdb57f7e5e53a32a32b5f13a91aac132d37a860e (patch)
treec2bee16a092a0a8dc28abb685b18e015f9cb271f
parent58d56789582716f92eb4b847d577c9a5cea32699 (diff)
parente74e48d9e7eec31c468db238f7f2edd9e6961923 (diff)
Merge "Added NPE check for audit"
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/exception/ExceptionBuilder.java106
-rw-r--r--bpmn/MSOCommonBPMN/src/test/java/org/onap/so/client/exception/ExceptionBuilderTest.java4
2 files changed, 56 insertions, 54 deletions
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 dabfc81e1f..870b936f5c 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
@@ -153,65 +153,67 @@ public class ExceptionBuilder {
}
public void processAuditException(DelegateExecutionImpl execution, boolean flowShouldContinue) {
- logger.info("Building a WorkflowException for Subflow");
+ logger.debug("Processing Audit Results");
+ String auditListString = (String) execution.getVariable("auditInventoryResult");
+ if (auditListString != null) {
+ 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();
+ AAIObjectAuditList auditList =
+ objectMapper.getMapper().readValue(auditListString, AAIObjectAuditList.class);
+
+ errorMessage = errorMessage.append(auditList.getAuditType() + " VF-Module " + module.getVfModuleId()
+ + " failed due to incomplete AAI vserver inventory population after stack "
+ + auditList.getHeatStackName() + " was successfully " + auditList.getAuditType()
+ + "d in cloud region " + cloudRegionId + ". MSO Audit indicates that the following was not "
+ + auditList.getAuditType() + "d in AAI: ");
+
+ 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() + ", ");
+ }
+ }
- 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(".");
}
- }
- 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. ");
}
- } 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.");
+ if (flowShouldContinue) {
+ execution.setVariable("StatusMessage", errorMessage.toString());
+ } else {
+ WorkflowException exception = new WorkflowException(processKey, 400, errorMessage.toString());
+ execution.setVariable("WorkflowException", exception);
+ execution.setVariable("WorkflowExceptionErrorMessage", errorMessage.toString());
+ logger.info("Outgoing WorkflowException is {}", exception);
+ logger.info("Throwing MSOWorkflowException");
+ throw new BpmnError("AAIInventoryFailure");
+ }
- if (flowShouldContinue) {
- execution.setVariable("StatusMessage", errorMessage.toString());
} else {
- WorkflowException exception = new WorkflowException(processKey, 400, errorMessage.toString());
- execution.setVariable("WorkflowException", exception);
- execution.setVariable("WorkflowExceptionErrorMessage", errorMessage.toString());
- logger.info("Outgoing WorkflowException is {}", exception);
- logger.info("Throwing MSOWorkflowException");
- throw new BpmnError("AAIInventoryFailure");
+ logger.debug("Unable to process audit results due to auditInventoryResult being null");
}
}
+
}
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 549f16b6f6..5f9aef67e6 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
@@ -138,7 +138,7 @@ public class ExceptionBuilderTest extends BaseTest {
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.",
+ "create VF-Module testVfModuleId1 failed due to incomplete AAI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that the following was not created in AAI: vserver testVServerId.",
we.getErrorMessage());
}
}
@@ -151,7 +151,7 @@ public class ExceptionBuilderTest extends BaseTest {
String sm = execution.getVariable("StatusMessage");
assertNotNull(sm);
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.",
+ "create VF-Module testVfModuleId1 failed due to incomplete AAI vserver inventory population after stack testStackName was successfully created in cloud region testLcpCloudRegionId. MSO Audit indicates that the following was not created in AAI: vserver testVServerId.",
sm);
} catch (BpmnError bpmnException) {
fail();