10/31: merge casablanca to master 47/71547/2
authorRob Daugherty <rd472p@att.com>
Wed, 31 Oct 2018 14:21:22 +0000 (10:21 -0400)
committerRob Daugherty <rd472p@att.com>
Wed, 31 Oct 2018 14:38:00 +0000 (10:38 -0400)
Commit: 649c4e85cc991ffe9c13fd3fab4cc3a303faa656
Subject: Fix Error, Check that vimID is present
Issue: SO-1156
https://gerrit.onap.org/r/#/c/71247/

Commit: 959493d3274d2f2749586248cf31ee12b730e2af
Subject: Bug fixes October 26th
Issue: SO-1169
https://gerrit.onap.org/r/#/c/71343/

Commit: 373c057bfa82583f615ea46814ad3cdf9ea8d669
Subject: Resolve vf_module_id setting bug
Issue: SO-1165
https://gerrit.onap.org/r/#/c/71270/

Commit: 6c2c8a66fade016f74b51bdfea3ba04494530b97
Issue: SO-1102
Subject: Pnf Spring Environment correction
https://gerrit.onap.org/r/#/c/71137/

Change-Id: I22b4566050f627e1f1428aacdb52ec4d4fe75733
Issue-ID: SO-1173
Signed-off-by: Rob Daugherty <rd472p@att.com>
1  2 
bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegate.java
bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfCheckInputsTest.java

  
  package org.onap.so.bpmn.infrastructure.pnf.delegate;
  
- import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_IP;
  import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.AAI_CONTAINS_INFO_ABOUT_PNF;
  import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
  
  import java.io.IOException;
 +
  import org.camunda.bpm.engine.delegate.DelegateExecution;
  import org.camunda.bpm.engine.delegate.JavaDelegate;
  import org.onap.so.bpmn.common.scripts.ExceptionUtil;
  import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection;
 -import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiResponse;
 -import org.onap.so.bpmn.infrastructure.pnf.implementation.CheckAaiForCorrelationIdImplementation;
 -import org.onap.so.logger.MsoLogger;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  
   * - correlationId - String
   *
   * Outputs:
 - * - AAI_CONTAINS_INFO_ABOUT_PNF - local Boolean
 - * - aaiContainsInfoAboutIp - local Boolean
 + * - aaiContainsInfoAboutPnf - local Boolean
   */
  
  @Component
  public class CheckAaiForCorrelationIdDelegate implements JavaDelegate {
 -      private static MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.GENERAL, CheckAaiForCorrelationIdDelegate.class);
 -    private CheckAaiForCorrelationIdImplementation implementation = new CheckAaiForCorrelationIdImplementation();
      private AaiConnection aaiConnection;
  
      @Autowired
      }
  
      @Override
 -    public void execute(DelegateExecution execution) throws Exception {
 +    public void execute(DelegateExecution execution) {
          String correlationId = (String) execution.getVariable(CORRELATION_ID);
          if (correlationId == null) {
              new ExceptionUtil().buildAndThrowWorkflowException(execution, 500, CORRELATION_ID + " is not set");
          }
 -
          try {
 -            AaiResponse aaiResponse = implementation.check(correlationId, aaiConnection);
 -
 -            execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, aaiResponse.getContainsInfoAboutPnf());
 +            boolean isEntry = aaiConnection.getEntryFor(correlationId).isPresent();
 +            execution.setVariableLocal(AAI_CONTAINS_INFO_ABOUT_PNF, isEntry);
          } catch (IOException e) {
 -              LOGGER.error("IOException",e);
              new ExceptionUtil().buildAndThrowWorkflowException(execution, 9999, e.getMessage());
          }
      }
@@@ -37,6 -37,7 +37,7 @@@ public class PnfCheckInputsTest 
      private static final String DEFAULT_TIMEOUT = "P1D";
  
      private DelegateExecution mockDelegateExecution() {
+         new PnfCheckInputs(DEFAULT_TIMEOUT);
          DelegateExecution delegateExecution = mock(DelegateExecution.class);
          when(delegateExecution.getVariable("testProcessKey")).thenReturn("testProcessKeyValue");
          return delegateExecution;
          assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
      }
  
 +    @Test
 +    public void shouldThrowException_whenPnfIdIsEmptyString() throws Exception {
 +        // given
 +        PnfCheckInputs testedObject = new PnfCheckInputs(DEFAULT_TIMEOUT);
 +        DelegateExecution delegateExecution = mockDelegateExecution();
 +        when(delegateExecution.getVariable(CORRELATION_ID)).thenReturn("");
 +        // when, then
 +        assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
 +    }
 +
      private DelegateExecution mockDelegateExecutionWithCorrelationId() {
+         new PnfCheckInputs(DEFAULT_TIMEOUT);
          DelegateExecution delegateExecution = mockDelegateExecution();
          when(delegateExecution.getVariable(CORRELATION_ID)).thenReturn("testCorrelationId");
          return delegateExecution;
          assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
      }
  
 +    @Test
 +    public void shouldThrowException_whenTimeoutIsEmptyStringAndDefaultIsNotDefined() throws Exception {
 +        // given
 +        PnfCheckInputs testedObject = new PnfCheckInputs(null);
 +        DelegateExecution delegateExecution = mockDelegateExecutionWithCorrelationId();
 +        when(delegateExecution.getVariable(TIMEOUT_FOR_NOTIFICATION)).thenReturn("");
 +        // when, then
 +        assertThatThrownBy(() -> testedObject.execute(delegateExecution)).isInstanceOf(BpmnError.class);
 +    }
 +
      @Test
      public void shouldSetDefaultTimeout_whenTimeoutIsNotSet() {
          // given
@@@ -96,4 -78,4 +98,4 @@@
          // then
          verify(delegateExecution).setVariable(eq(TIMEOUT_FOR_NOTIFICATION), eq(DEFAULT_TIMEOUT));
      }
--}
++}