X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Fimpl%2Fconnect%2Fdom%2FRpcInvocationStrategyTest.java;h=116491b5185b20c84f4800774ab0c548e4c3f4e6;hb=c90b3cfcb48dd75cc3cc6305aaac1bbabad8d9fe;hp=c5aea8f2ab666cb5e777e3f20d808910ab3308c6;hpb=d449631e9b99aace639985286b73357577481cab;p=controller.git diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/impl/connect/dom/RpcInvocationStrategyTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/impl/connect/dom/RpcInvocationStrategyTest.java index c5aea8f2ab..116491b518 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/impl/connect/dom/RpcInvocationStrategyTest.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/impl/connect/dom/RpcInvocationStrategyTest.java @@ -13,31 +13,28 @@ import static org.mockito.Matchers.any; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; - +import com.google.common.util.concurrent.Futures; +import com.google.common.util.concurrent.ListenableFuture; import java.net.URI; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; - import org.junit.Before; import org.junit.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import org.opendaylight.controller.sal.common.util.Rpcs; import org.opendaylight.controller.sal.core.api.RpcProvisionRegistry; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.RpcService; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcError; import org.opendaylight.yangtools.yang.common.RpcResult; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.opendaylight.yangtools.yang.data.impl.codec.BindingIndependentMappingService; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; - public class RpcInvocationStrategyTest { @Mock @@ -68,11 +65,11 @@ public class RpcInvocationStrategyTest { public class MockRpcService implements RpcService { - public Future rpcnameWithInputNoOutput(DataObject input) { + public Future rpcnameWithInputNoOutput(final DataObject input) { return futureDataObj; } - public Future> rpcnameWithInputWithOutput(DataObject input) { + public Future> rpcnameWithInputWithOutput(final DataObject input) { return futureDataObj; } @@ -94,11 +91,13 @@ public class RpcInvocationStrategyTest { urn = new URI(new String("urn:a:valid:urn")); } - private void setupForForwardToDom(boolean hasOutput, boolean hasInput, int expectedErrorSize) { + private void setupForForwardToDom(final boolean hasOutput, final boolean hasInput, final int expectedErrorSize) { - if (expectedErrorSize > 0) + if (expectedErrorSize > 0) { errors.add(rpcError); - RpcResult result = Rpcs.getRpcResult(true, invokeRpcResult, errors); + } + RpcResult result = RpcResultBuilder.success(invokeRpcResult) + .withRpcErrors( errors ).build(); futureCompNode = Futures.immediateFuture(result); if( hasInput ) { @@ -115,8 +114,8 @@ public class RpcInvocationStrategyTest { } - private void validateForwardToDomBroker(ListenableFuture> forwardToDomBroker, - boolean expectedSuccess, DataObject expectedResult, int expectedErrorSize) + private void validateForwardToDomBroker(final ListenableFuture> forwardToDomBroker, + final boolean expectedSuccess, final DataObject expectedResult, final int expectedErrorSize) throws InterruptedException, ExecutionException { assertNotNull(forwardToDomBroker); assertEquals(expectedSuccess, forwardToDomBroker.get().isSuccessful()); @@ -124,9 +123,9 @@ public class RpcInvocationStrategyTest { assertEquals(expectedErrorSize, forwardToDomBroker.get().getErrors().size()); } - private void setupTestMethod(String rpcName, String testMethodName, boolean hasInput) + private void setupTestMethod(final String rpcName, final String testMethodName, final boolean hasInput) throws NoSuchMethodException { - mockQName = new QName(urn, new Date(0L), new String("prefix"), new String(rpcName)); + mockQName = QName.create(urn, new Date(0L), new String(rpcName)); java.lang.reflect.Method rpcMethod = hasInput ? MockRpcService.class.getMethod(rpcName, DataObject.class) : MockRpcService.class.getMethod(rpcName); rpcInvocationStrategy = new RpcInvocationStrategy(mockQName, rpcMethod, mockMappingService, @@ -190,29 +189,35 @@ public class RpcInvocationStrategyTest { /* * invokeOn Tests */ - private void setupRpcResultsWithOutput(int expectedErrorSize) { - if (expectedErrorSize > 0) + private void setupRpcResultsWithOutput(final int expectedErrorSize) { + if (expectedErrorSize > 0) { errors.add(rpcError); - RpcResult resultCompNode = Rpcs.getRpcResult(true, inputInvokeOn, errors); + } + RpcResult resultCompNode = RpcResultBuilder.success(inputInvokeOn) + .withRpcErrors(errors).build(); futureCompNode = Futures.immediateFuture(resultCompNode); - RpcResult resultDataObj = Rpcs.getRpcResult(true, toDataDomInput, errors); + RpcResult resultDataObj = RpcResultBuilder.success(toDataDomInput) + .withRpcErrors(errors).build(); futureDataObj = Futures.immediateFuture(resultDataObj); when(mockMappingService.toDataDom(toDataDomInput)).thenReturn(outputInvokeOn); } - private void setupRpcResultsNoOutput(int expectedErrorSize) { - if (expectedErrorSize > 0) + private void setupRpcResultsNoOutput(final int expectedErrorSize) { + if (expectedErrorSize > 0) { errors.add(rpcError); - RpcResult resultCompNode = Rpcs.getRpcResult(true, inputInvokeOn, errors); + } + RpcResult resultCompNode = RpcResultBuilder.success(inputInvokeOn) + .withRpcErrors(errors).build(); futureCompNode = Futures.immediateFuture(resultCompNode); - RpcResult resultDataObj = Rpcs.getRpcResult(true, null, errors); + RpcResult resultDataObj = RpcResultBuilder.success() + .withRpcErrors(errors).build(); futureDataObj = Futures.immediateFuture(resultDataObj); } private void validateReturnedImmediateFuture( - ListenableFuture> immediateFuture, boolean expectedSuccess, - CompositeNode expectedReturn, int expectedErrorSize) throws InterruptedException, + final ListenableFuture> immediateFuture, final boolean expectedSuccess, + final CompositeNode expectedReturn, final int expectedErrorSize) throws InterruptedException, ExecutionException { assertNotNull(immediateFuture); assertEquals(expectedSuccess, immediateFuture.get().isSuccessful());