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.junit.Test;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest;
@Override
public void setUp() throws Exception {
- service = new QueueDirectStatisticsService(requestContextStack, deviceContext, convertorManager, multipartWriterProvider);
+ service = new QueueDirectStatisticsService(requestContextStack,
+ deviceContext,
+ convertorManager,
+ multipartWriterProvider);
}
@Override
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(nodeConnectorId);
assertEquals(map.getNodeConnectorId().getValue(), PORT_NO.toString());
}
+ @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 = Arrays.asList(map);
+ final List<QueueIdAndStatisticsMap> maps = Collections.singletonList(map);
final GetQueueStatisticsOutput output = mock(GetQueueStatisticsOutput.class);
when(output.getQueueIdAndStatisticsMap()).thenReturn(maps);