Convert mdsal submit() calls to commit()
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / databroker / ClientBackedDataStoreTest.java
index 24a58759673f134b6c24f0f020a7f2f0a09caa2d..cf08d3311f36b9357f3bfdd454bcc76d9e30d731 100644 (file)
@@ -7,7 +7,6 @@
  */
 package org.opendaylight.controller.cluster.databroker;
 
-import java.lang.reflect.Field;
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
@@ -20,7 +19,6 @@ import org.opendaylight.controller.cluster.access.concepts.FrontendType;
 import org.opendaylight.controller.cluster.access.concepts.LocalHistoryIdentifier;
 import org.opendaylight.controller.cluster.access.concepts.MemberName;
 import org.opendaylight.controller.cluster.access.concepts.TransactionIdentifier;
-import org.opendaylight.controller.cluster.databroker.actors.dds.AbstractClientHandle;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientLocalHistory;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientSnapshot;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
@@ -28,10 +26,10 @@ import org.opendaylight.controller.cluster.databroker.actors.dds.DataStoreClient
 import org.opendaylight.controller.cluster.datastore.DatastoreContext;
 import org.opendaylight.controller.cluster.datastore.utils.ActorContext;
 import org.opendaylight.controller.md.cluster.datastore.model.TestModel;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreReadWriteTransaction;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreTransactionChain;
-import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreReadWriteTransaction;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreTransactionChain;
+import org.opendaylight.mdsal.dom.spi.store.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
 public class ClientBackedDataStoreTest {
@@ -69,13 +67,8 @@ public class ClientBackedDataStoreTest {
 
         Mockito.when(actorContext.getSchemaContext()).thenReturn(schemaContext);
         Mockito.when(actorContext.getDatastoreContext()).thenReturn(DatastoreContext.newBuilder().build());
-
-        final Field transactionIdField = AbstractClientHandle.class.getDeclaredField("transactionId");
-        transactionIdField.setAccessible(true);
-
-        // set transaction ids to mocked objects
-        transactionIdField.set(clientTransaction, TRANSACTION_IDENTIFIER);
-        transactionIdField.set(clientSnapshot, TRANSACTION_IDENTIFIER);
+        Mockito.when(clientTransaction.getIdentifier()).thenReturn(TRANSACTION_IDENTIFIER);
+        Mockito.when(clientSnapshot.getIdentifier()).thenReturn(TRANSACTION_IDENTIFIER);
 
         Mockito.when(clientActor.getIdentifier()).thenReturn(CLIENT_IDENTIFIER);
         Mockito.when(clientActor.createTransaction()).thenReturn(clientTransaction);
@@ -85,7 +78,7 @@ public class ClientBackedDataStoreTest {
 
     @Test
     public void testCreateTransactionChain() throws Exception {
-        try (final ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
+        try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
                 actorContext, UNKNOWN_ID, clientActor)) {
             final DOMStoreTransactionChain txChain = clientBackedDataStore.createTransactionChain();
             Assert.assertNotNull(txChain);
@@ -95,7 +88,7 @@ public class ClientBackedDataStoreTest {
 
     @Test
     public void testNewReadOnlyTransaction() throws Exception {
-        try (final ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
+        try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
                 actorContext, UNKNOWN_ID, clientActor)) {
             final DOMStoreReadTransaction tx = clientBackedDataStore.newReadOnlyTransaction();
             Assert.assertNotNull(tx);
@@ -105,7 +98,7 @@ public class ClientBackedDataStoreTest {
 
     @Test
     public void testNewWriteOnlyTransaction() throws Exception {
-        try (final ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
+        try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
                 actorContext, UNKNOWN_ID, clientActor)) {
             final DOMStoreWriteTransaction tx = clientBackedDataStore.newWriteOnlyTransaction();
             Assert.assertNotNull(tx);
@@ -115,11 +108,11 @@ public class ClientBackedDataStoreTest {
 
     @Test
     public void testNewReadWriteTransaction() throws Exception {
-        try (final ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
+        try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
                 actorContext, UNKNOWN_ID, clientActor)) {
             final DOMStoreReadWriteTransaction tx = clientBackedDataStore.newReadWriteTransaction();
             Assert.assertNotNull(tx);
             Mockito.verify(clientActor, Mockito.times(1)).createTransaction();
         }
     }
-}
\ No newline at end of file
+}