From 25423c50e504676f15c7a57c03aad40bfc35c7e6 Mon Sep 17 00:00:00 2001 From: Michael Dürre Date: Wed, 20 Jul 2022 09:32:50 +0200 Subject: migrate sdnr features to sulfur MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix sdnr code for sulfur Issue-ID: CCSDK-3692 Signed-off-by: Michael Dürre Change-Id: I0a62ade424bb978222e7ce6450215fb327f957b7 Signed-off-by: Michael Dürre --- sdnr/wt/devicemanager-core/provider/pom.xml | 36 ++++++++++++++++------ .../impl/DeviceManagerApiServiceImpl.java | 29 +++++++++-------- .../util/NetworkElementConnectionEntitiyUtil.java | 5 +-- .../maintenance/impl/MaintenanceServiceImpl.java | 5 ++- .../wt/devicemanager/test/TestDevicemanager.java | 4 ++- 5 files changed, 53 insertions(+), 26 deletions(-) (limited to 'sdnr/wt/devicemanager-core/provider') diff --git a/sdnr/wt/devicemanager-core/provider/pom.xml b/sdnr/wt/devicemanager-core/provider/pom.xml index 05a6127d2..4c373d58d 100644 --- a/sdnr/wt/devicemanager-core/provider/pom.xml +++ b/sdnr/wt/devicemanager-core/provider/pom.xml @@ -22,13 +22,14 @@ ~ ============LICENSE_END======================================================= ~ --> + 4.0.0 org.onap.ccsdk.parent binding-parent - 2.4.0 + 2.4.1-SNAPSHOT @@ -52,13 +53,6 @@ - - - org.mockito - mockito-core - test - - ${project.groupId} sdnr-wt-devicemanager-core-model @@ -70,6 +64,12 @@ ${project.version} provided + + ${project.groupId} + sdnr-wt-data-provider-model + ${project.version} + provided + org.onap.ccsdk.features.sdnr.wt sdnr-wt-websocketmanager-model @@ -85,11 +85,12 @@ org.osgi org.osgi.core - provided + provided org.opendaylight.mdsal.model ietf-topology + provided org.opendaylight.netconf @@ -156,6 +157,23 @@ jaxb-runtime provided + + com.google.code.findbugs + annotations + provided + + + + org.mockito + mockito-core + test + + + javax.servlet + javax.servlet-api + test + + diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java index e31b79aea..4d5823a00 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java @@ -19,8 +19,14 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl; +import com.google.common.util.concurrent.ForwardingListenableFuture; import com.google.common.util.concurrent.ListenableFuture; + +import java.util.HashSet; import java.util.List; +import java.util.stream.Collectors; + +import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; import org.onap.ccsdk.features.sdnr.wt.devicemanager.housekeeping.ResyncNetworkElementsListener; import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceRPCServiceAPI; @@ -52,7 +58,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicema import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeOutput; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.TestMaintenanceModeOutputBuilder; import org.opendaylight.yangtools.concepts.ObjectRegistration; -import org.opendaylight.yangtools.yang.common.RpcError.ErrorType; +import org.opendaylight.yangtools.yang.common.ErrorType; import org.opendaylight.yangtools.yang.common.RpcResult; import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.slf4j.Logger; @@ -105,7 +111,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl try { GetRequiredNetworkElementKeysOutputBuilder outputBuilder = maintenanceService.getRequiredNetworkElementKeys(); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder.build()); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -123,7 +129,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl try { ShowRequiredNetworkElementOutputBuilder outputBuilder = maintenanceService.showRequiredNetworkElement(input); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder.build()); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -139,13 +145,12 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl try { SetMaintenanceModeOutputBuilder outputBuilder = maintenanceService.setMaintenanceMode(input); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder.build()); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); } return result.buildFuture(); - } @@ -154,11 +159,11 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl public ListenableFuture> getMaintenanceMode(GetMaintenanceModeInput input) { LOG.info("RPC Request: getMaintenanceMode input: {}", input.getMountpointName()); - RpcResultBuilder result; + @NonNull RpcResultBuilder result; try { GetMaintenanceModeOutputBuilder outputBuilder = maintenanceService.getMaintenanceMode(input); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder.build()); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -174,7 +179,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl try { TestMaintenanceModeOutputBuilder outputBuilder = maintenanceService.testMaintenanceMode(input); - result = RpcResultBuilder.success(outputBuilder); + result = RpcResultBuilder.success(outputBuilder.build()); } catch (Exception e) { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Exception", e); @@ -192,10 +197,10 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl try { if (this.resyncCallbackListener != null) { List nodeNames = - this.resyncCallbackListener.doClearCurrentFaultByNodename(input.getNodenames()); + this.resyncCallbackListener.doClearCurrentFaultByNodename(input.getNodenames().stream().collect(Collectors.toList())); ClearCurrentFaultByNodenameOutputBuilder outputBuilder = new ClearCurrentFaultByNodenameOutputBuilder(); - outputBuilder.setNodenames(nodeNames); - result = RpcResultBuilder.success(outputBuilder); + outputBuilder.setNodenames(new HashSet<>(nodeNames)); + result = RpcResultBuilder.success(outputBuilder.build()); } else { result = RpcResultBuilder.failed(); result.withError(ErrorType.APPLICATION, "Startup running"); @@ -251,6 +256,4 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl return result.buildFuture(); } - - } diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java index 4369af019..13eca8f25 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetworkElementConnectionEntitiyUtil.java @@ -17,6 +17,7 @@ */ package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util; +import java.util.HashSet; import java.util.Optional; import javax.annotation.Nonnull; import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InternalConnectionStatus; @@ -82,8 +83,8 @@ public class NetworkElementConnectionEntitiyUtil { Capabilities unAvailableCapabilities = Capabilities.getUnavailableCapabilities(nNode); NodeDetailsBuilder nodeDetails = - new NodeDetailsBuilder().setAvailableCapabilities(availableCapabilities.getCapabilities()) - .setUnavailableCapabilities(unAvailableCapabilities.getCapabilities()); + new NodeDetailsBuilder().setAvailableCapabilities(new HashSet<>(availableCapabilities.getCapabilities())) + .setUnavailableCapabilities(new HashSet<>(unAvailableCapabilities.getCapabilities())); eb.setNodeDetails(nodeDetails.build()); // -- host information Host host = nNode.getHost(); diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java index 6351f3958..b8b67fde4 100644 --- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java +++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java @@ -19,7 +19,10 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl; import java.time.ZonedDateTime; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; + import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance; import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceRPCServiceAPI; import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.MaintenanceService; @@ -79,7 +82,7 @@ public class MaintenanceServiceImpl implements MaintenanceService, MaintenanceRP public GetRequiredNetworkElementKeysOutputBuilder getRequiredNetworkElementKeys() { List all = database.getAll(); - List mountpointList = new ArrayList<>(); + Set mountpointList = new HashSet<>(); for (MaintenanceEntity oneOfAll : all) { mountpointList.add(oneOfAll.getNodeId()); diff --git a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java index 06b825934..07c4f6ae4 100644 --- a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java +++ b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java @@ -22,6 +22,8 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test; import static org.junit.Assert.assertTrue; import java.util.Arrays; +import java.util.HashSet; + import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -179,7 +181,7 @@ public class TestDevicemanager extends Mockito { log.info("testResync"); ClearCurrentFaultByNodenameInputBuilder inputBuilder = new ClearCurrentFaultByNodenameInputBuilder(); - inputBuilder.setNodenames(Arrays.asList("test1", "test2")); + inputBuilder.setNodenames(new HashSet<>(Arrays.asList("test1", "test2"))); apiService.clearCurrentFaultByNodename(inputBuilder.build()); } -- cgit 1.2.3-korg