fixed aai response code in updateAAIVfModule 66/74466/1
authorKalkere Ramesh, Sharan (sk720x) <sk720x@att.com>
Mon, 10 Dec 2018 20:45:55 +0000 (15:45 -0500)
committerKalkere Ramesh, Sharan (sk720x) <sk720x@att.com>
Mon, 10 Dec 2018 20:46:22 +0000 (15:46 -0500)
Added PUAAIVfMod_updateVfModuleResponseCode to be set to execution
Added responseCode verification in unit tests
Set UAAIVfMod_updateVfModuleResponseCode

Change-Id: I0d429388ff49ae78241ad1b0f33815a80f749061
Issue-ID: SO-1313
Signed-off-by: Kalkere Ramesh, Sharan (sk720x) <sk720x@att.com>
bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/PrepareUpdateAAIVfModule.groovy
bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModule.groovy
bpmn/MSOCommonBPMN/src/test/groovy/org/onap/so/bpmn/common/scripts/UpdateAAIVfModuleTest.groovy

index 8f0e481..15f00ac 100644 (file)
@@ -223,7 +223,7 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
                        AAIResourcesClient client = new AAIResourcesClient()
                        AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)
                        client.update(uri, vfModule)
-
+                       execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', 200)
                        // Set the output for this flow.  The updated VfModule is an output, the generic VNF name, and for
                        // backward compatibilty, the heat-stack-id is an output
                        execution.setVariable('PUAAIVfMod_outVfModule', vfModule)
@@ -238,9 +238,11 @@ public class PrepareUpdateAAIVfModule extends VfModuleBase {
 
                        msoLogger.trace('Exited ' + method)
                } catch (BpmnError e) {
+                       execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', 500)
                        throw e;
                } catch (Exception e) {
                        msoLogger.error(e)
+                       execution.setVariable('PUAAIVfMod_updateVfModuleResponseCode', 500)
                        exceptionUtil.buildAndThrowWorkflowException(execution, 1002, 'Error in updateVfModule(): ' + e.getMessage())
                }
        }
index a6568fb..3c4edd2 100644 (file)
@@ -184,11 +184,17 @@ public class UpdateAAIVfModule extends AbstractServiceTaskProcessor {
             try {
                 AAIResourceUri resourceUri = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)
                 getAAIClient().update(resourceUri, payload)
+                               execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', 200)
+                               execution.setVariable('UAAIVfMod_updateVfModuleResponse', "Success")
             }catch(NotFoundException ignored){
                 msoLogger.debug("VF-Module not found!!")
+                               execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', 404)
+                execution.setVariable('UAAIVfMod_updateVfModuleResponse', ignored.getMessage())
                 exceptionUtil.buildAndThrowWorkflowException(execution, 2500, "vf-module " + vfModuleId + " not found for under vnf " + vnfId + " in A&AI!")
             }
             catch(Exception ex){
+                               execution.setVariable('UAAIVfMod_updateVfModuleResponseCode', 500)
+                               execution.setVariable('UAAIVfMod_updateVfModuleResponse', 'AAI PATCH Failed:' + ex.getMessage())
                                exceptionUtil.buildAndThrowWorkflowException(execution, 2500, 'Exception occurred while executing AAI PATCH:' + ex.getMessage())
             }
                } catch (BpmnError e) {
index cb9bb5c..2d2f58b 100644 (file)
@@ -113,6 +113,7 @@ class UpdateAAIVfModuleTest  extends MsoGroovyTest {
         when(mockExecution.getVariable(prefix + "getVfModuleResponse")).thenReturn(vfModule)
         doNothing().when(client).update(isA(AAIResourceUri.class), anyObject())
         updateAAIVfModule.updateVfModule(mockExecution)
+               verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 200)
     }
 
     @Test
@@ -128,6 +129,7 @@ class UpdateAAIVfModuleTest  extends MsoGroovyTest {
         doThrow(new NotFoundException("Vf Module not found")).when(client).update(isA(AAIResourceUri.class), anyObject())
         thrown.expect(BpmnError.class)
         updateAAIVfModule.updateVfModule(mockExecution)
+               verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 404)
     }
 
 
@@ -144,6 +146,7 @@ class UpdateAAIVfModuleTest  extends MsoGroovyTest {
         doThrow(new IllegalStateException("Error in AAI client")).when(client).update(isA(AAIResourceUri.class), anyObject())
         thrown.expect(BpmnError.class)
         updateAAIVfModule.updateVfModule(mockExecution)
+               verify(mockExecution).setVariable("UAAIVfMod_updateVfModuleResponseCode", 500)
 
     }
 }