X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fmd-sal%2Fsal-binding-broker%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Ftest%2FRuntimeCodeGeneratorTest.java;h=e6cd1aa1ad638716b474fa9570c7d3ace3d767a1;hp=9c9841a4a5dc8deed41f717f7ce50d208f1c6b9f;hb=f776809962df87deeaa533ba995cc6fceba64d0e;hpb=576aa6018e48dfca8f223b7ac929139a32135201 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 9c9841a4a5..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 @@ -1,34 +1,36 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ package org.opendaylight.controller.sal.binding.test; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; import java.util.List; -import java.util.Map; import javassist.ClassPool; import org.junit.Before; import org.junit.Test; - -import static org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper.*; - -import org.opendaylight.controller.sal.binding.api.NotificationListener; +import org.opendaylight.controller.sal.binding.api.rpc.RpcRouter; +import org.opendaylight.controller.sal.binding.api.rpc.RpcRoutingTable; import org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator; import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory; import org.opendaylight.controller.sal.binding.spi.NotificationInvokerFactory.NotificationInvoker; -import org.opendaylight.controller.sal.binding.spi.RpcRouter; -import org.opendaylight.controller.sal.binding.spi.RpcRoutingTable; import org.opendaylight.controller.sal.binding.test.mock.BarListener; import org.opendaylight.controller.sal.binding.test.mock.BarUpdate; -import org.opendaylight.controller.sal.binding.test.mock.CompositeListener; import org.opendaylight.controller.sal.binding.test.mock.FlowDelete; import org.opendaylight.controller.sal.binding.test.mock.FooListener; import org.opendaylight.controller.sal.binding.test.mock.FooService; import org.opendaylight.controller.sal.binding.test.mock.FooUpdate; -import org.opendaylight.controller.sal.binding.test.mock.InheritedContextInput; import org.opendaylight.controller.sal.binding.test.mock.ReferencableObject; import org.opendaylight.controller.sal.binding.test.mock.ReferencableObjectKey; import org.opendaylight.controller.sal.binding.test.mock.SimpleInput; @@ -37,10 +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; - -import static org.mockito.Mockito.*; public class RuntimeCodeGeneratorTest { @@ -61,7 +59,7 @@ public class RuntimeCodeGeneratorTest { @Test public void testGenerateRouter() throws Exception { - RpcRouter product = codeGenerator.getRouterFor(FooService.class); + RpcRouter product = codeGenerator.getRouterFor(FooService.class,"test"); assertNotNull(product); assertNotNull(product.getInvocationProxy()); @@ -77,7 +75,7 @@ public class RuntimeCodeGeneratorTest { NotificationInvoker invokerFoo = invokerFactory.invokerFor(fooListener); - + assertSame(fooListener,invokerFoo.getDelegate()); assertNotNull(invokerFoo.getSupportedNotifications()); assertEquals(1, invokerFoo.getSupportedNotifications().size()); @@ -114,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); @@ -158,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++) { @@ -174,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; } @@ -229,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); } @@ -241,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); }