diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2016-09-28 09:33:32 +0200 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-09-28 07:51:13 +0000 |
commit | cab279cb43bf47fb4a15987f5130c7a09df9abee (patch) | |
tree | 999f26efd2799975e2e5c2b38d47a485a4884f9a /lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutorTest.java | |
parent | 482e75efafbc43ec4c7e5a0516b688dee721fc27 (diff) |
Lisp test coverage increased to ~80%
Change-Id: Id4e9072ebb8d66e532e30c1dc3bb6036bfdc9012
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutorTest.java')
-rw-r--r-- | lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutorTest.java | 76 |
1 files changed, 76 insertions, 0 deletions
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 new file mode 100644 index 000000000..13033bf65 --- /dev/null +++ b/lisp/lisp2vpp/src/test/java/io/fd/honeycomb/lisp/translate/read/dump/executor/VniTableDumpExecutorTest.java @@ -0,0 +1,76 @@ +package io.fd.honeycomb.lisp.translate.read.dump.executor; + + +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 com.google.common.collect.ImmutableList; +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 java.util.concurrent.TimeoutException; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; +import org.openvpp.jvpp.core.dto.LispEidTableMapDetails; +import org.openvpp.jvpp.core.dto.LispEidTableMapDetailsReplyDump; + + +public class VniTableDumpExecutorTest extends JvppDumpExecutorTest<VniTableDumpExecutor> { + + private LispEidTableMapDetailsReplyDump validDump; + + @Before + public void init() { + validDump = new LispEidTableMapDetailsReplyDump(); + LispEidTableMapDetails detail = new LispEidTableMapDetails(); + detail.dpTable = 1; + detail.vni = 2; + detail.context = 4; + validDump.lispEidTableMapDetails = ImmutableList.of(detail); + } + + @Test(expected = DumpCallFailedException.class) + public void testExecuteDumpFail() throws DumpExecutionFailedException { + doThrowFailExceptionWhen().lispEidTableMapDump(Mockito.any()); + getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS); + } + + + @Test + public void testExecuteDumpTimeout() throws Exception { + doThrowTimeoutExceptionWhen().lispEidTableMapDump(Mockito.any()); + try { + getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS); + } catch (Exception e) { + assertTrue(e instanceof DumpTimeoutException); + assertTrue(e.getCause() instanceof TimeoutException); + return; + } + fail("Test should have thrown exception"); + } + + @Test + public void testExecuteDump() throws DumpExecutionFailedException { + + doReturnResponseWhen(validDump).lispEidTableMapDump(Mockito.any()); + final LispEidTableMapDetailsReplyDump reply = getExecutor().executeDump(EntityDumpExecutor.NO_PARAMS); + + assertNotNull(reply); + assertEquals(1, reply.lispEidTableMapDetails.size()); + final LispEidTableMapDetails detail = reply.lispEidTableMapDetails.get(0); + + assertEquals(4, detail.context); + assertEquals(1, detail.dpTable); + assertEquals(2, detail.vni); + } + + @Override + protected VniTableDumpExecutor initExecutor() { + return new VniTableDumpExecutor(api); + } +}
\ No newline at end of file |