From: Robert Varga Date: Wed, 26 Mar 2014 23:54:48 +0000 (+0100) Subject: BUG-592: Fix InstanceIdentifier instantiation X-Git-Tag: autorelease-tag-v20140601202136_82eb3f9~242^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=1f30af35ddf4289ccb1423458b8793714d7103f1 BUG-592: Fix InstanceIdentifier instantiation This is a follow-up patch for https://git.opendaylight.org/gerrit/#/c/5778 and gets rid of using direct constructor use. Change-Id: I09310b71c595a99bb09038f129b47b5b28aaaa33 Signed-off-by: Robert Varga Signed-off-by: Tony Tkacik --- diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java index 4afbc29842..e6cd1aa1ad 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java @@ -14,7 +14,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import javassist.ClassPool; @@ -40,8 +39,6 @@ import org.opendaylight.yangtools.yang.binding.BaseIdentity; import org.opendaylight.yangtools.yang.binding.DataContainer; import org.opendaylight.yangtools.yang.binding.DataObject; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; public class RuntimeCodeGeneratorTest { @@ -115,7 +112,7 @@ public class RuntimeCodeGeneratorTest { } - private void verifyRouting(RpcRouter product) { + private void verifyRouting(final RpcRouter product) { assertNotNull("Routing table should be initialized", product.getRoutingTable(BaseIdentity.class)); RpcRoutingTable routingTable = product.getRoutingTable(BaseIdentity.class); @@ -159,7 +156,7 @@ public class RuntimeCodeGeneratorTest { verify(service[1]).simple(instance_1_input[0]); } - private InstanceIdentifier[][] identifiers(int serviceSize, int instancesPerService) { + private InstanceIdentifier[][] identifiers(final int serviceSize, final int instancesPerService) { InstanceIdentifier[][] ret = new InstanceIdentifier[serviceSize][]; int service = 0; for (int i = 0; i < serviceSize; i++) { @@ -175,23 +172,19 @@ public class RuntimeCodeGeneratorTest { return ret; } - private InstanceIdentifier referencableIdentifier(int i) { - ReferencableObjectKey key = new ReferencableObjectKey(i); - IdentifiableItem pathArg = new IdentifiableItem<>( - ReferencableObject.class, key); - return new InstanceIdentifier(Arrays. asList(pathArg), - ReferencableObject.class); + private InstanceIdentifier referencableIdentifier(final int i) { + return InstanceIdentifier.builder(ReferencableObject.class, new ReferencableObjectKey(i)).build(); } private static class SimpleInputImpl implements SimpleInput { private final InstanceIdentifier identifier; - public SimpleInputImpl(InstanceIdentifier _identifier) { + public SimpleInputImpl(final InstanceIdentifier _identifier) { this.identifier = _identifier; } @Override - public > E getAugmentation(Class augmentationType) { + public > E getAugmentation(final Class augmentationType) { return null; } @@ -230,7 +223,7 @@ public class RuntimeCodeGeneratorTest { List receivedFoos = new ArrayList<>(); @Override - public void onFooUpdate(FooUpdate notification) { + public void onFooUpdate(final FooUpdate notification) { receivedFoos.add(notification); } @@ -242,12 +235,12 @@ public class RuntimeCodeGeneratorTest { List receivedDeletes = new ArrayList<>(); @Override - public void onBarUpdate(BarUpdate notification) { + public void onBarUpdate(final BarUpdate notification) { receivedBars.add(notification); } @Override - public void onFlowDelete(FlowDelete notification) { + public void onFlowDelete(final FlowDelete notification) { receivedDeletes.add(notification); } diff --git a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObject.java b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObject.java index 7901bc0955..fa565070b9 100644 --- a/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObject.java +++ b/opendaylight/md-sal/sal-binding-broker/src/test/java/org/opendaylight/controller/sal/binding/test/mock/ReferencableObject.java @@ -7,9 +7,12 @@ */ package org.opendaylight.controller.sal.binding.test.mock; +import org.opendaylight.yangtools.yang.binding.ChildOf; import org.opendaylight.yangtools.yang.binding.DataObject; +import org.opendaylight.yangtools.yang.binding.DataRoot; import org.opendaylight.yangtools.yang.binding.Identifiable; -public interface ReferencableObject extends DataObject,Identifiable { +public interface ReferencableObject extends DataObject, + Identifiable,ChildOf{ }