Merge "Added setting pnf name in pnf-pnp"
authorSeshu Kumar M <seshu.kumar.m@huawei.com>
Tue, 22 May 2018 10:03:01 +0000 (10:03 +0000)
committerGerrit Code Review <gerrit@onap.org>
Tue, 22 May 2018 10:03:01 +0000 (10:03 +0000)
bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java
bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java
bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java [new file with mode: 0644]
bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java

index bc424fd..62b806e 100644 (file)
@@ -49,6 +49,7 @@ public class CreateAaiEntryWithPnfIdDelegate implements JavaDelegate {
         Pnf pnf = new Pnf();
         pnf.setInMaint(true);
         pnf.setPnfId(correlationId);
+        pnf.setPnfName(correlationId);
         aaiConnection.createEntry(correlationId, pnf);
     }
 }
index 1ad1f9e..bffae8d 100644 (file)
 package org.openecomp.mso.bpmn.infrastructure.pnf.delegate;
 
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
 import org.onap.aai.domain.yang.Pnf;
@@ -37,7 +39,7 @@ public class AaiConnectionTestImpl implements AaiConnection {
     public static final String DEFAULT_IP = "1.2.3.4";
     public static final String DEFAULT_IP_V6 = "2001:db8::ff00:42:8329";
 
-    private List<String> created = new LinkedList<>();
+    private Map<String, Pnf> created = new HashMap<>();
 
     @Override
     public Optional<Pnf> getEntryFor(String correlationId) throws IOException {
@@ -58,10 +60,10 @@ public class AaiConnectionTestImpl implements AaiConnection {
 
     @Override
     public void createEntry(String correlationId, Pnf entry) throws IOException {
-        created.add(correlationId);
+        created.put(correlationId, entry);
     }
 
-    public List<String> getCreated() {
+    public Map<String, Pnf> getCreated() {
         return created;
     }
 
diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java
new file mode 100644 (file)
index 0000000..3a65eaf
--- /dev/null
@@ -0,0 +1,47 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.openecomp.mso.bpmn.infrastructure.pnf.delegate;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.openecomp.mso.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.CORRELATION_ID;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.junit.Test;
+
+public class CreateAaiEntryWithPnfIdDelegateTest {
+
+    @Test
+    public void shouldSetPnfIdAndPnfName() throws Exception {
+        // given
+        CreateAaiEntryWithPnfIdDelegate delegate = new CreateAaiEntryWithPnfIdDelegate();
+        AaiConnectionTestImpl aaiConnection = new AaiConnectionTestImpl();
+        delegate.setAaiConnection(aaiConnection);
+        DelegateExecution execution = mock(DelegateExecution.class);
+        when(execution.getVariable(eq(CORRELATION_ID))).thenReturn("testCorrelationId");
+        // when
+        delegate.execute(execution);
+        // then
+        assertThat(aaiConnection.getCreated().get("testCorrelationId").getPnfId()).isEqualTo("testCorrelationId");
+        assertThat(aaiConnection.getCreated().get("testCorrelationId").getPnfName()).isEqualTo("testCorrelationId");
+    }
+}
\ No newline at end of file
index cceb271..ada5a90 100644 (file)
@@ -136,7 +136,7 @@ public class CreateAndActivatePnfResourceTest {
                 "WaitForDmaapPnfReadyNotification",
                 "AaiEntryUpdated"
         );
-        assertThat(aaiConnection.getCreated()).containsExactly(ID_WITHOUT_ENTRY);
+        assertThat(aaiConnection.getCreated()).containsOnlyKeys(ID_WITHOUT_ENTRY);
     }
 
     private List<HistoricVariableInstance> getVariables(ProcessInstance instance) {