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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations