use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder in project openflowplugin by opendaylight.
the class GroupStatsResponseConvertorTest method testGroupStatsWithBuckets.
/**
* Test GroupStats with buckets conversion.
*/
@Test
public void testGroupStatsWithBuckets() {
GroupStatsBuilder statsBuilder = new GroupStatsBuilder();
statsBuilder.setByteCount(new BigInteger("12345"));
statsBuilder.setDurationNsec(1000000L);
statsBuilder.setDurationSec(5000L);
statsBuilder.setGroupId(new GroupId(42L));
statsBuilder.setPacketCount(new BigInteger("54321"));
statsBuilder.setRefCount(24L);
List<BucketStats> bucketStats = new ArrayList<>();
BucketStatsBuilder bucketStatsBuilder = new BucketStatsBuilder();
bucketStatsBuilder.setByteCount(new BigInteger("987"));
bucketStatsBuilder.setPacketCount(new BigInteger("654"));
bucketStats.add(bucketStatsBuilder.build());
bucketStatsBuilder = new BucketStatsBuilder();
bucketStatsBuilder.setByteCount(new BigInteger("123"));
bucketStatsBuilder.setPacketCount(new BigInteger("456"));
bucketStats.add(bucketStatsBuilder.build());
statsBuilder.setBucketStats(bucketStats);
List<GroupStats> groupStats = new ArrayList<>();
groupStats.add(statsBuilder.build());
Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats>> salGroupStatsOptional = convertorManager.convert(groupStats, new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
Assert.assertTrue("Group stats response convertor not found", salGroupStatsOptional.isPresent());
List<org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats> salGroupStats = salGroupStatsOptional.get();
Assert.assertEquals("Wrong group stats size", 1, salGroupStats.size());
org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stat = salGroupStats.get(0);
Assert.assertEquals("Wrong group-id", 42, stat.getGroupId().getValue().intValue());
Assert.assertEquals("Wrong ref-count", 24, stat.getRefCount().getValue().intValue());
Assert.assertEquals("Wrong packet count", 54321, stat.getPacketCount().getValue().intValue());
Assert.assertEquals("Wrong byte count", 12345, stat.getByteCount().getValue().intValue());
Assert.assertEquals("Wrong duration sec", 5000, stat.getDuration().getSecond().getValue().intValue());
Assert.assertEquals("Wrong duration n sec", 1000000, stat.getDuration().getNanosecond().getValue().intValue());
Assert.assertEquals("Wrong bucket stats", 2, stat.getBuckets().getBucketCounter().size());
List<BucketCounter> list = stat.getBuckets().getBucketCounter();
Assert.assertEquals("Wrong bucket-id", 0, list.get(0).getBucketId().getValue().intValue());
Assert.assertEquals("Wrong bucket packet count", 654, list.get(0).getPacketCount().getValue().intValue());
Assert.assertEquals("Wrong bucket byte count", 987, list.get(0).getByteCount().getValue().intValue());
Assert.assertEquals("Wrong bucket-id", 1, list.get(1).getBucketId().getValue().intValue());
Assert.assertEquals("Wrong bucket packet count", 456, list.get(1).getPacketCount().getValue().intValue());
Assert.assertEquals("Wrong bucket byte count", 123, list.get(1).getByteCount().getValue().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method createGroupStats.
private static List<GroupStats> createGroupStats() {
GroupStatsBuilder builder = new GroupStatsBuilder();
builder.setGroupId(new GroupId(1L));
builder.setRefCount(1L);
builder.setPacketCount(BigInteger.valueOf(1L));
builder.setByteCount(BigInteger.valueOf(1L));
builder.setDurationSec(1L);
builder.setDurationNsec(1L);
builder.setBucketStats(createBucketStats());
List<GroupStats> list = new ArrayList<>();
list.add(builder.build());
return list;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder in project openflowplugin by opendaylight.
the class GroupDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final MultipartReply reply = mock(MultipartReply.class);
final MultipartReplyGroupCase groupCase = mock(MultipartReplyGroupCase.class);
final MultipartReplyGroup group = mock(MultipartReplyGroup.class);
final GroupStats groupStat = new GroupStatsBuilder().setGroupId(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId(GROUP_NO)).setByteCount(BigInteger.ONE).setPacketCount(BigInteger.ONE).setBucketStats(Collections.emptyList()).setDurationSec(1L).setDurationNsec(1L).setRefCount(0L).build();
final List<GroupStats> groupStats = Collections.singletonList(groupStat);
final List<MultipartReply> input = Collections.singletonList(reply);
when(group.getGroupStats()).thenReturn(groupStats);
when(groupCase.getMultipartReplyGroup()).thenReturn(group);
when(reply.getMultipartReplyBody()).thenReturn(groupCase);
final GetGroupStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getGroupStats().size() > 0);
final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats = output.getGroupStats().get(0);
assertEquals(stats.getGroupId().getValue(), GROUP_NO);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder in project openflowplugin by opendaylight.
the class MultipartReplyTranslatorTest method prepareMultipartReplyGroup.
private MultipartReplyBody prepareMultipartReplyGroup() {
GroupStatsBuilder groupStatsBuilder = new GroupStatsBuilder();
groupStatsBuilder.setByteCount(DUMMY_BYTE_COUNT);
groupStatsBuilder.setBucketStats(Collections.<BucketStats>emptyList());
groupStatsBuilder.setDurationSec(DUMMY_DURATION_SEC);
groupStatsBuilder.setDurationNsec(DUMMY_DURATION_NSEC);
groupStatsBuilder.setGroupId(DUMMY_GROUP_ID);
groupStatsBuilder.setPacketCount(DUMMY_PACKET_COUNT);
groupStatsBuilder.setRefCount(DUMMY_REF_COUNT);
MultipartReplyGroupBuilder multipartReplyGroupBuilder = new MultipartReplyGroupBuilder();
multipartReplyGroupBuilder.setGroupStats(Lists.newArrayList(groupStatsBuilder.build()));
MultipartReplyGroupCaseBuilder multipartReplyGroupCaseBuilder = new MultipartReplyGroupCaseBuilder();
multipartReplyGroupCaseBuilder.setMultipartReplyGroup(multipartReplyGroupBuilder.build());
return multipartReplyGroupCaseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStatsBuilder in project openflowplugin by opendaylight.
the class GroupDirectStatisticsServiceTest method testBuildReply.
@Override
public void testBuildReply() throws Exception {
final GroupStats groupStat = new GroupStatsBuilder().setGroupId(new GroupId(GROUP_NO)).build();
final MultipartReply reply = new MultipartReplyBuilder().setMultipartReplyBody(new MultipartReplyGroupStatsBuilder().setGroupStats(Collections.singletonList(groupStat)).build()).build();
final List<MultipartReply> input = Collections.singletonList(reply);
final GetGroupStatisticsOutput output = service.buildReply(input, true);
assertTrue(output.getGroupStats().size() > 0);
final org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.statistics.reply.GroupStats stats = output.getGroupStats().get(0);
assertEquals(stats.getGroupId().getValue(), GROUP_NO);
}
Aggregations