Fix checkstyle problems not detected by the current version
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / databroker / ClientBackedDataStoreTest.java
index 24a58759673f134b6c24f0f020a7f2f0a09caa2d..d7d774d699b3d791d59fd8d17b3d484e90feaa6d 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;
@@ -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
+}