use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput in project openflowplugin by opendaylight.
the class MeterDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final MultipartReply reply = mock(MultipartReply.class);
final MultipartReplyMeterCase MeterCase = mock(MultipartReplyMeterCase.class);
final MultipartReplyMeter meter = mock(MultipartReplyMeter.class);
final MeterStats meterStat = new MeterStatsBuilder().setMeterId(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterId(METER_NO)).setByteInCount(BigInteger.ONE).setPacketInCount(BigInteger.ONE).setDurationSec(1L).setDurationNsec(1L).setFlowCount(0L).setMeterBandStats(Collections.emptyList()).build();
final List<MeterStats> meterStats = Collections.singletonList(meterStat);
final List<MultipartReply> input = Collections.singletonList(reply);
when(meter.getMeterStats()).thenReturn(meterStats);
when(MeterCase.getMultipartReplyMeter()).thenReturn(meter);
when(reply.getMultipartReplyBody()).thenReturn(MeterCase);
final GetMeterStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getMeterStats().size() > 0);
final org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats stats = output.getMeterStats().get(0);
assertEquals(stats.getMeterId().getValue(), METER_NO);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput in project openflowplugin by opendaylight.
the class OpendaylightDirectStatisticsServiceImplTest method testGetMeterStatisticsFail.
@Test
public void testGetMeterStatisticsFail() throws Exception {
RpcResult<GetMeterStatisticsOutput> result = emptyService.getMeterStatistics(getMeterStatisticsInput).get();
assertFalse(result.isSuccessful());
for (RpcError error : result.getErrors()) {
assertTrue(error.getMessage().contains(AbstractMeterDirectStatisticsService.class.getSimpleName()));
}
verify(meterDirectStatisticsService, times(0)).handleAndReply(getMeterStatisticsInput);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput in project openflowplugin by opendaylight.
the class MeterDirectStatisticsService method buildReply.
@Override
protected GetMeterStatisticsOutput buildReply(List<MultipartReply> input, boolean success) {
final List<MeterStats> meterStats = new ArrayList<>();
if (success) {
for (final MultipartReply mpReply : input) {
final MultipartReplyMeterCase caseBody = (MultipartReplyMeterCase) mpReply.getMultipartReplyBody();
final MultipartReplyMeter replyBody = caseBody.getMultipartReplyMeter();
final Optional<List<MeterStats>> meterStatsList = getConvertorExecutor().convert(replyBody.getMeterStats(), data);
meterStatsList.ifPresent(meterStats::addAll);
}
}
return new GetMeterStatisticsOutputBuilder().setMeterStats(meterStats).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.GetMeterStatisticsOutput in project openflowplugin by opendaylight.
the class MeterDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final MeterStats meterStat = new MeterStatsBuilder().setMeterId(new MeterId(METER_NO)).setByteInCount(new Counter64(BigInteger.ONE)).setPacketInCount(new Counter64(BigInteger.ONE)).setDuration(new DurationBuilder().setSecond(new Counter32(1L)).setNanosecond(new Counter32(1L)).build()).setFlowCount(new Counter32(0L)).setMeterBandStats(new MeterBandStatsBuilder().build()).build();
final MultipartReply reply = new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyMeterStatsBuilder().setMeterStats(Collections.singletonList(meterStat)).build()).build();
final List<MultipartReply> input = Collections.singletonList(reply);
final GetMeterStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getMeterStats().size() > 0);
final MeterStats stats = output.getMeterStats().get(0);
assertEquals(stats.getMeterId().getValue(), METER_NO);
}
Aggregations