From cc306a6e41824f2de2fe9f3cd2f788c7e5c41cd5 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Mon, 13 Jun 2016 14:58:50 +0200 Subject: HONEYCOMB-91: initializer for L2 FIB tables Change-Id: I7f133ea56fc3bb11e0f4b584839dabc0754a8d50 Signed-off-by: Marek Gradzki --- .../v3po/vppstate/BridgeDomainCustomizerTest.java | 4 +- .../v3po/vppstate/L2FibEntryCustomizerTest.java | 4 +- .../v3po/translate/v3po/vppstate/VppStateTest.java | 44 +++++++++++++--------- .../translate/v3po/vppstate/VppStateTestUtils.java | 24 ++++++------ 4 files changed, 44 insertions(+), 32 deletions(-) (limited to 'v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate') diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizerTest.java index 80403eb58..7639f4849 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/BridgeDomainCustomizerTest.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package io.fd.honeycomb.v3po.translate.v3po.vppstate; import static org.mockito.Mockito.mock; @@ -29,7 +30,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomainBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.vpp.state.bridge.domains.BridgeDomainKey; -public class BridgeDomainCustomizerTest extends ListReaderCustomizerTest { +public class BridgeDomainCustomizerTest + extends ListReaderCustomizerTest { private NamingContext bdContext; private NamingContext interfacesContext; diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/L2FibEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/L2FibEntryCustomizerTest.java index 4808b6d88..1f668b817 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/L2FibEntryCustomizerTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/L2FibEntryCustomizerTest.java @@ -83,11 +83,11 @@ public class L2FibEntryCustomizerTest extends ListReaderCustomizerTest getL2FibEntryId(final String bdName, final PhysAddress address) { return InstanceIdentifier.create(BridgeDomains.class).child(BridgeDomain.class, new BridgeDomainKey(bdName)) - .child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(address)); + .child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(address)); } private void whenL2FibTableDumpThenReturn(final List l2FibTableEntryList) - throws ExecutionException, InterruptedException, VppInvocationException { + throws ExecutionException, InterruptedException, VppInvocationException { final L2FibTableEntryReplyDump reply = new L2FibTableEntryReplyDump(); reply.l2FibTableEntry = l2FibTableEntryList; diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateTest.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateTest.java index 8b11769d6..782924490 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateTest.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateTest.java @@ -99,19 +99,21 @@ public class VppStateTest { bdContext = new NamingContext("generatedBdName", "bd-test-instance"); interfaceContext = new NamingContext("generatedIfaceName", "ifc-test-instance"); vppStateReader = VppStateTestUtils.getVppStateReader(api, bdContext); - readerRegistry = new DelegatingReaderRegistry(Collections.>singletonList(vppStateReader)); + readerRegistry = + new DelegatingReaderRegistry(Collections.>singletonList(vppStateReader)); } private static Version getVersion() { return new VersionBuilder() - .setName("test") - .setBuildDirectory("1") - .setBranch("2") - .setBuildDate("3") - .build(); + .setName("test") + .setBuildDirectory("1") + .setBranch("2") + .setBuildDate("3") + .build(); } - private void whenShowVersionThenReturn(int retval, Version version) throws ExecutionException, InterruptedException, VppInvocationException { + private void whenShowVersionThenReturn(int retval, Version version) + throws ExecutionException, InterruptedException, VppInvocationException { final CompletableFuture replyFuture = new CompletableFuture<>(); final ShowVersionReply reply = new ShowVersionReply(); reply.buildDate = version.getBuildDate().getBytes(); @@ -123,7 +125,8 @@ public class VppStateTest { when(api.showVersion(any(ShowVersion.class))).thenReturn(replyFuture); } - private void whenL2FibTableDumpThenReturn(final List entryList) throws ExecutionException, InterruptedException, VppInvocationException { + private void whenL2FibTableDumpThenReturn(final List entryList) + throws ExecutionException, InterruptedException, VppInvocationException { final CompletionStage replyCS = mock(CompletionStage.class); final CompletableFuture replyFuture = mock(CompletableFuture.class); when(replyCS.toCompletableFuture()).thenReturn(replyFuture); @@ -133,7 +136,8 @@ public class VppStateTest { when(api.l2FibTableDump(any(L2FibTableDump.class))).thenReturn(replyCS); } - private void whenBridgeDomainDumpThenReturn(final List bdList) throws ExecutionException, InterruptedException, VppInvocationException { + private void whenBridgeDomainDumpThenReturn(final List bdList) + throws ExecutionException, InterruptedException, VppInvocationException { final CompletionStage replyCS = mock(CompletionStage.class); final CompletableFuture replyFuture = mock(CompletableFuture.class); when(replyCS.toCompletableFuture()).thenReturn(replyFuture); @@ -142,7 +146,7 @@ public class VppStateTest { when(replyFuture.get()).thenReturn(reply); doAnswer(invocation -> { - BridgeDomainDump request = (BridgeDomainDump)invocation.getArguments()[0]; + BridgeDomainDump request = (BridgeDomainDump) invocation.getArguments()[0]; if (request.bdId == -1) { reply.bridgeDomainDetails = bdList; } else { @@ -167,9 +171,11 @@ public class VppStateTest { whenBridgeDomainDumpThenReturn(bdList); - final Multimap, ? extends DataObject> dataObjects = readerRegistry.readAll(ctx); + final Multimap, ? extends DataObject> dataObjects = + readerRegistry.readAll(ctx); assertEquals(dataObjects.size(), 1); - final VppState dataObject = (VppState)Iterables.getOnlyElement(dataObjects.get(Iterables.getOnlyElement(dataObjects.keySet()))); + final VppState dataObject = + (VppState) Iterables.getOnlyElement(dataObjects.get(Iterables.getOnlyElement(dataObjects.keySet()))); assertEquals(version, dataObject.getVersion()); assertEquals(2, dataObject.getBridgeDomains().getBridgeDomain().size()); } @@ -221,15 +227,19 @@ public class VppStateTest { whenL2FibTableDumpThenReturn(Collections.singletonList(l2FibEntry)); // Deep child without a dedicated reader with specific l2fib key - final InstanceIdentifier idExisting = InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child( - BridgeDomain.class, new BridgeDomainKey("bdn1")).child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(new PhysAddress("01:02:03:04:05:06"))); + final InstanceIdentifier idExisting = + InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child( + BridgeDomain.class, new BridgeDomainKey("bdn1")).child(L2FibTable.class) + .child(L2FibEntry.class, new L2FibEntryKey(new PhysAddress("01:02:03:04:05:06"))); Optional read = readerRegistry.read(idExisting, ctx); assertTrue(read.isPresent()); // non existing l2fib - final InstanceIdentifier idNonExisting = InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child( - BridgeDomain.class, new BridgeDomainKey("bdn1")).child(L2FibTable.class).child(L2FibEntry.class, new L2FibEntryKey(new PhysAddress("FF:FF:FF:04:05:06"))); + final InstanceIdentifier idNonExisting = + InstanceIdentifier.create(VppState.class).child(BridgeDomains.class).child( + BridgeDomain.class, new BridgeDomainKey("bdn1")).child(L2FibTable.class) + .child(L2FibEntry.class, new L2FibEntryKey(new PhysAddress("FF:FF:FF:04:05:06"))); read = readerRegistry.read(idNonExisting, ctx); assertFalse(read.isPresent()); } @@ -276,7 +286,7 @@ public class VppStateTest { assertTrue(read.isPresent()); assertEquals(readRoot.getBridgeDomains().getBridgeDomain().stream().filter( - input -> input.getKey().getName().equals(bdName)).findFirst().get(), + input -> input.getKey().getName().equals(bdName)).findFirst().get(), read.get()); } diff --git a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateTestUtils.java b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateTestUtils.java index 8fd57d679..27095c7d9 100644 --- a/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateTestUtils.java +++ b/v3po/v3po2vpp/src/test/java/io/fd/honeycomb/v3po/translate/v3po/vppstate/VppStateTestUtils.java @@ -50,31 +50,31 @@ final class VppStateTestUtils { @Nonnull final NamingContext bdContext) { final ChildReader versionReader = new CompositeChildReader<>( - Version.class, new VersionCustomizer(futureJVpp)); + Version.class, new VersionCustomizer(futureJVpp)); final CompositeListReader bridgeDomainReader = - getBridgeDomainReader(futureJVpp, bdContext); + getBridgeDomainReader(futureJVpp, bdContext); final ChildReader bridgeDomainsReader = new CompositeChildReader<>( - BridgeDomains.class, - RWUtils.singletonChildReaderList(bridgeDomainReader), - new ReflexiveChildReaderCustomizer<>(BridgeDomainsBuilder.class)); + BridgeDomains.class, + RWUtils.singletonChildReaderList(bridgeDomainReader), + new ReflexiveChildReaderCustomizer<>(BridgeDomainsBuilder.class)); final List>> childVppReaders = new ArrayList<>(); childVppReaders.add(versionReader); childVppReaders.add(bridgeDomainsReader); return new CompositeRootReader<>( - VppState.class, - childVppReaders, - RWUtils.emptyAugReaderList(), - new ReflexiveRootReaderCustomizer<>(VppStateBuilder.class)); + VppState.class, + childVppReaders, + RWUtils.emptyAugReaderList(), + new ReflexiveRootReaderCustomizer<>(VppStateBuilder.class)); } static CompositeListReader getBridgeDomainReader( - final @Nonnull FutureJVpp futureJVpp, @Nonnull final NamingContext bdContext) { + final @Nonnull FutureJVpp futureJVpp, @Nonnull final NamingContext bdContext) { return new CompositeListReader<>( - BridgeDomain.class, - new BridgeDomainCustomizer(futureJVpp, bdContext)); + BridgeDomain.class, + new BridgeDomainCustomizer(futureJVpp, bdContext)); } } -- cgit 1.2.3-korg