Migrate restconf to mockito ArgumentMatchers
[netconf.git] / restconf / restconf-nb-bierman02 / src / test / java / org / opendaylight / controller / sal / restconf / impl / test / BrokerFacadeTest.java
index 287598868ff5582e3355060d6defd43b7db6058f..ae3bf69939a587aaa899f114a04e1d5a27304e12 100644 (file)
@@ -14,8 +14,8 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertSame;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.inOrder;
 import static org.mockito.Mockito.mock;
@@ -36,7 +36,6 @@ import org.mockito.InOrder;
 import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.MockitoAnnotations;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
@@ -66,6 +65,7 @@ import org.opendaylight.restconf.common.errors.RestconfError.ErrorTag;
 import org.opendaylight.restconf.common.errors.RestconfError.ErrorType;
 import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.common.patch.PatchStatusContext;
+import org.opendaylight.restconf.common.util.DataChangeScope;
 import org.opendaylight.yang.gen.v1.urn.sal.restconf.event.subscription.rev140708.NotificationOutputTypeGrouping.NotificationOutputType;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.common.QName;
@@ -100,7 +100,7 @@ public class BrokerFacadeTest {
     @Mock
     private DOMDataReadWriteTransaction rwTransaction;
 
-    private final BrokerFacade brokerFacade = BrokerFacade.getInstance();
+    private BrokerFacade brokerFacade;
     private final NormalizedNode<?, ?> dummyNode = createDummyNode("test:module", "2014-01-09", "interfaces");
     private final CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> dummyNodeInFuture =
             wrapDummyNode(this.dummyNode);
@@ -116,10 +116,7 @@ public class BrokerFacadeTest {
         controllerContext = TestRestconfUtils.newControllerContext(
                 TestUtils.loadSchemaContext("/full-versions/test-module", "/modules"));
 
-        this.brokerFacade.setDomDataBroker(this.domDataBroker);
-        this.brokerFacade.setDomNotificationService(this.domNotification);
-        this.brokerFacade.setRpcService(this.mockRpcService);
-        this.brokerFacade.setControllerContext(controllerContext);
+        brokerFacade = BrokerFacade.newInstance(mockRpcService, domDataBroker, domNotification, controllerContext);
 
         when(this.domDataBroker.newReadOnlyTransaction()).thenReturn(this.readTransaction);
         when(this.domDataBroker.newWriteOnlyTransaction()).thenReturn(this.writeTransaction);
@@ -167,13 +164,6 @@ public class BrokerFacadeTest {
         assertSame("readOperationalData", this.dummyNode, actualNode);
     }
 
-    @Test(expected = RestconfDocumentedException.class)
-    public void testReadOperationalDataWithNoDataBroker() {
-        this.brokerFacade.setDomDataBroker(null);
-
-        this.brokerFacade.readOperationalData(this.instanceID);
-    }
-
     @Test
     public void test503() throws Exception {
         final RpcError error = RpcResultBuilder.newError(
@@ -207,12 +197,6 @@ public class BrokerFacadeTest {
         assertSame("invokeRpc", expResult, actualResult);
     }
 
-    @Test(expected = RestconfDocumentedException.class)
-    public void testInvokeRpcWithNoConsumerSession() {
-        brokerFacade.setDomDataBroker(null);
-        this.brokerFacade.invokeRpc(this.type, this.dummyNode);
-    }
-
     @Test
     public void testCommitConfigurationDataPut() throws Exception {
         @SuppressWarnings("unchecked")