diff options
author | Michael Dürre <michael.duerre@highstreet-technologies.com> | 2022-07-20 09:32:50 +0200 |
---|---|---|
committer | Michael Dürre <michael.duerre@highstreet-technologies.com> | 2022-07-21 12:38:52 +0200 |
commit | 25423c50e504676f15c7a57c03aad40bfc35c7e6 (patch) | |
tree | 811649e2ec44e0332e601c6563e00e914d355b9a /sdnr/wt/devicemanager-core/provider | |
parent | cea47224b7b6afdd7b3d3ead8d08baf46eadc575 (diff) |
migrate sdnr features to sulfur
fix sdnr code for sulfur
Issue-ID: CCSDK-3692
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Change-Id: I0a62ade424bb978222e7ce6450215fb327f957b7
Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager-core/provider')
5 files changed, 53 insertions, 26 deletions
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======================================================= ~ --> + <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.onap.ccsdk.parent</groupId> <artifactId>binding-parent</artifactId> - <version>2.4.0</version> + <version>2.4.1-SNAPSHOT</version> <relativePath/> </parent> @@ -52,13 +53,6 @@ </properties> <dependencies> - <!-- begin for testing --> - <dependency> - <groupId>org.mockito</groupId> - <artifactId>mockito-core</artifactId> - <scope>test</scope> - </dependency> - <!-- end for testing --> <dependency> <groupId>${project.groupId}</groupId> <artifactId>sdnr-wt-devicemanager-core-model</artifactId> @@ -71,6 +65,12 @@ <scope>provided</scope> </dependency> <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>sdnr-wt-data-provider-model</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.onap.ccsdk.features.sdnr.wt</groupId> <artifactId>sdnr-wt-websocketmanager-model</artifactId> <version>${project.version}</version> @@ -85,11 +85,12 @@ <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> - <scope>provided</scope> + <scope>provided</scope> </dependency> <dependency> <groupId>org.opendaylight.mdsal.model</groupId> <artifactId>ietf-topology</artifactId> + <scope>provided</scope> </dependency> <dependency> <groupId>org.opendaylight.netconf</groupId> @@ -156,6 +157,23 @@ <artifactId>jaxb-runtime</artifactId> <scope>provided</scope> </dependency> + <dependency> + <groupId>com.google.code.findbugs</groupId> + <artifactId>annotations</artifactId> + <scope>provided</scope> + </dependency> + <!-- begin for testing --> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-core</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>javax.servlet</groupId> + <artifactId>javax.servlet-api</artifactId> + <scope>test</scope> + </dependency> + <!-- end for testing --> </dependencies> <build> 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<RpcResult<GetMaintenanceModeOutput>> getMaintenanceMode(GetMaintenanceModeInput input) { LOG.info("RPC Request: getMaintenanceMode input: {}", input.getMountpointName()); - RpcResultBuilder<GetMaintenanceModeOutput> result; + @NonNull RpcResultBuilder<GetMaintenanceModeOutput> 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<String> 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<MaintenanceEntity> all = database.getAll(); - List<String> mountpointList = new ArrayList<>(); + Set<String> 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()); } |