Search in sources :

Example 91 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult in project openflowplugin by opendaylight.

the class SingleLayerExperimenterMultipartServiceTest method handleAndReply.

@Test
public void handleAndReply() throws Exception {
    mockSuccessfulFuture(Collections.singletonList(new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyExperimenterBuilder().setExperimenterMessageOfChoice(mockExperimenter()).build()).build()));
    final SendExperimenterMpRequestInput input = new SendExperimenterMpRequestInputBuilder().setExperimenterMessageOfChoice(mockExperimenter()).build();
    final Future<RpcResult<SendExperimenterMpRequestOutput>> rpcResultFuture = service.handleAndReply(input);
    final RpcResult<SendExperimenterMpRequestOutput> sendExperimenterMpRequestOutputRpcResult = rpcResultFuture.get();
    assertEquals(DummyExperimenter.class, sendExperimenterMpRequestOutputRpcResult.getResult().getExperimenterCoreMessageItem().get(0).getExperimenterMessageOfChoice().getImplementedInterface());
}
Also used : SendExperimenterMpRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.mp.message.service.rev151020.SendExperimenterMpRequestInput) SendExperimenterMpRequestInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.mp.message.service.rev151020.SendExperimenterMpRequestInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MultipartReplyBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder) SendExperimenterMpRequestOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.mp.message.service.rev151020.SendExperimenterMpRequestOutput) MultipartReplyExperimenterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.multipart.reply.multipart.reply.body.MultipartReplyExperimenterBuilder) Test(org.junit.Test)

Example 92 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult 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 93 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult in project openflowplugin by opendaylight.

the class OpendaylightFlowTableStatisticsServiceImplTest method testGetFlowTablesStatistics.

@Test
public void testGetFlowTablesStatistics() throws Exception {
    Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider).commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
    GetFlowTablesStatisticsInputBuilder input = new GetFlowTablesStatisticsInputBuilder().setNode(createNodeRef("unitProt:123"));
    rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setMultipartReplyBody(new MultipartReplyTableCaseBuilder().setMultipartReplyTable(new MultipartReplyTableBuilder().setTableStats(Collections.singletonList(new TableStatsBuilder().setActiveCount(31L).setLookupCount(BigInteger.valueOf(32L)).setMatchedCount(BigInteger.valueOf(33L)).setMaxEntries(34L).setName("test-table").setNwDstMask((short) 35).setNwSrcMask((short) 36).setTableId(TABLE_ID).build())).build()).build()).build())).build();
    final Future<RpcResult<GetFlowTablesStatisticsOutput>> resultFuture = flowTableStatisticsService.getFlowTablesStatistics(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetFlowTablesStatisticsOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPTABLE, requestInput.getValue().getType());
    Mockito.verify(notificationPublishService).offerNotification(Matchers.<Notification>any());
}
Also used : MultipartReplyTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.MultipartReplyTableBuilder) GetFlowTablesStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsInputBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetFlowTablesStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.table.statistics.rev131215.GetFlowTablesStatisticsOutput) TableStatsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.table._case.multipart.reply.table.TableStatsBuilder) FutureCallback(com.google.common.util.concurrent.FutureCallback) MultipartReplyTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyTableCaseBuilder) Test(org.junit.Test)

Example 94 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult in project openflowplugin by opendaylight.

the class OpendaylightMeterStatisticsServiceImplTest method testGetAllMeterConfigStatistics.

@Test
public void testGetAllMeterConfigStatistics() throws Exception {
    GetAllMeterConfigStatisticsInputBuilder input = new GetAllMeterConfigStatisticsInputBuilder().setNode(createNodeRef("unitProt:123"));
    rpcResult = RpcResultBuilder.<Object>success(Collections.singletonList(new MultipartReplyMessageBuilder().setVersion(OFConstants.OFP_VERSION_1_3).setMultipartReplyBody(new MultipartReplyMeterConfigCaseBuilder().setMultipartReplyMeterConfig(new MultipartReplyMeterConfigBuilder().setMeterConfig(Collections.singletonList(new MeterConfigBuilder().setFlags(new MeterFlags(true, false, false, false)).setMeterId(METER_ID).setBands(Collections.singletonList(new BandsBuilder().setMeterBand(new MeterBandDropCaseBuilder().setMeterBandDrop(new MeterBandDropBuilder().setBurstSize(61L).setRate(62L).setType(MeterBandType.OFPMBTDROP).build()).build()).build())).build())).build()).build()).build())).build();
    final Future<RpcResult<GetAllMeterConfigStatisticsOutput>> resultFuture = meterStatisticsService.getAllMeterConfigStatistics(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetAllMeterConfigStatisticsOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPMETERCONFIG, requestInput.getValue().getType());
}
Also used : MultipartReplyMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder) MeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.MeterConfigBuilder) GetAllMeterConfigStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsOutput) MultipartReplyMeterConfigBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.MultipartReplyMeterConfigBuilder) MeterBandDropBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.meter.band.drop._case.MeterBandDropBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) MeterBandDropCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.meter.band.header.meter.band.MeterBandDropCaseBuilder) MultipartReplyMeterConfigCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterConfigCaseBuilder) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) GetAllMeterConfigStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetAllMeterConfigStatisticsInputBuilder) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) BandsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.config._case.multipart.reply.meter.config.meter.config.BandsBuilder) Test(org.junit.Test)

Example 95 with RpcResult

use of org.opendaylight.yangtools.yang.common.RpcResult in project openflowplugin by opendaylight.

the class OpendaylightMeterStatisticsServiceImplTest method testGetMeterStatistics.

@Test
public void testGetMeterStatistics() throws Exception {
    GetMeterStatisticsInputBuilder input = new GetMeterStatisticsInputBuilder().setNode(createNodeRef("unitProt:123")).setMeterId(new MeterId(21L));
    rpcResult = buildMeterStatisticsReply();
    final Future<RpcResult<GetMeterStatisticsOutput>> resultFuture = meterStatisticsService.getMeterStatistics(input.build());
    Assert.assertTrue(resultFuture.isDone());
    final RpcResult<GetMeterStatisticsOutput> rpcResult = resultFuture.get();
    Assert.assertTrue(rpcResult.isSuccessful());
    Assert.assertEquals(MultipartType.OFPMPMETER, requestInput.getValue().getType());
}
Also used : GetMeterStatisticsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetMeterStatisticsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsInputBuilder) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) Test(org.junit.Test)

Aggregations

RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)360 Test (org.junit.Test)120 ExecutionException (java.util.concurrent.ExecutionException)118 ArrayList (java.util.ArrayList)61 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)37 InOrder (org.mockito.InOrder)30 List (java.util.List)29 BigInteger (java.math.BigInteger)26 NodeRef (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef)25 FutureCallback (com.google.common.util.concurrent.FutureCallback)24 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)24 AllocateIdOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)24 RpcError (org.opendaylight.yangtools.yang.common.RpcError)24 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)23 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)23 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)22 Future (java.util.concurrent.Future)21 Flow (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow)21 Logger (org.slf4j.Logger)21 LoggerFactory (org.slf4j.LoggerFactory)21