From 0720a8a4e336d516ee00c515a392bb48a23404fd Mon Sep 17 00:00:00 2001 From: sushant53 Date: Thu, 29 Feb 2024 11:51:05 +0530 Subject: [SO] Code improvement in bpmn-infra supporting kafka change Code improvement in bpmn-infra supporting kafka change Issue-ID: SO-4122 Change-Id: I3924418d16f8f6d9270278f1894e224a216d1cf2 Signed-off-by: sushant53 --- .../delegate/CreateAndActivatePnfResourceTest.java | 20 +++---- .../pnf/delegate/DmaapClientTestImpl.java | 68 ---------------------- .../pnf/delegate/KafkaClientTestImpl.java | 67 +++++++++++++++++++++ 3 files changed, 77 insertions(+), 78 deletions(-) delete mode 100644 bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java create mode 100644 bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/KafkaClientTestImpl.java (limited to 'bpmn/mso-infrastructure-bpmn/src/test') diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java index 0c001b1192..32ec69e5fa 100644 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/CreateAndActivatePnfResourceTest.java @@ -49,7 +49,7 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { private PnfManagementTestImpl pnfManagementTest; @Autowired - private DmaapClientTestImpl dmaapClientTestImpl; + private KafkaClientTestImpl kafkaClientTestImpl; @Before public void setup() { @@ -60,7 +60,7 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { } @Test - public void shouldWaitForMessageFromDmaapAndUpdateAaiEntryWhenAaiEntryExists() { + public void shouldWaitForMessageFromKafkaAndUpdateAaiEntryWhenAaiEntryExists() { // given variables.put(PNF_CORRELATION_ID, PnfManagementTestImpl.ID_WITH_ENTRY); ResourceInput ri = getUpdateResInputObj("OLT"); @@ -72,19 +72,19 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { // when ProcessInstance instance = runtimeService.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); - assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); - dmaapClientTestImpl.sendMessage(); + assertThat(instance).isWaitingAt("WaitForKafkaPnfReadyNotification").isWaitingFor("WorkflowMessage"); + kafkaClientTestImpl.sendMessage(); // then assertThat(instance).isEnded().hasPassedInOrder("CreateAndActivatePnf_StartEvent", "CheckInputs", - "CheckAiiForPnfCorrelationId", "DoesAaiContainInfoAboutPnf", "AaiEntryExists", "InformDmaapClient", - "WaitForDmaapPnfReadyNotification", "CreateRelationId", "AaiEntryUpdated"); + "CheckAiiForPnfCorrelationId", "DoesAaiContainInfoAboutPnf", "AaiEntryExists", "InformKafkaClient", + "WaitForKafkaPnfReadyNotification", "CreateRelationId", "AaiEntryUpdated"); Assertions.assertThat(pnfManagementTest.getServiceAndPnfRelationMap()) .containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID, PnfManagementTestImpl.ID_WITH_ENTRY)); } @Test - public void shouldCreateAaiEntryWaitForMessageFromDmaapAndUpdateAaiEntryWhenNoAaiEntryExists() { + public void shouldCreateAaiEntryWaitForMessageFromKafkaAndUpdateAaiEntryWhenNoAaiEntryExists() { // given variables.put(PNF_CORRELATION_ID, PnfManagementTestImpl.ID_WITHOUT_ENTRY); ResourceInput ri = getUpdateResInputObj("OLT"); @@ -96,13 +96,13 @@ public class CreateAndActivatePnfResourceTest extends BaseIntegrationTest { // when ProcessInstance instance = runtimeService.startProcessInstanceByKey("CreateAndActivatePnfResource", "businessKey", variables); - assertThat(instance).isWaitingAt("WaitForDmaapPnfReadyNotification").isWaitingFor("WorkflowMessage"); - dmaapClientTestImpl.sendMessage(); + assertThat(instance).isWaitingAt("WaitForKafkaPnfReadyNotification").isWaitingFor("WorkflowMessage"); + kafkaClientTestImpl.sendMessage(); // then assertThat(instance).isEnded().hasPassedInOrder("CreateAndActivatePnf_StartEvent", "CheckInputs", "CheckAiiForPnfCorrelationId", "DoesAaiContainInfoAboutPnf", "CreatePnfEntryInAai", "AaiEntryExists", - "InformDmaapClient", "WaitForDmaapPnfReadyNotification", "CreateRelationId", "AaiEntryUpdated"); + "InformKafkaClient", "WaitForKafkaPnfReadyNotification", "CreateRelationId", "AaiEntryUpdated"); Assertions.assertThat(pnfManagementTest.getCreated()).containsOnlyKeys(PnfManagementTestImpl.ID_WITHOUT_ENTRY); Assertions.assertThat(pnfManagementTest.getServiceAndPnfRelationMap()) .containsOnly(MapEntry.entry(SERVICE_INSTANCE_ID, PnfManagementTestImpl.ID_WITHOUT_ENTRY)); diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java deleted file mode 100644 index 43fbc59b3d..0000000000 --- a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/DmaapClientTestImpl.java +++ /dev/null @@ -1,68 +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.util.Map; -import java.util.Objects; -import org.onap.so.bpmn.infrastructure.pnf.dmaap.DmaapClient; -import org.springframework.context.annotation.Primary; -import org.springframework.stereotype.Component; - -@Component -@Primary -public class DmaapClientTestImpl implements DmaapClient { - - private String pnfCorrelationId; - private Runnable informConsumer; - - @Override - public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer) { - this.pnfCorrelationId = pnfCorrelationId; - this.informConsumer = informConsumer; - } - - @Override - public Runnable unregister(String pnfCorrelationId) { - if (Objects.equals(this.pnfCorrelationId, pnfCorrelationId)) { - this.pnfCorrelationId = null; - Runnable informConsumer = this.informConsumer; - this.informConsumer = null; - return informConsumer; - } - return null; - } - - public String getPnfCorrelationId() { - return pnfCorrelationId; - } - - public Runnable getInformConsumer() { - return informConsumer; - } - - public void sendMessage() { - informConsumer.run(); - } - - public boolean haveRegisteredConsumer() { - return pnfCorrelationId != null; - } -} diff --git a/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/KafkaClientTestImpl.java b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/KafkaClientTestImpl.java new file mode 100644 index 0000000000..e4c1717752 --- /dev/null +++ b/bpmn/mso-infrastructure-bpmn/src/test/java/org/onap/so/bpmn/infrastructure/pnf/delegate/KafkaClientTestImpl.java @@ -0,0 +1,67 @@ +/*- + * ============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.util.Objects; +import org.onap.so.bpmn.infrastructure.pnf.kafka.KafkaClient; +import org.springframework.context.annotation.Primary; +import org.springframework.stereotype.Component; + +@Component +@Primary +public class KafkaClientTestImpl implements KafkaClient { + + private String pnfCorrelationId; + private Runnable informConsumer; + + @Override + public void registerForUpdate(String pnfCorrelationId, Runnable informConsumer) { + this.pnfCorrelationId = pnfCorrelationId; + this.informConsumer = informConsumer; + } + + @Override + public Runnable unregister(String pnfCorrelationId) { + if (Objects.equals(this.pnfCorrelationId, pnfCorrelationId)) { + this.pnfCorrelationId = null; + Runnable informConsumer = this.informConsumer; + this.informConsumer = null; + return informConsumer; + } + return null; + } + + public String getPnfCorrelationId() { + return pnfCorrelationId; + } + + public Runnable getInformConsumer() { + return informConsumer; + } + + public void sendMessage() { + informConsumer.run(); + } + + public boolean haveRegisteredConsumer() { + return pnfCorrelationId != null; + } +} -- cgit 1.2.3-korg