use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.
the class DSInputFactory method createGroupWithPreconditions.
public static Group createGroupWithPreconditions(final long groupIdValue, final long... requiredId) {
final List<Action> actionBag = new ArrayList<>();
for (long groupIdPrecondition : requiredId) {
final GroupAction groupAction = new GroupActionBuilder().setGroupId(groupIdPrecondition).build();
final GroupActionCase groupActionCase = new GroupActionCaseBuilder().setGroupAction(groupAction).build();
final Action action = new ActionBuilder().setAction(groupActionCase).build();
actionBag.add(action);
}
final Bucket bucket = new BucketBuilder().setAction(actionBag).build();
final Buckets buckets = new BucketsBuilder().setBucket(Collections.singletonList(bucket)).build();
return new GroupBuilder().setGroupId(new GroupId(groupIdValue)).setBuckets(buckets).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId 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.GroupId in project openflowplugin by opendaylight.
the class GroupModInputMessageFactoryTest method testGroupModInputMessage.
/**
* Testing of {@link GroupModInputMessageFactory} for correct translation from POJO.
*/
@Test
public void testGroupModInputMessage() throws Exception {
GroupModInputBuilder builder = new GroupModInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setCommand(GroupModCommand.forValue(2));
builder.setType(GroupType.forValue(3));
builder.setGroupId(new GroupId(256L));
List<BucketsList> exp = createBucketsList();
builder.setBucketsList(exp);
final GroupModInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
// simulate parent message
out.writeInt(1);
out.writeZero(2);
out.writeShort(3);
groupModFactory.serialize(message, out);
// read parent message
out.readInt();
out.skipBytes(2);
out.readShort();
BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, 32);
Assert.assertEquals("Wrong command", message.getCommand().getIntValue(), out.readUnsignedShort());
Assert.assertEquals("Wrong type", message.getType().getIntValue(), out.readUnsignedByte());
out.skipBytes(PADDING_IN_GROUP_MOD_MESSAGE);
Assert.assertEquals("Wrong groupId", message.getGroupId().getValue().intValue(), out.readUnsignedInt());
List<BucketsList> rec = createBucketsListFromBufer(out);
Assert.assertArrayEquals("Wrong bucketList", exp.toArray(), rec.toArray());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId in project openflowplugin by opendaylight.
the class OpendaylightGroupStatisticsServiceImplTest method testGetGroupStatistics.
@Test
public void testGetGroupStatistics() throws Exception {
GetGroupStatisticsInputBuilder input = new GetGroupStatisticsInputBuilder().setNode(createNodeRef("unitProt:123")).setGroupId(new GroupId(21L));
rpcResult = buildGroupStatsResponse();
final Future<RpcResult<GetGroupStatisticsOutput>> resultFuture = groupStatisticsService.getGroupStatistics(input.build());
Assert.assertTrue(resultFuture.isDone());
final RpcResult<GetGroupStatisticsOutput> rpcResult = resultFuture.get();
Assert.assertTrue(rpcResult.isSuccessful());
Assert.assertEquals(MultipartType.OFPMPGROUP, requestInput.getValue().getType());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId 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);
}
Aggregations