Fix codestyle
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / statistics / services / direct / multilayer / FlowDirectStatisticsServiceTest.java
index e8c734777a23d62acc54cf99c170ab32cbecfe01..6f598f8737912d8828f4974b44a108873221cbec 100644 (file)
@@ -17,11 +17,12 @@ 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.opendaylight.openflowplugin.api.openflow.device.Xid;
 import org.opendaylight.openflowplugin.api.openflow.registry.flow.DeviceFlowRegistry;
+import org.opendaylight.openflowplugin.impl.registry.flow.FlowDescriptorFactory;
 import org.opendaylight.openflowplugin.impl.statistics.services.direct.AbstractDirectStatisticsServiceTest;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.direct.statistics.rev160511.GetFlowStatisticsOutput;
@@ -32,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.M
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyFlowCase;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.MultipartReplyFlow;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.flow._case.multipart.reply.flow.FlowStats;
@@ -45,9 +47,12 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer
 
     @Override
     public void setUp() throws Exception {
-        service = new FlowDirectStatisticsService(requestContextStack, deviceContext, convertorManager, multipartWriterProvider);
+        service = new FlowDirectStatisticsService(requestContextStack,
+                                                  deviceContext,
+                                                  convertorManager,
+                                                  multipartWriterProvider);
         final DeviceFlowRegistry registry = mock(DeviceFlowRegistry.class);
-        when(registry.storeIfNecessary(any())).thenReturn(new FlowId("1"));
+        when(registry.retrieveDescriptor(any())).thenReturn(FlowDescriptorFactory.create(TABLE_NO, new FlowId("1")));
         when(deviceContext.getDeviceFlowRegistry()).thenReturn(registry);
     }
 
@@ -58,7 +63,10 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer
         when(input.getNode()).thenReturn(createNodeRef(NODE_ID));
         when(input.getTableId()).thenReturn(TABLE_NO);
 
-        final MultipartRequestFlowCase body = (MultipartRequestFlowCase) service.buildRequestBody(input);
+        final MultipartRequestFlowCase body = (MultipartRequestFlowCase) ((MultipartRequestInput) service
+            .buildRequest(new Xid(42L), input))
+            .getMultipartRequestBody();
+
         final MultipartRequestFlow flow = body.getMultipartRequestFlow();
 
         assertEquals(TABLE_NO, flow.getTableId());
@@ -76,7 +84,8 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer
                 .setByteCount(BigInteger.ONE)
                 .setPacketCount(BigInteger.ONE)
                 .setFlags(mock(FlowModFlags.class))
-                .setMatch(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder()
+                .setMatch(new org.opendaylight.yang.gen.v1.urn
+                        .opendaylight.openflow.oxm.rev150225.match.grouping.MatchBuilder()
                         .setMatchEntry(Collections.emptyList())
                         .build())
                 .build();
@@ -102,7 +111,7 @@ public class FlowDirectStatisticsServiceTest extends AbstractDirectStatisticsSer
         when(stat.getTableId()).thenReturn(TABLE_NO);
         when(stat.getMatch()).thenReturn(new MatchBuilder().build());
 
-        final List<FlowAndStatisticsMapList> stats = Arrays.asList(stat);
+        final List<FlowAndStatisticsMapList> stats = Collections.singletonList(stat);
         final GetFlowStatisticsOutput output = mock(GetFlowStatisticsOutput.class);
         when(output.getFlowAndStatisticsMapList()).thenReturn(stats);