diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2016-10-06 08:54:02 +0200 |
---|---|---|
committer | Jan Srnicek <jsrnicek@cisco.com> | 2016-10-06 08:54:02 +0200 |
commit | 8c9c430823aa19912a55b0a6ccfcbbb6a1bc028d (patch) | |
tree | 1e5aa752236ada01009a353cf34eb6b7706e65fc /lisp/lisp2vpp/src/test/java/io/fd/honeycomb | |
parent | 15f481bc86adfd879e0e0d001ef3dd0939aa3649 (diff) |
HONEYCOMB-236 - Unified read/write exceptions
Change-Id: Idde761d0c0c2c4d96555ef94dbdaa87fad889493
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'lisp/lisp2vpp/src/test/java/io/fd/honeycomb')
9 files changed, 122 insertions, 92 deletions
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/BridgeDomainSubtableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/BridgeDomainSubtableCustomizerTest.java index 5902028fe..4334aea31 100644 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/BridgeDomainSubtableCustomizerTest.java +++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/BridgeDomainSubtableCustomizerTest.java @@ -11,7 +11,6 @@ import static org.junit.Assert.fail; import io.fd.honeycomb.lisp.translate.read.trait.SubtableReaderTestCase; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException; import io.fd.honeycomb.translate.vpp.util.NamingContext; import io.fd.vpp.jvpp.VppCallbackException; import org.junit.Test; @@ -76,8 +75,7 @@ public class BridgeDomainSubtableCustomizerTest try { customizer.readCurrentAttributes(validId, builder, ctx); } catch (ReadFailedException e) { - assertTrue(e.getCause() instanceof DumpCallFailedException); - assertTrue(e.getCause().getCause() instanceof VppCallbackException); + assertTrue(e.getCause() instanceof VppCallbackException); assertNull(builder.getBridgeDomainRef()); verifyLispEidTableMapDumpNotCalled(); diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java index a1688ae35..1fd2a3c86 100644 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java +++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/ItrRemoteLocatorSetCustomizerTest.java @@ -12,7 +12,6 @@ import static org.mockito.Mockito.when; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException; import io.fd.honeycomb.vpp.test.read.ReaderCustomizerTest; import io.fd.vpp.jvpp.VppCallbackException; import io.fd.vpp.jvpp.core.dto.LispGetMapRequestItrRlocs; @@ -85,8 +84,7 @@ public class ItrRemoteLocatorSetCustomizerTest try { getCustomizer().readCurrentAttributes(validId, builder, ctx); } catch (ReadFailedException e) { - assertTrue(e.getCause() instanceof DumpCallFailedException); - assertTrue(e.getCause().getCause() instanceof VppCallbackException); + assertTrue(e.getCause() instanceof VppCallbackException); assertNotNull(builder); assertNull(builder.getRemoteLocatorSetName()); diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizerTest.java index fe967e486..6ce9ea711 100644 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizerTest.java +++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VniTableCustomizerTest.java @@ -4,22 +4,18 @@ package io.fd.honeycomb.lisp.translate.read; 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.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; import com.google.common.collect.ImmutableList; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException; import io.fd.honeycomb.vpp.test.read.ListReaderCustomizerTest; import io.fd.vpp.jvpp.VppCallbackException; import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetails; import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetailsReplyDump; import java.util.List; import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; @@ -61,11 +57,11 @@ public class VniTableCustomizerTest extends ListReaderCustomizerTest<VniTable, V try { getCustomizer().getAllIds(validId, ctx); } catch (ReadFailedException e) { - assertTrue(e instanceof ReadFailedException); - assertTrue(e.getCause() instanceof DumpCallFailedException); - assertTrue(e.getCause().getCause() instanceof VppCallbackException); + assertTrue(e.getCause() instanceof VppCallbackException); + return; } + fail("Test should have thrown ReadFailedException"); } @Test @@ -99,13 +95,7 @@ public class VniTableCustomizerTest extends ListReaderCustomizerTest<VniTable, V private void whenLispEidTableVniDumpThrowException() { when(api.lispEidTableVniDump(Mockito.any())) - .thenReturn(new CompletableFuture<LispEidTableVniDetailsReplyDump>() { - @Override - public LispEidTableVniDetailsReplyDump get(final long l, final TimeUnit timeUnit) - throws InterruptedException, ExecutionException, TimeoutException { - throw new ExecutionException(new VppCallbackException("lispEidTableVniDump", 1, -2)); - } - }); + .thenReturn(failedFuture()); } @Override diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VrfSubtableCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VrfSubtableCustomizerTest.java index f18f349d8..955a5a01a 100644 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VrfSubtableCustomizerTest.java +++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/VrfSubtableCustomizerTest.java @@ -11,7 +11,6 @@ import static org.junit.Assert.fail; import io.fd.honeycomb.lisp.translate.read.trait.SubtableReaderTestCase; import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.spi.read.ReaderCustomizer; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException; import io.fd.vpp.jvpp.VppCallbackException; import org.junit.Before; import org.junit.Test; @@ -70,8 +69,7 @@ public class VrfSubtableCustomizerTest extends SubtableReaderTestCase<VrfSubtabl try { customizer.readCurrentAttributes(validId, builder, ctx); } catch (ReadFailedException e) { - assertTrue(e.getCause() instanceof DumpCallFailedException); - assertTrue(e.getCause().getCause() instanceof VppCallbackException); + assertTrue(e.getCause() instanceof VppCallbackException); assertTrue(builder.getTableId() == null); verifyLispEidTableMapDumpNotCalled(); diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutorTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutorTest.java index 14c7c7002..f21b33353 100644 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutorTest.java +++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorDumpExecutorTest.java @@ -12,19 +12,20 @@ import static org.mockito.Mockito.verify; import com.google.common.collect.ImmutableList; import io.fd.honeycomb.lisp.translate.read.dump.executor.params.LocatorDumpParams; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException; +import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.vpp.test.read.JvppDumpExecutorTest; +import io.fd.vpp.jvpp.VppCallbackException; +import io.fd.vpp.jvpp.core.dto.LispLocatorDetails; +import io.fd.vpp.jvpp.core.dto.LispLocatorDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.LispLocatorDump; import java.util.concurrent.TimeoutException; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Captor; import org.mockito.Mockito; -import io.fd.vpp.jvpp.core.dto.LispLocatorDetails; -import io.fd.vpp.jvpp.core.dto.LispLocatorDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.LispLocatorDump; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSet; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class LocatorDumpExecutorTest extends JvppDumpExecutorTest<LocatorDumpExecutor> { @@ -32,10 +33,12 @@ public class LocatorDumpExecutorTest extends JvppDumpExecutorTest<LocatorDumpExe @Captor private ArgumentCaptor<LispLocatorDump> requestCaptor; + private InstanceIdentifier identifier; private LispLocatorDetailsReplyDump validDump; @Before public void init() { + identifier = InstanceIdentifier.create(LocatorSet.class); validDump = new LispLocatorDetailsReplyDump(); LispLocatorDetails detail = new LispLocatorDetails(); @@ -54,28 +57,36 @@ public class LocatorDumpExecutorTest extends JvppDumpExecutorTest<LocatorDumpExe public void testExecuteDumpTimeout() throws Exception { doThrowTimeoutExceptionWhen().lispLocatorDump(Mockito.any()); try { - getExecutor().executeDump(new LocatorDumpParamsBuilder().build()); + getExecutor().executeDump(identifier, new LocatorDumpParamsBuilder().build()); } catch (Exception e) { - assertTrue(e instanceof DumpTimeoutException); + assertTrue(e instanceof ReadFailedException); assertTrue(e.getCause() instanceof TimeoutException); + assertEquals(identifier, ((ReadFailedException) e).getFailedId()); return; } fail("Test should have thrown exception"); } - @Test(expected = DumpCallFailedException.class) - public void testExecuteDumpHalted() throws DumpExecutionFailedException { + @Test + public void testExecuteDumpHalted() throws ReadFailedException { doThrowFailExceptionWhen().lispLocatorDump(Mockito.any()); - getExecutor().executeDump(new LocatorDumpParamsBuilder().build()); + try { + getExecutor().executeDump(identifier, new LocatorDumpParamsBuilder().build()); + } catch (ReadFailedException e) { + assertTrue(e.getCause() instanceof VppCallbackException); + assertEquals(identifier, ((ReadFailedException) e).getFailedId()); + return; + } + fail("Test should have thrown ReadFailedException"); } @Test - public void testExecuteDump() throws DumpExecutionFailedException { + public void testExecuteDump() throws ReadFailedException { doReturnResponseWhen(validDump).lispLocatorDump(Mockito.any()); final LocatorDumpParams params = new LocatorDumpParamsBuilder().setLocatorSetIndex(5).build(); - final LispLocatorDetailsReplyDump reply = getExecutor().executeDump(params); + final LispLocatorDetailsReplyDump reply = getExecutor().executeDump(identifier, params); verify(api, times(1)).lispLocatorDump(requestCaptor.capture()); final LispLocatorDump request = requestCaptor.getValue(); diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutorTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutorTest.java index 0a739b3a8..bb2779ee8 100644 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutorTest.java +++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/LocatorSetsDumpExecutorTest.java @@ -10,20 +10,20 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import com.google.common.collect.ImmutableList; +import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException; import io.fd.honeycomb.vpp.test.read.JvppDumpExecutorTest; +import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetails; +import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.LispLocatorSetDump; import java.nio.charset.StandardCharsets; import java.util.concurrent.TimeoutException; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Captor; -import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetails; -import io.fd.vpp.jvpp.core.dto.LispLocatorSetDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.LispLocatorSetDump; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.locator.sets.grouping.locator.sets.LocatorSet; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class LocatorSetsDumpExecutorTest extends JvppDumpExecutorTest<LocatorSetsDumpExecutor> { @@ -35,8 +35,11 @@ public class LocatorSetsDumpExecutorTest extends JvppDumpExecutorTest<LocatorSet @Captor private ArgumentCaptor<LispLocatorSetDump> requestCaptor; + private InstanceIdentifier identifier; + @Before public void init() { + identifier = InstanceIdentifier.create(LocatorSet.class); validDump = new LispLocatorSetDetailsReplyDump(); LispLocatorSetDetails detail = new LispLocatorSetDetails(); detail.lsIndex = 2; @@ -50,26 +53,27 @@ public class LocatorSetsDumpExecutorTest extends JvppDumpExecutorTest<LocatorSet public void testExecuteDumpTimeout() throws Exception { doThrowTimeoutExceptionWhen().lispLocatorSetDump(any()); try { - getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS); + getExecutor().executeDump(identifier, EntityDumpExecutor.NO_PARAMS); } catch (Exception e) { - assertTrue(e instanceof DumpTimeoutException); + assertTrue(e instanceof ReadFailedException); assertTrue(e.getCause() instanceof TimeoutException); return; } fail("Test should have thrown exception"); } - @Test(expected = DumpCallFailedException.class) - public void testExecuteDumpHalted() throws DumpExecutionFailedException { + @Test(expected = ReadFailedException.class) + public void testExecuteDumpHalted() throws ReadFailedException { doThrowFailExceptionWhen().lispLocatorSetDump(any()); - getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS); + getExecutor().executeDump(identifier, EntityDumpExecutor.NO_PARAMS); } @Test - public void testExecuteDump() throws DumpExecutionFailedException { + public void testExecuteDump() throws ReadFailedException { doReturnResponseWhen(validDump).lispLocatorSetDump(any()); - final LispLocatorSetDetailsReplyDump replyDump = getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS); + final LispLocatorSetDetailsReplyDump replyDump = + getExecutor().executeDump(identifier, EntityDumpExecutor.NO_PARAMS); verify(api, times(1)).lispLocatorSetDump(requestCaptor.capture()); final LispLocatorSetDump request = requestCaptor.getValue(); diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutorTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutorTest.java index 172a89d0a..50aa0391d 100644 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutorTest.java +++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MapResolversDumpExecutorTest.java @@ -8,25 +8,29 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.google.common.collect.ImmutableList; +import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException; import io.fd.honeycomb.vpp.test.read.JvppDumpExecutorTest; +import io.fd.vpp.jvpp.VppCallbackException; +import io.fd.vpp.jvpp.core.dto.LispMapResolverDetails; +import io.fd.vpp.jvpp.core.dto.LispMapResolverDetailsReplyDump; import java.util.concurrent.TimeoutException; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import io.fd.vpp.jvpp.core.dto.LispMapResolverDetails; -import io.fd.vpp.jvpp.core.dto.LispMapResolverDetailsReplyDump; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.map.resolvers.grouping.map.resolvers.MapResolver; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class MapResolversDumpExecutorTest extends JvppDumpExecutorTest<MapResolversDumpExecutor> { private LispMapResolverDetailsReplyDump validDump; + private InstanceIdentifier identifier; + @Before public void init() { + identifier = InstanceIdentifier.create(MapResolver.class); validDump = new LispMapResolverDetailsReplyDump(); final LispMapResolverDetails details = new LispMapResolverDetails(); details.isIpv6 = 0; @@ -40,25 +44,33 @@ public class MapResolversDumpExecutorTest extends JvppDumpExecutorTest<MapResolv public void testExecuteDumpTimeout() throws Exception { doThrowTimeoutExceptionWhen().lispMapResolverDump(Mockito.any()); try { - getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS); - } catch (Exception e) { - assertTrue(e instanceof DumpTimeoutException); + getExecutor().executeDump(identifier, EntityDumpExecutor.NO_PARAMS); + } catch (ReadFailedException e) { assertTrue(e.getCause() instanceof TimeoutException); + assertEquals(identifier, ((ReadFailedException) e).getFailedId()); return; } - fail("Test should have thrown exception"); + fail("Test should have thrown ReadFailedException"); } - @Test(expected = DumpCallFailedException.class) - public void testExecuteDumpHalted() throws DumpExecutionFailedException { + @Test + public void testExecuteDumpHalted() throws ReadFailedException { doThrowFailExceptionWhen().lispMapResolverDump(Mockito.any()); - getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS); + try { + getExecutor().executeDump(identifier, EntityDumpExecutor.NO_PARAMS); + } catch (ReadFailedException e) { + assertTrue(e.getCause() instanceof VppCallbackException); + assertEquals(identifier, ((ReadFailedException) e).getFailedId()); + return; + } + fail("Test should have thrown ReadFailedException"); } @Test - public void testExecuteDump() throws DumpExecutionFailedException { + public void testExecuteDump() throws ReadFailedException { doReturnResponseWhen(validDump).lispMapResolverDump(Mockito.any()); - final LispMapResolverDetailsReplyDump reply = getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS); + final LispMapResolverDetailsReplyDump reply = + getExecutor().executeDump(identifier, EntityDumpExecutor.NO_PARAMS); assertNotNull(reply); assertEquals(1, reply.lispMapResolverDetails.size()); diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutorTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutorTest.java index b58c0aebf..f25099baf 100644 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutorTest.java +++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/MappingsDumpExecutorTest.java @@ -15,18 +15,19 @@ import static org.mockito.Mockito.verify; import com.google.common.collect.ImmutableList; import io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException; +import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.vpp.test.read.JvppDumpExecutorTest; +import io.fd.vpp.jvpp.VppCallbackException; +import io.fd.vpp.jvpp.core.dto.LispEidTableDetails; +import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump; +import io.fd.vpp.jvpp.core.dto.LispEidTableDump; import java.util.concurrent.TimeoutException; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; import org.mockito.Captor; -import io.fd.vpp.jvpp.core.dto.LispEidTableDetails; -import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump; -import io.fd.vpp.jvpp.core.dto.LispEidTableDump; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.dp.subtable.grouping.local.mappings.LocalMapping; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class MappingsDumpExecutorTest extends JvppDumpExecutorTest<MappingsDumpExecutor> { @@ -35,12 +36,15 @@ public class MappingsDumpExecutorTest extends JvppDumpExecutorTest<MappingsDumpE @Captor private ArgumentCaptor<LispEidTableDump> requestCaptor; + private InstanceIdentifier identifier; + private LispEidTableDetailsReplyDump validDump; private MappingsDumpParams emptyParams; private MappingsDumpParams validParams; @Before public void init() { + identifier = InstanceIdentifier.create(LocalMapping.class); validDump = new LispEidTableDetailsReplyDump(); LispEidTableDetails detail = new LispEidTableDetails(); @@ -67,25 +71,33 @@ public class MappingsDumpExecutorTest extends JvppDumpExecutorTest<MappingsDumpE public void testExecuteDumpTimeout() throws Exception { doThrowTimeoutExceptionWhen().lispEidTableDump(any()); try { - getExecutor().executeDump(emptyParams); + getExecutor().executeDump(identifier, emptyParams); } catch (Exception e) { - assertTrue(e instanceof DumpTimeoutException); + assertTrue(e instanceof ReadFailedException); assertTrue(e.getCause() instanceof TimeoutException); + assertEquals(identifier, ((ReadFailedException) e).getFailedId()); return; } fail("Test should have thrown exception"); } - @Test(expected = DumpCallFailedException.class) - public void testExecuteDumpHalted() throws DumpExecutionFailedException { + @Test + public void testExecuteDumpHalted() throws Exception { doThrowFailExceptionWhen().lispEidTableDump(any()); - getExecutor().executeDump(emptyParams); + try { + getExecutor().executeDump(identifier, emptyParams); + } catch (ReadFailedException e) { + assertTrue(e.getCause() instanceof VppCallbackException); + assertEquals(identifier, ((ReadFailedException) e).getFailedId()); + return; + } + fail("Test should have thrown ReadFailedException"); } @Test - public void testExecuteDump() throws DumpExecutionFailedException { + public void testExecuteDump() throws ReadFailedException { doReturnResponseWhen(validDump).lispEidTableDump(any()); - final LispEidTableDetailsReplyDump reply = getExecutor().executeDump(validParams); + final LispEidTableDetailsReplyDump reply = getExecutor().executeDump(identifier, validParams); verify(api, times(1)).lispEidTableDump(requestCaptor.capture()); final LispEidTableDump request = requestCaptor.getValue(); diff --git a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutorTest.java b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutorTest.java index b955609c5..48a327cbe 100644 --- a/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutorTest.java +++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutorTest.java @@ -7,59 +7,66 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import com.google.common.collect.ImmutableList; +import io.fd.honeycomb.translate.read.ReadFailedException; import io.fd.honeycomb.translate.util.read.cache.EntityDumpExecutor; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.DumpExecutionFailedException; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpCallFailedException; -import io.fd.honeycomb.translate.util.read.cache.exceptions.execution.i.DumpTimeoutException; import io.fd.honeycomb.vpp.test.read.JvppDumpExecutorTest; +import io.fd.vpp.jvpp.VppCallbackException; import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetails; import io.fd.vpp.jvpp.core.dto.LispEidTableVniDetailsReplyDump; import java.util.concurrent.TimeoutException; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetails; -import io.fd.vpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev160520.eid.table.grouping.eid.table.VniTable; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; public class VniTableDumpExecutorTest extends JvppDumpExecutorTest<VniTableDumpExecutor> { private LispEidTableVniDetailsReplyDump validDump; + private InstanceIdentifier<VniTable> identifier; @Before public void init() { validDump = new LispEidTableVniDetailsReplyDump(); + identifier = InstanceIdentifier.create(VniTable.class); LispEidTableVniDetails detail = new LispEidTableVniDetails(); detail.vni = 2; detail.context = 4; validDump.lispEidTableVniDetails = ImmutableList.of(detail); } - @Test(expected = DumpCallFailedException.class) - public void testExecuteDumpFail() throws DumpExecutionFailedException { + @Test + public void testExecuteDumpFail() throws Exception { doThrowFailExceptionWhen().lispEidTableVniDump(Mockito.any()); - getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS); - } + try { + getExecutor().executeDump(identifier, EntityDumpExecutor.NO_PARAMS); + } catch (ReadFailedException e) { + assertTrue(e.getCause() instanceof VppCallbackException); + return; + } + fail("Test should have thrown ReadFailedException"); + } @Test public void testExecuteDumpTimeout() throws Exception { doThrowTimeoutExceptionWhen().lispEidTableVniDump(Mockito.any()); try { - getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS); - } catch (Exception e) { - assertTrue(e instanceof DumpTimeoutException); + getExecutor().executeDump(identifier, EntityDumpExecutor.NO_PARAMS); + } catch (ReadFailedException e) { assertTrue(e.getCause() instanceof TimeoutException); return; } - fail("Test should have thrown exception"); + fail("Test should have thrown ReadFailedException"); } @Test - public void testExecuteDump() throws DumpExecutionFailedException { + public void testExecuteDump() throws Exception { doReturnResponseWhen(validDump).lispEidTableVniDump(Mockito.any()); - final LispEidTableVniDetailsReplyDump reply = getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS); + final LispEidTableVniDetailsReplyDump reply = + getExecutor().executeDump(identifier, EntityDumpExecutor.NO_PARAMS); assertNotNull(reply); assertEquals(1, reply.lispEidTableVniDetails.size()); |