Translate uint values for old streams
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / databroker / ClientBackedDataStoreTest.java
index bf107514809355dbcb2cff65384b083178fe3781..bcdbb98d1c6cf04cdb45aa7489fba5457c99d2cb 100644 (file)
@@ -7,8 +7,13 @@
  */
 package org.opendaylight.controller.cluster.databroker;
 
-import org.junit.Assert;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import org.junit.AfterClass;
 import org.junit.Before;
+import org.junit.BeforeClass;
 import org.junit.Test;
 import org.mockito.Mock;
 import org.mockito.Mockito;
@@ -24,12 +29,12 @@ import org.opendaylight.controller.cluster.databroker.actors.dds.ClientSnapshot;
 import org.opendaylight.controller.cluster.databroker.actors.dds.ClientTransaction;
 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.cluster.datastore.utils.ActorUtils;
 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 {
@@ -37,18 +42,20 @@ public class ClientBackedDataStoreTest {
     private static final ClientIdentifier UNKNOWN_ID = ClientIdentifier.create(
             FrontendIdentifier.create(MemberName.forName("local"), FrontendType.forName("unknown")), 0);
 
-    private static FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
+    private static final FrontendIdentifier FRONTEND_IDENTIFIER = FrontendIdentifier.create(
             MemberName.forName("member"), FrontendType.forName("frontend"));
     private static final ClientIdentifier CLIENT_IDENTIFIER = ClientIdentifier.create(FRONTEND_IDENTIFIER, 0);
 
-    private static LocalHistoryIdentifier HISTORY_ID = new LocalHistoryIdentifier(CLIENT_IDENTIFIER, 0);
+    private static final LocalHistoryIdentifier HISTORY_ID = new LocalHistoryIdentifier(CLIENT_IDENTIFIER, 0);
     private static final TransactionIdentifier TRANSACTION_IDENTIFIER = new TransactionIdentifier(HISTORY_ID, 0);
 
+    private static SchemaContext SCHEMA_CONTEXT;
+
     @Mock
     private DataStoreClient clientActor;
 
     @Mock
-    private ActorContext actorContext;
+    private ActorUtils actorUtils;
 
     @Mock
     private ClientLocalHistory clientLocalHistory;
@@ -59,60 +66,68 @@ public class ClientBackedDataStoreTest {
     @Mock
     private ClientSnapshot clientSnapshot;
 
+    @BeforeClass
+    public static void beforeClass() {
+        SCHEMA_CONTEXT = TestModel.createTestContext();
+    }
+
+    @AfterClass
+    public static void afterClass() {
+        SCHEMA_CONTEXT = null;
+    }
+
     @Before
-    public void setUp() throws Exception {
+    public void setUp() {
         MockitoAnnotations.initMocks(this);
 
-        final SchemaContext schemaContext = TestModel.createTestContext();
-
-        Mockito.when(actorContext.getSchemaContext()).thenReturn(schemaContext);
-        Mockito.when(actorContext.getDatastoreContext()).thenReturn(DatastoreContext.newBuilder().build());
-        Mockito.when(clientTransaction.getIdentifier()).thenReturn(TRANSACTION_IDENTIFIER);
-        Mockito.when(clientSnapshot.getIdentifier()).thenReturn(TRANSACTION_IDENTIFIER);
+        when(actorUtils.getSchemaContext()).thenReturn(SCHEMA_CONTEXT);
+        when(actorUtils.getDatastoreContext()).thenReturn(DatastoreContext.newBuilder().build());
+        when(clientTransaction.getIdentifier()).thenReturn(TRANSACTION_IDENTIFIER);
+        when(clientSnapshot.getIdentifier()).thenReturn(TRANSACTION_IDENTIFIER);
 
-        Mockito.when(clientActor.getIdentifier()).thenReturn(CLIENT_IDENTIFIER);
-        Mockito.when(clientActor.createTransaction()).thenReturn(clientTransaction);
-        Mockito.when(clientActor.createLocalHistory()).thenReturn(clientLocalHistory);
-        Mockito.when(clientActor.createSnapshot()).thenReturn(clientSnapshot);
+        when(clientActor.getIdentifier()).thenReturn(CLIENT_IDENTIFIER);
+        when(clientActor.createTransaction()).thenReturn(clientTransaction);
+        when(clientActor.createLocalHistory()).thenReturn(clientLocalHistory);
+        when(clientActor.createSnapshot()).thenReturn(clientSnapshot);
     }
 
     @Test
-    public void testCreateTransactionChain() throws Exception {
-        try (final ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
-                actorContext, UNKNOWN_ID, clientActor)) {
+    public void testCreateTransactionChain() {
+        try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
+                actorUtils, UNKNOWN_ID, clientActor)) {
             final DOMStoreTransactionChain txChain = clientBackedDataStore.createTransactionChain();
-            Assert.assertNotNull(txChain);
-            Mockito.verify(clientActor, Mockito.times(1)).createLocalHistory();
+            assertNotNull(txChain);
+            verify(clientActor, Mockito.times(1)).createLocalHistory();
         }
     }
 
     @Test
-    public void testNewReadOnlyTransaction() throws Exception {
-        try (final ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
-                actorContext, UNKNOWN_ID, clientActor)) {
+    public void testNewReadOnlyTransaction() {
+        try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
+                actorUtils, UNKNOWN_ID, clientActor)) {
             final DOMStoreReadTransaction tx = clientBackedDataStore.newReadOnlyTransaction();
-            Assert.assertNotNull(tx);
-            Mockito.verify(clientActor, Mockito.times(1)).createSnapshot();
+            assertNotNull(tx);
+            verify(clientActor, Mockito.times(1)).createSnapshot();
         }
     }
 
     @Test
-    public void testNewWriteOnlyTransaction() throws Exception {
-        try (final ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
-                actorContext, UNKNOWN_ID, clientActor)) {
+    public void testNewWriteOnlyTransaction() {
+        try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
+                actorUtils, UNKNOWN_ID, clientActor)) {
             final DOMStoreWriteTransaction tx = clientBackedDataStore.newWriteOnlyTransaction();
-            Assert.assertNotNull(tx);
-            Mockito.verify(clientActor, Mockito.times(1)).createTransaction();
+            assertNotNull(tx);
+            verify(clientActor, Mockito.times(1)).createTransaction();
         }
     }
 
     @Test
-    public void testNewReadWriteTransaction() throws Exception {
-        try (final ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
-                actorContext, UNKNOWN_ID, clientActor)) {
+    public void testNewReadWriteTransaction() {
+        try (ClientBackedDataStore clientBackedDataStore = new ClientBackedDataStore(
+                actorUtils, UNKNOWN_ID, clientActor)) {
             final DOMStoreReadWriteTransaction tx = clientBackedDataStore.newReadWriteTransaction();
-            Assert.assertNotNull(tx);
-            Mockito.verify(clientActor, Mockito.times(1)).createTransaction();
+            assertNotNull(tx);
+            verify(clientActor, Mockito.times(1)).createTransaction();
         }
     }
-}
\ No newline at end of file
+}