Switch to MD-SAL APIs
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / statistics / services / direct / multilayer / QueueDirectStatisticsServiceTest.java
index 9944e075d7d03443c1432267625fe2121759e175..c2ce06a194c93c40c9d576b5e835ca3b8db858a7 100644 (file)
@@ -5,22 +5,22 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.openflowplugin.impl.statistics.services.direct.multilayer;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-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.lenient;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.verify;
 import static org.mockito.Mockito.when;
 
 import java.math.BigInteger;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.junit.Test;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetQueueStatisticsInput;
@@ -53,7 +53,7 @@ public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsSe
     public void testBuildRequestBody() throws Exception {
         final GetQueueStatisticsInput input = mock(GetQueueStatisticsInput.class);
 
-        when(input.getNode()).thenReturn(createNodeRef(NODE_ID));
+        lenient().when(input.getNode()).thenReturn(createNodeRef(NODE_ID));
         when(input.getQueueId()).thenReturn(new QueueId(QUEUE_NO));
         when(input.getNodeConnectorId()).thenReturn(new NodeConnectorId(NODE_ID + ":" + PORT_NO));
 
@@ -94,10 +94,25 @@ public class QueueDirectStatisticsServiceTest extends AbstractDirectStatisticsSe
         assertEquals(map.getNodeConnectorId(), nodeConnectorId);
     }
 
+    @Test
+    public void testStoreStatisticsBarePortNo() throws Exception {
+        final QueueIdAndStatisticsMap map = mock(QueueIdAndStatisticsMap.class);
+        when(map.getQueueId()).thenReturn(new QueueId(QUEUE_NO));
+        when(map.getNodeConnectorId()).thenReturn(new NodeConnectorId("1"));
+
+        final List<QueueIdAndStatisticsMap> maps = Collections.singletonList(map);
+        final GetQueueStatisticsOutput output = mock(GetQueueStatisticsOutput.class);
+        when(output.getQueueIdAndStatisticsMap()).thenReturn(maps);
+
+        multipartWriterProvider.lookup(MultipartType.OFPMPQUEUE).get().write(output, true);
+        verify(deviceContext).writeToTransactionWithParentsSlow(eq(LogicalDatastoreType.OPERATIONAL), any(), any());
+    }
+
     @Override
     public void testStoreStatistics() throws Exception {
         final QueueIdAndStatisticsMap map = mock(QueueIdAndStatisticsMap.class);
         when(map.getQueueId()).thenReturn(new QueueId(QUEUE_NO));
+        when(map.getNodeConnectorId()).thenReturn(new NodeConnectorId("openflow:1:1"));
 
         final List<QueueIdAndStatisticsMap> maps = Collections.singletonList(map);
         final GetQueueStatisticsOutput output = mock(GetQueueStatisticsOutput.class);