Do not use Binding DTO compat methods 12/84712/20
authorRobert Varga <robert.varga@pantheon.tech>
Wed, 25 Sep 2019 14:47:24 +0000 (16:47 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Sat, 12 Oct 2019 14:35:54 +0000 (16:35 +0200)
This removes the use of compat methods, preferring explicit
instantiation of the correct type.

Change-Id: Ie3b739e1e31ba2762cdda92444f4734a8ac47ae8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
benchmark/dsbenchmark/src/main/java/org/opendaylight/dsbenchmark/DsbenchmarkProvider.java
benchmark/ntfbenchmark/src/main/java/ntfbenchmark/impl/NtfbenchmarkProvider.java
benchmark/rpcbenchmark/src/main/java/rpcbenchmark/impl/RpcbenchmarkProvider.java
opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/md/sal/binding/impl/test/Bug4513Test.java
opendaylight/md-sal/sal-binding-it/src/test/java/org/opendaylight/controller/test/sal/binding/it/NotificationIT.java
opendaylight/md-sal/samples/clustering-test-app/provider/src/main/java/org/opendaylight/controller/clustering/it/provider/CarProvider.java
opendaylight/md-sal/samples/toaster-consumer/src/main/java/org/opendaylight/controller/sample/kitchen/impl/KitchenServiceImpl.java
opendaylight/md-sal/samples/toaster-provider/src/main/java/org/opendaylight/controller/sample/toaster/provider/OpendaylightToaster.java
opendaylight/md-sal/samples/toaster-provider/src/test/java/org/opendaylight/controller/sample/toaster/provider/OpenDaylightToasterTest.java

index 1547f2b..1315f1d 100644 (file)
@@ -45,6 +45,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.dsbenchm
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -153,10 +154,10 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
                 .setStatus(StartTestOutput.Status.OK)
                 .setListBuildTime(listCreateTime)
                 .setExecTime(execTime)
-                .setTxOk((long)dsWriter.getTxOk())
-                .setNtfOk(numEvents)
-                .setDataChangeEventsOk(numDataChanges)
-                .setTxError((long)dsWriter.getTxError())
+                .setTxOk(Uint32.valueOf(dsWriter.getTxOk()))
+                .setNtfOk(Uint32.valueOf(numEvents))
+                .setDataChangeEventsOk(Uint32.valueOf(numDataChanges))
+                .setTxError(Uint32.valueOf(dsWriter.getTxError()))
                 .build();
 
         return RpcResultBuilder.success(output).buildFuture();
@@ -165,7 +166,7 @@ public class DsbenchmarkProvider implements DsbenchmarkService, AutoCloseable {
     private void setTestOperData(final ExecStatus sts, final long tstCompl) {
         TestStatus status = new TestStatusBuilder()
                 .setExecStatus(sts)
-                .setTestsCompleted(tstCompl)
+                .setTestsCompleted(Uint32.valueOf(tstCompl))
                 .build();
 
         WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
index 39e8273..50b0478 100644 (file)
@@ -28,6 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ntfbench
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -120,13 +121,14 @@ public class NtfbenchmarkProvider implements AutoCloseable, NtfbenchmarkService
 
             final StartTestOutput output =
                     new StartTestOutputBuilder()
-                            .setProducerElapsedTime(producerElapsedTime / 1000000)
-                            .setListenerElapsedTime(listenerElapsedTime / 1000000)
-                            .setListenerOk(allListeners)
-                            .setProducerOk(allProducersOk)
-                            .setProducerError(allProducersError)
-                            .setProducerRate((allProducersOk + allProducersError) * 1000000000 / producerElapsedTime)
-                            .setListenerRate(allListeners * 1000000000 / listenerElapsedTime)
+                            .setProducerElapsedTime(Uint32.valueOf(producerElapsedTime / 1000000))
+                            .setListenerElapsedTime(Uint32.valueOf(listenerElapsedTime / 1000000))
+                            .setListenerOk(Uint32.valueOf(allListeners))
+                            .setProducerOk(Uint32.valueOf(allProducersOk))
+                            .setProducerError(Uint32.valueOf(allProducersError))
+                            .setProducerRate(Uint32.valueOf((allProducersOk + allProducersError) * 1000000000
+                                / producerElapsedTime))
+                            .setListenerRate(Uint32.valueOf(allListeners * 1000000000 / listenerElapsedTime))
                            .build();
             return RpcResultBuilder.success(output).buildFuture();
         } finally {
index ddcf254..6f2e924 100644 (file)
@@ -35,6 +35,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.binding.KeyedInstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -123,12 +124,12 @@ public class RpcbenchmarkProvider implements AutoCloseable, RpcbenchmarkService
             long elapsedTime = endTime - startTime;
 
             StartTestOutput output = new StartTestOutputBuilder()
-                                            .setRate((long)0)
-                                            .setGlobalRtcClientError(client.getRpcError())
-                                            .setGlobalRtcClientOk(client.getRpcOk())
-                                            .setExecTime(TimeUnit.NANOSECONDS.toMillis(elapsedTime))
-                                            .setRate(
-                                                (client.getRpcOk() + client.getRpcError()) * 1000000000 / elapsedTime)
+                                            .setRate(Uint32.ZERO)
+                                            .setGlobalRtcClientError(Uint32.valueOf(client.getRpcError()))
+                                            .setGlobalRtcClientOk(Uint32.valueOf(client.getRpcOk()))
+                                            .setExecTime(Uint32.valueOf(TimeUnit.NANOSECONDS.toMillis(elapsedTime)))
+                                            .setRate(Uint32.valueOf(
+                                                (client.getRpcOk() + client.getRpcError()) * 1000000000 / elapsedTime))
                                             .build();
             return RpcResultBuilder.success(output).buildFuture();
         } finally {
@@ -142,7 +143,7 @@ public class RpcbenchmarkProvider implements AutoCloseable, RpcbenchmarkService
     public ListenableFuture<RpcResult<TestStatusOutput>> testStatus(final TestStatusInput input) {
         LOG.info("testStatus");
         TestStatusOutput output = new TestStatusOutputBuilder()
-                                        .setGlobalServerCnt((long)globalServer.getNumRpcs())
+                                        .setGlobalServerCnt(Uint32.valueOf(globalServer.getNumRpcs()))
                                         .setExecStatus(execStatus.get())
                                         .build();
         return RpcResultBuilder.success(output).buildFuture();
index eb3cd3e..f4534de 100644 (file)
@@ -29,6 +29,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.listener.rev150825.listener.test.ListItemBuilder;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 /**
  * Regression test suite for https://bugs.opendaylight.org/show_bug.cgi?id=4513 - Change event is empty when
@@ -60,7 +61,7 @@ public class Bug4513Test extends AbstractDataBrokerTest {
 
     private ListItem writeListItem() {
         WriteTransaction writeTransaction = getDataBroker().newWriteOnlyTransaction();
-        final ListItem item = new ListItemBuilder().setSip("name").setOp(43L).build();
+        final ListItem item = new ListItemBuilder().setSip("name").setOp(Uint32.valueOf(43)).build();
         ListenerTestBuilder builder = new ListenerTestBuilder().setListItem(Arrays.asList(item));
         writeTransaction.put(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.builder(
                 ListenerTest.class).build(), builder.build());
index 9654ebf..703897f 100644 (file)
@@ -19,6 +19,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controll
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.md.sal.test.bi.ba.notification.rev150205.OutOfPixieDustNotificationBuilder;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.NotificationListener;
+import org.opendaylight.yangtools.yang.common.Uint16;
 import org.ops4j.pax.exam.util.Filter;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -27,9 +28,7 @@ import org.slf4j.LoggerFactory;
  * covers registering of notification listener, publishing of notification and receiving of notification.
  */
 public class NotificationIT extends AbstractIT {
-
-    private static final Logger LOG = LoggerFactory
-            .getLogger(NotificationIT.class);
+    private static final Logger LOG = LoggerFactory.getLogger(NotificationIT.class);
 
     @Inject
     @Filter(timeout = 120 * 1000)
@@ -114,7 +113,7 @@ public class NotificationIT extends AbstractIT {
      */
     public static OutOfPixieDustNotification noDustNotification(final String reason, final int days) {
         OutOfPixieDustNotificationBuilder ret = new OutOfPixieDustNotificationBuilder();
-        ret.setReason(reason).setDaysTillNewDust(days);
+        ret.setReason(reason).setDaysTillNewDust(Uint16.valueOf(days));
         return ret.build();
     }
 
index 1daef6e..f8dd5c6 100644 (file)
@@ -68,6 +68,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -224,8 +225,8 @@ public class CarProvider implements CarService {
         stopThread();
         StopStressTestOutputBuilder stopStressTestOutput;
         stopStressTestOutput = new StopStressTestOutputBuilder()
-                .setSuccessCount(succcessCounter.longValue())
-                .setFailureCount(failureCounter.longValue());
+                .setSuccessCount(Uint32.valueOf(succcessCounter.longValue()))
+                .setFailureCount(Uint32.valueOf(failureCounter.longValue()));
 
         final StopStressTestOutput result = stopStressTestOutput.build();
         LOG_PURCHASE_CAR.info("Executed Stop Stress test; No. of cars created {}; "
index b9b9b3d..306efc5 100644 (file)
@@ -35,6 +35,7 @@ import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -106,7 +107,7 @@ public class KitchenServiceImpl extends AbstractMXBean
 
         // Access the ToasterService to make the toast.
 
-        MakeToastInput toastInput = new MakeToastInputBuilder().setToasterDoneness((long) toastDoneness)
+        MakeToastInput toastInput = new MakeToastInputBuilder().setToasterDoneness(Uint32.valueOf(toastDoneness))
                 .setToasterToastType(toastType).build();
 
         return toaster.makeToast(toastInput);
index ab91aab..20e5449 100644 (file)
@@ -66,6 +66,7 @@ import org.opendaylight.yangtools.yang.common.RpcError;
 import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
 import org.opendaylight.yangtools.yang.common.RpcResult;
 import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yangtools.yang.common.Uint16;
 import org.opendaylight.yangtools.yang.common.Uint32;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -101,7 +102,7 @@ public class OpendaylightToaster extends AbstractMXBean
 
     public OpendaylightToaster() {
         this(new ToasterAppConfigBuilder().setManufacturer(TOASTER_MANUFACTURER).setModelNumber(TOASTER_MODEL_NUMBER)
-                .setMaxMakeToastTries(2).build());
+                .setMaxMakeToastTries(Uint16.valueOf(2)).build());
     }
 
     public OpendaylightToaster(final ToasterAppConfig toasterAppConfig) {
index 3be46b0..1b6dc3c 100644 (file)
@@ -32,10 +32,11 @@ import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120
 import org.opendaylight.yang.gen.v1.http.netconfcentral.org.ns.toaster.rev091120.WheatBread;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.opendaylight.yangtools.yang.common.Uint32;
 
 public class OpenDaylightToasterTest extends AbstractConcurrentDataBrokerTest {
 
-    private static InstanceIdentifier<Toaster> TOASTER_IID = InstanceIdentifier.builder(Toaster.class).build();
+    private static final InstanceIdentifier<Toaster> TOASTER_IID = InstanceIdentifier.builder(Toaster.class).build();
     private OpendaylightToaster toaster;
 
     @Before
@@ -71,7 +72,7 @@ public class OpenDaylightToasterTest extends AbstractConcurrentDataBrokerTest {
     @Test
     @Ignore //ignored because it is not a test right now. Illustrative purposes only.
     public void testSomething() throws Exception {
-        MakeToastInput toastInput = new MakeToastInputBuilder().setToasterDoneness(1L)
+        MakeToastInput toastInput = new MakeToastInputBuilder().setToasterDoneness(Uint32.valueOf(1))
                 .setToasterToastType(WheatBread.class).build();
 
         // NOTE: In a real test we would want to override the Thread.sleep() to

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.