From b8cf23cd61c2d3f57f9450570236534bce69232e Mon Sep 17 00:00:00 2001 From: Jan Srnicek Date: Tue, 15 Aug 2017 11:30:28 +0200 Subject: HONEYCOMB-386 - Hc2vpp Customizers update Utilizes new default update implementation Change-Id: I9bf8473336274ba5fcfc18804f7b414937b3708e Signed-off-by: Jan Srnicek --- .../gpe/translate/write/NativeForwardPathCustomizer.java | 10 ---------- .../translate/write/NativeForwardPathsTableCustomizer.java | 12 ------------ .../translate/write/BridgeDomainSubtableCustomizer.java | 8 -------- .../fd/hc2vpp/lisp/translate/write/InterfaceCustomizer.java | 6 ------ .../lisp/translate/write/ItrRemoteLocatorSetCustomizer.java | 9 --------- .../hc2vpp/lisp/translate/write/LocatorSetCustomizer.java | 9 --------- .../hc2vpp/lisp/translate/write/MapResolverCustomizer.java | 7 ------- .../fd/hc2vpp/lisp/translate/write/MapServerCustomizer.java | 9 --------- .../fd/hc2vpp/lisp/translate/write/VniTableCustomizer.java | 6 ------ .../hc2vpp/lisp/translate/write/VrfSubtableCustomizer.java | 7 ------- .../write/NativeForwardPathsTableCustomizerTest.java | 6 +++++- .../translate/write/ItrRemoteLocatorSetCustomizerTest.java | 13 +++---------- .../lisp/translate/write/LocatorSetCustomizerTest.java | 13 ++----------- .../lisp/translate/write/MapServerCustomizerTest.java | 10 ++-------- 14 files changed, 12 insertions(+), 113 deletions(-) (limited to 'lisp') diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/gpe/translate/write/NativeForwardPathCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/gpe/translate/write/NativeForwardPathCustomizer.java index cbb4b2f97..730f7663d 100644 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/gpe/translate/write/NativeForwardPathCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/gpe/translate/write/NativeForwardPathCustomizer.java @@ -54,16 +54,6 @@ public class NativeForwardPathCustomizer extends FutureJVppCustomizer createNativePath(id, dataAfter, writeContext); } - - @Override - public void updateCurrentAttributes(@Nonnull final InstanceIdentifier id, - @Nonnull final NativeForwardPath dataBefore, - @Nonnull final NativeForwardPath dataAfter, - @Nonnull final WriteContext writeContext) throws WriteFailedException { - deleteNativePath(id, dataBefore, writeContext); - createNativePath(id, dataAfter, writeContext); - } - @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final NativeForwardPath dataBefore, diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/gpe/translate/write/NativeForwardPathsTableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/gpe/translate/write/NativeForwardPathsTableCustomizer.java index 6d2faf297..f04a13f5c 100644 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/gpe/translate/write/NativeForwardPathsTableCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/gpe/translate/write/NativeForwardPathsTableCustomizer.java @@ -53,18 +53,6 @@ public class NativeForwardPathsTableCustomizer extends FutureJVppCustomizer createFibTable(id, dataAfter); } - - @Override - public void updateCurrentAttributes(@Nonnull final InstanceIdentifier id, - @Nonnull final NativeForwardPathsTable dataBefore, - @Nonnull final NativeForwardPathsTable dataAfter, - @Nonnull final WriteContext writeContext) - throws WriteFailedException { - // not sure if update makes sense, but just in case - deleteFibTable(id); - createFibTable(id, dataAfter); - } - @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final NativeForwardPathsTable dataBefore, diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/BridgeDomainSubtableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/BridgeDomainSubtableCustomizer.java index 4006628f0..b3fce3340 100644 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/BridgeDomainSubtableCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/BridgeDomainSubtableCustomizer.java @@ -66,14 +66,6 @@ public class BridgeDomainSubtableCustomizer extends FutureJVppCustomizer LOG.debug("{} successfully written", id); } - @Override - public void updateCurrentAttributes(@Nonnull final InstanceIdentifier id, - @Nonnull final BridgeDomainSubtable dataBefore, - @Nonnull final BridgeDomainSubtable dataAfter, - @Nonnull final WriteContext writeContext) throws WriteFailedException { - throw new UnsupportedOperationException("Operation not supported"); - } - @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final BridgeDomainSubtable dataBefore, diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/InterfaceCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/InterfaceCustomizer.java index bb963a4e3..8feb2e08a 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/InterfaceCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/InterfaceCustomizer.java @@ -79,12 +79,6 @@ public class InterfaceCustomizer extends FutureJVppCustomizer } - @Override - public void updateCurrentAttributes(InstanceIdentifier id, Interface dataBefore, Interface dataAfter, - WriteContext writeContext) throws WriteFailedException { - throw new UnsupportedOperationException("Operation not supported"); - } - @Override public void deleteCurrentAttributes(InstanceIdentifier id, Interface dataBefore, WriteContext writeContext) throws WriteFailedException { diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizer.java index f841ac579..3ec2a72dd 100644 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizer.java @@ -52,15 +52,6 @@ public class ItrRemoteLocatorSetCustomizer extends CheckedLispCustomizer impleme } } - @Override - public void updateCurrentAttributes(@Nonnull final InstanceIdentifier id, - @Nonnull final ItrRemoteLocatorSet dataBefore, - @Nonnull final ItrRemoteLocatorSet dataAfter, - @Nonnull final WriteContext writeContext) throws WriteFailedException { - throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, - new UnsupportedOperationException("Operation not supported")); - } - @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final ItrRemoteLocatorSet dataBefore, diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizer.java index dfd6a003d..614d538d5 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizer.java @@ -86,15 +86,6 @@ public class LocatorSetCustomizer extends CheckedLispCustomizer return locators != null && !locators.isEmpty(); } - @Override - public void updateCurrentAttributes(@Nonnull InstanceIdentifier id, - @Nonnull LocatorSet dataBefore, - @Nonnull LocatorSet dataAfter, - @Nonnull WriteContext writeContext) throws WriteFailedException { - throw new WriteFailedException.UpdateFailedException(id, dataBefore, dataAfter, - new UnsupportedOperationException("Operation not supported")); - } - @Override public void deleteCurrentAttributes(@Nonnull InstanceIdentifier id, @Nonnull LocatorSet dataBefore, diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizer.java index 9f24e3c5f..b492627c0 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapResolverCustomizer.java @@ -62,13 +62,6 @@ public class MapResolverCustomizer extends CheckedLispCustomizer } } - @Override - public void updateCurrentAttributes(@Nonnull final InstanceIdentifier id, - @Nonnull final MapResolver dataBefore, @Nonnull final MapResolver dataAfter, - @Nonnull final WriteContext writeContext) throws WriteFailedException { - throw new UnsupportedOperationException("Operation not supported"); - } - @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final MapResolver dataBefore, @Nonnull final WriteContext writeContext) diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizer.java index e9de1a917..3d33aaf9c 100644 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizer.java @@ -48,15 +48,6 @@ public class MapServerCustomizer extends CheckedLispCustomizer addDelMapServer(true, instanceIdentifier, mapServer); } - @Override - public void updateCurrentAttributes(@Nonnull InstanceIdentifier instanceIdentifier, - @Nonnull MapServer mapServerBefore, - @Nonnull MapServer mapServerAfter, - @Nonnull WriteContext writeContext) throws WriteFailedException { - throw new WriteFailedException.UpdateFailedException(instanceIdentifier, mapServerBefore, mapServerAfter, - new UnsupportedOperationException("Not supported")); - } - @Override public void deleteCurrentAttributes(@Nonnull InstanceIdentifier instanceIdentifier, @Nonnull MapServer mapServer, @Nonnull WriteContext writeContext) throws WriteFailedException { lispStateCheckService.checkLispEnabledBefore(writeContext); diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizer.java index e1f1371ee..fb3c89ded 100755 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/VniTableCustomizer.java @@ -50,12 +50,6 @@ public class VniTableCustomizer extends CheckedLispCustomizer implements ListWri checkAtLeastOnChildExists(id, writeContext, false); } - @Override - public void updateCurrentAttributes(InstanceIdentifier id, VniTable dataBefore, VniTable dataAfter, - WriteContext writeContext) throws WriteFailedException { - throw new UnsupportedOperationException("Operation not supported"); - } - @Override public void deleteCurrentAttributes(InstanceIdentifier id, VniTable dataBefore, WriteContext writeContext) throws WriteFailedException { diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/VrfSubtableCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/VrfSubtableCustomizer.java index e7314b683..d4c4a1ad5 100644 --- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/VrfSubtableCustomizer.java +++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/write/VrfSubtableCustomizer.java @@ -58,13 +58,6 @@ public class VrfSubtableCustomizer extends FutureJVppCustomizer LOG.debug("{} successfully written", id); } - @Override - public void updateCurrentAttributes(@Nonnull final InstanceIdentifier id, - @Nonnull final VrfSubtable dataBefore, @Nonnull final VrfSubtable dataAfter, - @Nonnull final WriteContext writeContext) throws WriteFailedException { - throw new UnsupportedOperationException("Operation not supported"); - } - @Override public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier id, @Nonnull final VrfSubtable dataBefore, @Nonnull final WriteContext writeContext) diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/gpe/translate/write/NativeForwardPathsTableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/gpe/translate/write/NativeForwardPathsTableCustomizerTest.java index 80bb2c600..e2f55fdd1 100644 --- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/gpe/translate/write/NativeForwardPathsTableCustomizerTest.java +++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/gpe/translate/write/NativeForwardPathsTableCustomizerTest.java @@ -79,7 +79,11 @@ public class NativeForwardPathsTableCustomizerTest extends WriterCustomizerTest @Test public void testUpdateValid() throws WriteFailedException { when(api.gpeAddDelNativeFwdRpath(any())).thenReturn(future(new GpeAddDelNativeFwdRpathReply())); - customizer.updateCurrentAttributes(validId, validTableBefore(), validTable(), writeContext); + final NativeForwardPathsTable before = validTableBefore(); + final NativeForwardPathsTable after = validTable(); + // emulates what default update would do + customizer.deleteCurrentAttributes(validId, before, writeContext); + customizer.writeCurrentAttributes(validId, after, writeContext); verify(api, times(2)).gpeAddDelIface(requestCaptor.capture()); final List requests = requestCaptor.getAllValues(); diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java index 4d76f7d6f..a05866114 100644 --- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java +++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/ItrRemoteLocatorSetCustomizerTest.java @@ -84,16 +84,9 @@ public class ItrRemoteLocatorSetCustomizerTest extends LispWriterCustomizerTest fail("Test should have thrown exception"); } - @Test - public void updateCurrentAttributes() { - try { - customizer.updateCurrentAttributes(validId, validData, validData, writeContext); - } catch (WriteFailedException e) { - assertTrue(e.getCause() instanceof UnsupportedOperationException); - return; - } - - fail("Test should have thrown exception"); + @Test(expected = UnsupportedOperationException.class) + public void updateCurrentAttributes() throws WriteFailedException { + customizer.updateCurrentAttributes(validId, validData, validData, writeContext); } @Test diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java index edb648bd9..52ed5dfd1 100755 --- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java +++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/LocatorSetCustomizerTest.java @@ -18,7 +18,6 @@ package io.fd.hc2vpp.lisp.translate.write; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; @@ -121,18 +120,10 @@ public class LocatorSetCustomizerTest extends LispWriterCustomizerTest { assertEquals(1, request.isAdd); } - @Test + @Test(expected = UnsupportedOperationException.class) public void testUpdateCurrentAttributes() throws WriteFailedException { final InstanceIdentifier identifier = InstanceIdentifier.create(LocatorSet.class); - try { - customizer - .updateCurrentAttributes(identifier, mock(LocatorSet.class), mock(LocatorSet.class), writeContext); - } catch (WriteFailedException e) { - assertTrue(e.getCause() instanceof UnsupportedOperationException); - assertEquals(identifier, e.getFailedId()); - return; - } - fail("Test should have failed"); + customizer.updateCurrentAttributes(identifier, mock(LocatorSet.class), mock(LocatorSet.class), writeContext); } @Test(expected = NullPointerException.class) diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java index 19f8b0af4..27c716080 100644 --- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java +++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/write/MapServerCustomizerTest.java @@ -72,15 +72,9 @@ public class MapServerCustomizerTest extends LispWriterCustomizerTest implements } - @Test + @Test(expected = UnsupportedOperationException.class) public void updateCurrentAttributes() throws Exception { - try { - customizer.updateCurrentAttributes(ID, data, data, writeContext); - } catch (WriteFailedException e) { - assertTrue(e instanceof WriteFailedException.UpdateFailedException); - assertTrue(e.getCause() instanceof UnsupportedOperationException); - verify(api, times(0)).oneAddDelMapServer(any()); - } + customizer.updateCurrentAttributes(ID, data, data, writeContext); } @Test -- cgit 1.2.3-korg