From ac9c52250c1e013f61dc922a8f27a1bd274976a8 Mon Sep 17 00:00:00 2001 From: biniek Date: Wed, 9 May 2018 10:47:03 +0200 Subject: Added setting pnf name in pnf-pnp Change-Id: I2f35d1a8cc01f349f791b1bc192f91f5f020f689 Issue-ID: SO-506 Signed-off-by: biniek --- .../delegate/CreateAaiEntryWithPnfIdDelegate.java | 1 + .../pnf/delegate/AaiConnectionTestImpl.java | 8 ++-- .../CreateAaiEntryWithPnfIdDelegateTest.java | 47 ++++++++++++++++++++++ .../bpmn/CreateAndActivatePnfResourceTest.java | 2 +- 4 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java (limited to 'bpmn') diff --git a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java index bc424fd347..62b806eae8 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java +++ b/bpmn/MSOInfrastructureBPMN/src/main/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegate.java @@ -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); } } diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java index 1ad1f9e5a4..bffae8d892 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java @@ -21,8 +21,10 @@ 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 created = new LinkedList<>(); + private Map created = new HashMap<>(); @Override public Optional 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 getCreated() { + public Map 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 index 0000000000..3a65eaf531 --- /dev/null +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/CreateAaiEntryWithPnfIdDelegateTest.java @@ -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 diff --git a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java index cceb271778..ada5a902a7 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java +++ b/bpmn/MSOInfrastructureBPMN/src/test/java/org/openecomp/mso/bpmn/infrastructure/pnf/delegate/bpmn/CreateAndActivatePnfResourceTest.java @@ -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 getVariables(ProcessInstance instance) { -- cgit 1.2.3-korg