diff options
author | Gamboa, Gilbert <gilbert.g.gamboa@att.com> | 2019-06-06 15:55:45 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-06-06 15:55:56 -0400 |
commit | 1520c9b3f95bd2b9c96a89a8cd4b292d78e57ff3 (patch) | |
tree | 02a06654d221937941ce0662927f13efa3a0b265 /bpmn | |
parent | 62b2e47808fe1adcbac31dbcdf992617b7f0bd4d (diff) |
vrfvalidation exceptions not getting logged
Remove unused imports in VrfValidation class
Check for null AAI network and vpn-bindings. Do not catch exceptions in
WorkflowAction.traverseVrfCondifuration. Propagate exceptions and let
calling method selectExecutionList() handle exceptions.
Change-Id: I26adfdb351cee6dc111f496901558340b8152a2a
Issue-ID: SO-1988
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'bpmn')
4 files changed, 58 insertions, 29 deletions
diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java index 6e410e9880..9092b68491 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidation.java @@ -8,7 +8,6 @@ import org.onap.so.client.aai.AAIObjectType; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.db.catalog.beans.ConfigurationResourceCustomization; -import org.onap.so.db.catalog.beans.ServiceProxyResourceCustomization; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -54,11 +53,14 @@ public class VrfValidation { return null; } - protected void aaiVpnBindingValidation(org.onap.aai.domain.yang.VpnBinding aaiVpnBinding) + protected void aaiVpnBindingValidation(String relatedVpnId, org.onap.aai.domain.yang.VpnBinding aaiVpnBinding) throws VrfBondingServiceException { - if (aaiVpnBinding == null || !aaiVpnBinding.getVpnType().equalsIgnoreCase("SERVICE-INFRASTRUCTURE")) { - throw new VrfBondingServiceException("VpnBinding: " + aaiVpnBinding.getVpnId() - + " does not have service type of BONDING and doesn not have service role of INFRASTRUCTURE-VPN"); + if (aaiVpnBinding == null) { + throw new VrfBondingServiceException("The infrastructure vpn " + relatedVpnId + " does not exist in A&AI."); + } else if (aaiVpnBinding.getVpnType() != null + && !aaiVpnBinding.getVpnType().equalsIgnoreCase("SERVICE-INFRASTRUCTURE")) { + throw new VrfBondingServiceException( + "VpnBinding: " + relatedVpnId + " does not have a vpn type of SERVICE-INFRASTRUCTURE."); } } @@ -84,6 +86,13 @@ public class VrfValidation { } } + protected void aaiNetworkValidation(String relatedNetworkid, org.onap.aai.domain.yang.L3Network aaiLocalNetwork) + throws VrfBondingServiceException { + if (aaiLocalNetwork == null) { + throw new VrfBondingServiceException("The local network " + relatedNetworkid + " does not exist in A&AI."); + } + } + protected void aaiSubnetValidation(org.onap.aai.domain.yang.L3Network aaiLocalNetwork) throws VrfBondingServiceException { if (aaiLocalNetwork.getSubnets() == null || aaiLocalNetwork.getSubnets().getSubnet() == null) { diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java index 73b0b5483e..4958e123fb 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowAction.java @@ -368,7 +368,7 @@ public class WorkflowAction { execution.setVariable("isRollbackComplete", false); } catch (Exception ex) { - buildAndThrowException(execution, "Exception in create execution list " + ex.getMessage(), ex); + buildAndThrowException(execution, "Exception in create execution list. " + ex.getMessage(), ex); } } @@ -623,7 +623,8 @@ public class WorkflowAction { } protected void traverseCatalogDbService(DelegateExecution execution, ServiceInstancesRequest sIRequest, - List<Resource> resourceCounter, List<Pair<WorkflowType, String>> aaiResourceIds) { + List<Resource> resourceCounter, List<Pair<WorkflowType, String>> aaiResourceIds) + throws JsonProcessingException, VrfBondingServiceException { String modelUUID = sIRequest.getRequestDetails().getModelInfo().getModelVersionId(); org.onap.so.db.catalog.beans.Service service = catalogDbClient.getServiceByID(modelUUID); if (service == null) { @@ -646,27 +647,24 @@ public class WorkflowAction { protected void traverseVrfConfiguration(DelegateExecution execution, List<Pair<WorkflowType, String>> aaiResourceIds, List<Resource> resourceCounter, org.onap.so.db.catalog.beans.Service service, RelatedInstance relatedVpnBinding, - RelatedInstance relatedLocalNetwork) { - try { - org.onap.aai.domain.yang.L3Network aaiLocalNetwork = - bbInputSetupUtils.getAAIL3Network(relatedLocalNetwork.getInstanceId()); - vrfValidation.vrfServiceValidation(service); - vrfValidation.vrfCatalogDbChecks(service); - vrfValidation - .aaiVpnBindingValidation(bbInputSetupUtils.getAAIVpnBinding(relatedVpnBinding.getInstanceId())); - vrfValidation.aaiSubnetValidation(aaiLocalNetwork); - vrfValidation.aaiAggregateRouteValidation(aaiLocalNetwork); - vrfValidation.aaiRouteTargetValidation(aaiLocalNetwork); - String existingAAIVrfConfiguration = getExistingAAIVrfConfiguration(relatedVpnBinding, aaiLocalNetwork); - if (existingAAIVrfConfiguration != null) { - aaiResourceIds - .add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, existingAAIVrfConfiguration)); - } - resourceCounter.add(new Resource(WorkflowType.CONFIGURATION, - service.getConfigurationCustomizations().get(0).getModelCustomizationUUID(), false)); - } catch (VrfBondingServiceException | JsonProcessingException e) { - buildAndThrowException(execution, e.getMessage()); + RelatedInstance relatedLocalNetwork) throws VrfBondingServiceException, JsonProcessingException { + org.onap.aai.domain.yang.L3Network aaiLocalNetwork = + bbInputSetupUtils.getAAIL3Network(relatedLocalNetwork.getInstanceId()); + vrfValidation.vrfServiceValidation(service); + vrfValidation.vrfCatalogDbChecks(service); + vrfValidation.aaiVpnBindingValidation(relatedVpnBinding.getInstanceId(), + bbInputSetupUtils.getAAIVpnBinding(relatedVpnBinding.getInstanceId())); + vrfValidation.aaiNetworkValidation(relatedLocalNetwork.getInstanceId(), aaiLocalNetwork); + vrfValidation.aaiSubnetValidation(aaiLocalNetwork); + vrfValidation.aaiAggregateRouteValidation(aaiLocalNetwork); + vrfValidation.aaiRouteTargetValidation(aaiLocalNetwork); + String existingAAIVrfConfiguration = getExistingAAIVrfConfiguration(relatedVpnBinding, aaiLocalNetwork); + if (existingAAIVrfConfiguration != null) { + aaiResourceIds.add(new Pair<WorkflowType, String>(WorkflowType.CONFIGURATION, existingAAIVrfConfiguration)); } + resourceCounter.add(new Resource(WorkflowType.CONFIGURATION, + service.getConfigurationCustomizations().get(0).getModelCustomizationUUID(), false)); + } protected String getExistingAAIVrfConfiguration(RelatedInstance relatedVpnBinding, diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java index 526ebe8581..3a8c318cc2 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/VrfValidationTest.java @@ -96,7 +96,29 @@ public class VrfValidationTest extends BaseTaskTest { org.onap.aai.domain.yang.VpnBinding aaiVpnBinding = new org.onap.aai.domain.yang.VpnBinding(); aaiVpnBinding.setVpnType("SERVICE-INFRASTRUCTURE"); ExpectedException.none(); - vrfValidation.aaiVpnBindingValidation(aaiVpnBinding); + vrfValidation.aaiVpnBindingValidation("test-vpn", aaiVpnBinding); + } + + @Test + public void testAaiVpnBindingValidationVpnBindingIsNull() throws VrfBondingServiceException { + exceptionRule.expect(VrfBondingServiceException.class); + exceptionRule.expectMessage("The infrastructure vpn test-vpn does not exist in A&AI."); + vrfValidation.aaiVpnBindingValidation("test-vpn", null); + } + + @Test + public void testAaiNetworkValidation() throws VrfBondingServiceException { + org.onap.aai.domain.yang.L3Network aaiLocalNetwork = new org.onap.aai.domain.yang.L3Network(); + aaiLocalNetwork.setNetworkId("test-network"); + ExpectedException.none(); + vrfValidation.aaiNetworkValidation("test-network", aaiLocalNetwork); + } + + @Test + public void testAaiNetworkValidationNetworkIsNull() throws VrfBondingServiceException { + exceptionRule.expect(VrfBondingServiceException.class); + exceptionRule.expectMessage("The local network test-network does not exist in A&AI."); + vrfValidation.aaiNetworkValidation("test-network", null); } @Test diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java index 10d36f9527..ece3682d65 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionTest.java @@ -1552,7 +1552,7 @@ public class WorkflowActionTest extends BaseTaskTest { @Ignore @Test - public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException { + public void traverseCatalogDbServiceMultipleNetworkTest() throws IOException, VrfBondingServiceException { execution.setVariable("testProcessKey", "testProcessKeyValue"); Service service = new Service(); List<NetworkResourceCustomization> networkCustomizations = new ArrayList<>(); |