Add create/cancel/create test for PingPongTransactionChain 63/101263/2
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 23 May 2022 11:44:06 +0000 (13:44 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 23 May 2022 11:54:18 +0000 (13:54 +0200)
Extend the test to cover allocation of next transaction after
a vaild cancel() call.

JIRA: MDSAL-698
Change-Id: Icbaacaa1140cdb6f1d0ffc98cd7b9411db578f6b
Signed-off-by: Samuel Schneider <samuel.schneider@pantheon.tech>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
dom/mdsal-dom-spi/src/test/java/org/opendaylight/mdsal/dom/spi/PingPongTransactionChainTest.java

index a33f4929496bc6a95e73f929a96d9db386ed13d8..f3e2e645ce444c462386476bd0e5265d5265e3b4 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.mdsal.dom.spi;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
@@ -84,6 +85,7 @@ public class PingPongTransactionChainTest {
     public void testIdleFailure() {
         final var cause = new Throwable();
         doNothing().when(listener).onTransactionChainFailed(pingPong, null, cause);
+        doReturn("mock").when(chain).toString();
         pingPongListener.onTransactionChainFailed(chain, rwTx, cause);
         verify(listener).onTransactionChainFailed(pingPong, null, cause);
     }
@@ -203,6 +205,13 @@ public class PingPongTransactionChainTest {
         verify(rwTx).cancel();
     }
 
+    @Test
+    public void testNewAfterSuccessfulCancel() {
+        doReturn(true).when(rwTx).cancel();
+        pingPong.newWriteOnlyTransaction().cancel();
+        assertNotNull(pingPong.newWriteOnlyTransaction());
+    }
+
     private static <T> T assertDone(final FluentFuture<T> future) {
         try {
             return Futures.getDone(future);