From e34094aa0f0adce2daa1978452f25a145e039ebe Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 21 Feb 2024 14:17:20 +0100 Subject: [PATCH] Simplify invocation mocking Use Invocation.getArgument() instead of getArguments() and casting. While we are here, fix minor warnings around ArgumentCaptor by using local variable type inference. Change-Id: I75756f79a9e0820d61acea847c8e635cf5657f36 Signed-off-by: Robert Varga --- .../netconf/client/mdsal/NetconfDeviceTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceTest.java b/plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceTest.java index ea53d20655..25e1628293 100644 --- a/plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceTest.java +++ b/plugins/netconf-client-mdsal/src/test/java/org/opendaylight/netconf/client/mdsal/NetconfDeviceTest.java @@ -103,7 +103,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { final SchemaResolutionException schemaResolutionException = new SchemaResolutionException("fail first", TEST_SID, new Throwable("YangTools parser fail")); doAnswer(invocation -> { - if (((Collection) invocation.getArguments()[0]).size() == 2) { + if (invocation.getArgument(0, Collection.class).size() == 2) { return Futures.immediateFailedFuture(schemaResolutionException); } else { return Futures.immediateFuture(SCHEMA_CONTEXT); @@ -399,7 +399,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { netconfSpy.onRemoteSessionUp(sessionCaps.replaceModuleCaps(moduleBasedCaps), listener); - final ArgumentCaptor argument = ArgumentCaptor.forClass(NetconfDeviceSchema.class); + final var argument = ArgumentCaptor.forClass(NetconfDeviceSchema.class); verify(facade, timeout(5000)).onDeviceConnected(argument.capture(), any(NetconfSessionPreferences.class), any(RemoteDeviceServices.class)); argument.getValue().capabilities().resolvedCapabilities() @@ -429,7 +429,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { netconfSpy.onRemoteSessionUp(sessionCaps, listener); - final ArgumentCaptor argument = ArgumentCaptor.forClass(NetconfDeviceSchema.class); + final var argument = ArgumentCaptor.forClass(NetconfDeviceSchema.class); verify(facade, timeout(5000)).onDeviceConnected(argument.capture(), any(NetconfSessionPreferences.class), any(RemoteDeviceServices.class)); @@ -468,7 +468,7 @@ public class NetconfDeviceTest extends AbstractTestModelTest { netconfSpy.onRemoteSessionUp(sessionCaps, listener); - final ArgumentCaptor argument = ArgumentCaptor.forClass(NetconfDeviceSchema.class); + final var argument = ArgumentCaptor.forClass(NetconfDeviceSchema.class); verify(facade, timeout(5000)).onDeviceConnected(argument.capture(), any(NetconfSessionPreferences.class), any(RemoteDeviceServices.class)); final NetconfDeviceCapabilities netconfDeviceCaps = argument.getValue().capabilities(); -- 2.36.6