From a48d97f0fff248d2b58be4a516227b77638e3982 Mon Sep 17 00:00:00 2001 From: Marcin Rzepecki Date: Tue, 20 Apr 2021 15:00:58 +0200 Subject: SO refactor - extract junit from WorkflowActionTest to ServiceEBBLoaderTest Issue-ID: SO-3489 Signed-off-by: Marcin Rzepecki Change-Id: I54b3a72e1ddd34b3039eccbb3ef3c32a3428ad99 --- .../tasks/WorkflowActionExtractResourcesAAI.java | 76 ---------------------- .../tasks/ebb/loader/ServiceEBBLoader.java | 1 - .../workflow/tasks/ebb/loader/VnfEBBLoader.java | 1 - .../loader/WorkflowActionExtractResourcesAAI.java | 76 ++++++++++++++++++++++ 4 files changed, 76 insertions(+), 78 deletions(-) delete mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java create mode 100644 bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/WorkflowActionExtractResourcesAAI.java (limited to 'bpmn/so-bpmn-tasks/src/main/java/org/onap') diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java deleted file mode 100644 index 4140692b44..0000000000 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/WorkflowActionExtractResourcesAAI.java +++ /dev/null @@ -1,76 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2019 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.workflow.tasks; - -import java.util.List; -import java.util.Optional; -import org.onap.aai.domain.yang.VpnBinding; -import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; -import org.onap.aaiclient.client.aai.entities.Relationships; -import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; -import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; -import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -@Component -public class WorkflowActionExtractResourcesAAI { - private static final Logger logger = LoggerFactory.getLogger(WorkflowActionExtractResourcesAAI.class); - - @Autowired - protected BBInputSetupUtils bbInputSetupUtils; - - public Optional extractRelationshipsConfiguration(Relationships relationships) { - List configurations = relationships.getByType(Types.CONFIGURATION); - for (AAIResultWrapper configWrapper : configurations) { - Optional config = configWrapper.asBean(Configuration.class); - if (config.isPresent()) { - return config; - } - } - return Optional.empty(); - } - - public Optional extractRelationshipsVpnBinding(Relationships relationships) { - List configurations = relationships.getRelatedUris(Types.VPN_BINDING); - for (AAIResourceUri vpnBindingUri : configurations) { - AAIResultWrapper vpnBindingWrapper = bbInputSetupUtils.getAAIResourceDepthOne(vpnBindingUri); - Optional vpnBinding = vpnBindingWrapper.asBean(VpnBinding.class); - if (vpnBinding.isPresent()) { - return vpnBinding; - } - } - return Optional.empty(); - } - - public Optional extractRelationshipsVnfc(Relationships relationships) { - List vnfcs = relationships.getByType(Types.VNFC); - for (AAIResultWrapper vnfcWrapper : vnfcs) { - if (vnfcWrapper.getRelationships().isPresent()) { - return vnfcWrapper.getRelationships(); - } - } - return Optional.empty(); - } -} diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java index 55a92b0b81..068c287ee7 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/ServiceEBBLoader.java @@ -12,7 +12,6 @@ import org.onap.aaiclient.client.aai.entities.Relationships; import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource; import org.onap.so.bpmn.infrastructure.workflow.tasks.VrfBondingServiceException; -import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionExtractResourcesAAI; import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java index 210d5195e5..b271226414 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/VnfEBBLoader.java @@ -32,7 +32,6 @@ import org.onap.aaiclient.client.aai.AAICommonObjectMapperProvider; import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.aaiclient.client.aai.entities.Relationships; import org.onap.so.bpmn.infrastructure.workflow.tasks.Resource; -import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowActionExtractResourcesAAI; import org.onap.so.bpmn.infrastructure.workflow.tasks.WorkflowType; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/WorkflowActionExtractResourcesAAI.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/WorkflowActionExtractResourcesAAI.java new file mode 100644 index 0000000000..7f1eb0ef07 --- /dev/null +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/workflow/tasks/ebb/loader/WorkflowActionExtractResourcesAAI.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 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.workflow.tasks.ebb.loader; + +import java.util.List; +import java.util.Optional; +import org.onap.aai.domain.yang.VpnBinding; +import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; +import org.onap.aaiclient.client.aai.entities.Relationships; +import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; +import org.onap.so.bpmn.servicedecomposition.tasks.BBInputSetupUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Component +public class WorkflowActionExtractResourcesAAI { + private static final Logger logger = LoggerFactory.getLogger(WorkflowActionExtractResourcesAAI.class); + + @Autowired + protected BBInputSetupUtils bbInputSetupUtils; + + public Optional extractRelationshipsConfiguration(Relationships relationships) { + List configurations = relationships.getByType(Types.CONFIGURATION); + for (AAIResultWrapper configWrapper : configurations) { + Optional config = configWrapper.asBean(Configuration.class); + if (config.isPresent()) { + return config; + } + } + return Optional.empty(); + } + + public Optional extractRelationshipsVpnBinding(Relationships relationships) { + List configurations = relationships.getRelatedUris(Types.VPN_BINDING); + for (AAIResourceUri vpnBindingUri : configurations) { + AAIResultWrapper vpnBindingWrapper = bbInputSetupUtils.getAAIResourceDepthOne(vpnBindingUri); + Optional vpnBinding = vpnBindingWrapper.asBean(VpnBinding.class); + if (vpnBinding.isPresent()) { + return vpnBinding; + } + } + return Optional.empty(); + } + + public Optional extractRelationshipsVnfc(Relationships relationships) { + List vnfcs = relationships.getByType(Types.VNFC); + for (AAIResultWrapper vnfcWrapper : vnfcs) { + if (vnfcWrapper.getRelationships().isPresent()) { + return vnfcWrapper.getRelationships(); + } + } + return Optional.empty(); + } +} -- cgit 1.2.3-korg