Search in sources :

Example 1 with GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder in project openflowplugin by opendaylight.

the class OpendaylightFlowStatisticsServiceImpl2Test method testGetAggregateFlowStatisticsFromFlowTableForGivenMatch.

@Test
public void testGetAggregateFlowStatisticsFromFlowTableForGivenMatch() throws Exception {
    Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider).commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
    Mockito.doAnswer((Answer<Void>) invocation -> {
        final MultipartReplyMessageBuilder messageBuilder = new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3);
        rqContextMp.setResult(RpcResultBuilder.success(Collections.<MultipartReply>singletonList(messageBuilder.build())).build());
        return null;
    }).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
    Mockito.when(translator.translate(Matchers.any(MultipartReply.class), Matchers.same(deviceInfo), Matchers.isNull())).thenReturn(new AggregatedFlowStatisticsBuilder().build());
    GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder input = new GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder().setNode(createNodeRef("unitProt:123")).setPriority(5).setTableId((short) 1);
    final Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> resultFuture = flowStatisticsService.getAggregateFlowStatisticsFromFlowTableForGivenMatch(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(1, rpcResult.getResult().getAggregatedFlowStatistics().size());
    Assert.assertEquals(MultipartType.OFPMPAGGREGATE, requestInput.getValue().getType());
}
Also used : GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Matchers(org.mockito.Matchers) Mock(org.mockito.Mock) Captor(org.mockito.Captor) Answer(org.mockito.stubbing.Answer) Future(java.util.concurrent.Future) ArgumentCaptor(org.mockito.ArgumentCaptor) MessageTranslator(org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator) ConvertorManagerFactory(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManagerFactory) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) AbstractRequestContext(org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext) Test(org.junit.Test) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) FutureCallback(com.google.common.util.concurrent.FutureCallback) OFConstants(org.opendaylight.openflowplugin.api.OFConstants) Mockito(org.mockito.Mockito) List(java.util.List) ConvertorManager(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager) GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder) EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) TranslatorKey(org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey) Assert(org.junit.Assert) Collections(java.util.Collections) AggregatedFlowStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics) AggregatedFlowStatisticsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder) GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput) EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) AggregatedFlowStatisticsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder) FutureCallback(com.google.common.util.concurrent.FutureCallback) Test(org.junit.Test)

Example 2 with GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder in project openflowplugin by opendaylight.

the class SingleLayerAggregateFlowMultipartServiceTest method handleAndReply.

@Test
public void handleAndReply() throws Exception {
    mockSuccessfulFuture(Collections.singletonList(new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyFlowAggregateStatsBuilder().setByteCount(new Counter64(BYTE_COUNT)).build()).build()));
    final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input = new GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder().setTableId(TABLE_ID).build();
    final Future<RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput>> rpcResultFuture = service.handleAndReply(input);
    final RpcResult<GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput> sendAggregateFlowMpRequestOutputRpcResult = rpcResultFuture.get();
    assertEquals(BYTE_COUNT, sendAggregateFlowMpRequestOutputRpcResult.getResult().getAggregatedFlowStatistics().get(0).getByteCount().getValue());
}
Also used : MultipartReplyFlowAggregateStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.multipart.reply.multipart.reply.body.MultipartReplyFlowAggregateStatsBuilder) GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput) GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MultipartReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder) Test(org.junit.Test)

Example 3 with GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder in project openflowplugin by opendaylight.

the class SingleLayerAggregateFlowMultipartServiceTest method buildRequest.

@Test
public void buildRequest() throws Exception {
    final GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput input = new GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder().setTableId(TABLE_ID).build();
    final OfHeader ofHeader = service.buildRequest(DUMMY_XID, input);
    assertEquals(MultipartRequest.class, ofHeader.getImplementedInterface());
    final MultipartRequestFlowAggregateStats result = MultipartRequestFlowAggregateStats.class.cast(MultipartRequest.class.cast(ofHeader).getMultipartRequestBody());
    assertEquals(TABLE_ID, result.getTableId().shortValue());
}
Also used : GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder) MultipartRequestFlowAggregateStats(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.multipart.request.multipart.request.body.MultipartRequestFlowAggregateStats) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInputBuilder)3 GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchInput)2 GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForGivenMatchOutput)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 Collections (java.util.Collections)1 List (java.util.List)1 Future (java.util.concurrent.Future)1 Assert (org.junit.Assert)1 ArgumentCaptor (org.mockito.ArgumentCaptor)1 Captor (org.mockito.Captor)1 Matchers (org.mockito.Matchers)1 Mock (org.mockito.Mock)1 Mockito (org.mockito.Mockito)1 Answer (org.mockito.stubbing.Answer)1 OFConstants (org.opendaylight.openflowplugin.api.OFConstants)1 MessageTranslator (org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator)1 TranslatorKey (org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey)1 EventIdentifier (org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier)1