From f7bf1c998895e1599e861a4bf7a56270552245ea Mon Sep 17 00:00:00 2001 From: Lukasz Muszkieta Date: Thu, 21 Feb 2019 13:28:55 +0100 Subject: Change interface name to be more suitable Change-Id: Ifb4f6bc7f3e18974e9a11a17d474ad989c043673 Issue-ID: SO-1274 Signed-off-by: Lukasz Muszkieta --- .../pnf/delegate/AaiConnectionTestImpl.java | 64 ---------------------- .../delegate/AaiConnectionThrowingException.java | 45 --------------- .../CheckAaiForCorrelationIdDelegateTest.java | 8 +-- .../delegate/CreatePnfEntryInAaiDelegateTest.java | 6 +- .../pnf/delegate/CreateRelationTest.java | 11 ++-- .../pnf/delegate/PnfManagementTestImpl.java | 64 ++++++++++++++++++++++ .../delegate/PnfManagementThrowingException.java | 45 +++++++++++++++ 7 files changed, 121 insertions(+), 122 deletions(-) delete mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java delete mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java create mode 100644 bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java (limited to 'bpmn/so-bpmn-infrastructure-common/src/test/java/org') diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java deleted file mode 100644 index 76b62a9cea..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionTestImpl.java +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * ============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.onap.so.bpmn.infrastructure.pnf.delegate; - -import org.onap.aai.domain.yang.Pnf; -import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.Optional; - -public class AaiConnectionTestImpl implements AaiConnection { - - public static final String ID_WITHOUT_ENTRY = "IdWithoutEntry"; - public static final String ID_WITH_ENTRY = "idWithEntryNoIp"; - - private Map created = new HashMap<>(); - - @Override - public Optional getEntryFor(String correlationId) { - if (Objects.equals(correlationId, ID_WITH_ENTRY)) { - return Optional.of(new Pnf()); - } else { - return Optional.empty(); - } - } - - @Override - public void createEntry(String correlationId, Pnf entry) throws IOException { - created.put(correlationId, entry); - } - - @Override - public void createRelation(String serviceInstanceId, String pnfName) { - } - - public Map getCreated() { - return created; - } - - public void reset() { - created.clear(); - } -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java deleted file mode 100644 index 300d1e4c9b..0000000000 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/AaiConnectionThrowingException.java +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * ============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.onap.so.bpmn.infrastructure.pnf.delegate; - -import java.io.IOException; -import java.util.Optional; -import org.onap.aai.domain.yang.Pnf; -import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; - -public class AaiConnectionThrowingException implements AaiConnection { - - @Override - public Optional getEntryFor(String correlationId) throws IOException { - throw new IOException(); - } - - @Override - public void createEntry(String correlationId, Pnf entry) throws IOException { - throw new IOException(); - } - - @Override - public void createRelation(String serviceInstanceId, String pnfName) throws IOException { - throw new IOException(); - } - -} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java index eeda355f80..4b47ed6407 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CheckAaiForCorrelationIdDelegateTest.java @@ -25,8 +25,8 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITHOUT_ENTRY; -import static org.onap.so.bpmn.infrastructure.pnf.delegate.AaiConnectionTestImpl.ID_WITH_ENTRY; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl.ID_WITHOUT_ENTRY; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.PnfManagementTestImpl.ID_WITH_ENTRY; 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; @@ -53,7 +53,7 @@ public class CheckAaiForCorrelationIdDelegateTest { @Before public void setUp() { delegate = new CheckAaiForCorrelationIdDelegate(); - delegate.setAaiConnection(new AaiConnectionTestImpl()); + delegate.setPnfManagement(new PnfManagementTestImpl()); } @Test @@ -101,7 +101,7 @@ public class CheckAaiForCorrelationIdDelegateTest { @Before public void setUp() { delegate = new CheckAaiForCorrelationIdDelegate(); - delegate.setAaiConnection(new AaiConnectionThrowingException()); + delegate.setPnfManagement(new PnfManagementThrowingException()); } @Test diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java index c487125ea6..9c5f8f3fc4 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreatePnfEntryInAaiDelegateTest.java @@ -40,15 +40,15 @@ public class CreatePnfEntryInAaiDelegateTest { // given String pnfUuid = UUID.nameUUIDFromBytes("testUuid".getBytes()).toString(); CreatePnfEntryInAaiDelegate delegate = new CreatePnfEntryInAaiDelegate(); - AaiConnectionTestImpl aaiConnection = new AaiConnectionTestImpl(); - delegate.setAaiConnection(aaiConnection); + PnfManagementTestImpl pnfManagementTest = new PnfManagementTestImpl(); + delegate.setPnfManagement(pnfManagementTest); DelegateExecution execution = mock(DelegateExecution.class); given(execution.getVariable(eq(CORRELATION_ID))).willReturn("testCorrelationId"); given(execution.getVariable(eq(PNF_UUID))).willReturn(pnfUuid); // when delegate.execute(execution); // then - Pnf createdEntry = aaiConnection.getCreated().get("testCorrelationId"); + Pnf createdEntry = pnfManagementTest.getCreated().get("testCorrelationId"); assertThat(createdEntry.getPnfId()).isEqualTo(pnfUuid); assertThat(createdEntry.getPnfName()).isEqualTo("testCorrelationId"); assertThat(createdEntry.isInMaint()).isNull(); diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java index 2dd3e23828..2a78337e34 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateRelationTest.java @@ -29,8 +29,7 @@ import org.camunda.bpm.engine.delegate.BpmnError; import org.camunda.bpm.extension.mockito.delegate.DelegateExecutionFake; import org.junit.Before; import org.junit.Test; -import org.onap.so.bpmn.infrastructure.pnf.aai.AaiConnectionImpl; -import org.onap.so.bpmn.infrastructure.pnf.implementation.AaiConnection; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; public class CreateRelationTest { @@ -49,17 +48,17 @@ public class CreateRelationTest { @Test public void createRelationSuccessful() throws IOException { // given - AaiConnection aaiConnectionMock = mock(AaiConnectionImpl.class); - CreateRelation testedObject = new CreateRelation(aaiConnectionMock); + PnfManagement pnfManagementMock = mock(PnfManagement.class); + CreateRelation testedObject = new CreateRelation(pnfManagementMock); // when testedObject.execute(executionFake); // then - verify(aaiConnectionMock).createRelation(SERVICE_INSTANCE_ID, PNF_NAME); + verify(pnfManagementMock).createRelation(SERVICE_INSTANCE_ID, PNF_NAME); } @Test public void shouldThrowBpmnErrorWhenExceptionOccurred() { - CreateRelation testedObject = new CreateRelation(new AaiConnectionThrowingException()); + CreateRelation testedObject = new CreateRelation(new PnfManagementThrowingException()); executionFake.setVariable("testProcessKey", "testProcessKeyValue"); assertThatThrownBy(() -> testedObject.execute(executionFake)).isInstanceOf(BpmnError.class); diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java new file mode 100644 index 0000000000..1377c8295f --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementTestImpl.java @@ -0,0 +1,64 @@ +/*- + * ============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.onap.so.bpmn.infrastructure.pnf.delegate; + +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; + +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.Optional; + +public class PnfManagementTestImpl implements PnfManagement { + + public static final String ID_WITHOUT_ENTRY = "IdWithoutEntry"; + public static final String ID_WITH_ENTRY = "idWithEntryNoIp"; + + private Map created = new HashMap<>(); + + @Override + public Optional getEntryFor(String correlationId) { + if (Objects.equals(correlationId, ID_WITH_ENTRY)) { + return Optional.of(new Pnf()); + } else { + return Optional.empty(); + } + } + + @Override + public void createEntry(String correlationId, Pnf entry) throws IOException { + created.put(correlationId, entry); + } + + @Override + public void createRelation(String serviceInstanceId, String pnfName) { + } + + public Map getCreated() { + return created; + } + + public void reset() { + created.clear(); + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java new file mode 100644 index 0000000000..43315d3803 --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/PnfManagementThrowingException.java @@ -0,0 +1,45 @@ +/*- + * ============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.onap.so.bpmn.infrastructure.pnf.delegate; + +import java.io.IOException; +import java.util.Optional; +import org.onap.aai.domain.yang.Pnf; +import org.onap.so.bpmn.infrastructure.pnf.management.PnfManagement; + +public class PnfManagementThrowingException implements PnfManagement { + + @Override + public Optional getEntryFor(String correlationId) throws IOException { + throw new IOException(); + } + + @Override + public void createEntry(String correlationId, Pnf entry) throws IOException { + throw new IOException(); + } + + @Override + public void createRelation(String serviceInstanceId, String pnfName) throws IOException { + throw new IOException(); + } + +} -- cgit 1.2.3-korg