Search in sources :

Example 6 with MultipartReplyMeterFeaturesCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase in project openflowplugin by opendaylight.

the class MultipartReplyMeterFeaturesTest method testMultipartReplyMeterFeatures2.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyMeterFeatures2() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 0B 00 01 00 00 00 00 " + // maxMeter
    "00 00 00 09 " + // bandTypes
    "00 00 00 00 " + // capabilities
    "00 00 00 00 " + // maxBands, maxColor, padding
    "03 04 00 00");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 11, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", true, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyMeterFeaturesCase messageCase = (MultipartReplyMeterFeaturesCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyMeterFeatures message = messageCase.getMultipartReplyMeterFeatures();
    Assert.assertEquals("Wrong maxMeter", 9, message.getMaxMeter().intValue());
    Assert.assertEquals("Wrong bandTypes", new MeterBandTypeBitmap(false, false), message.getBandTypes());
    Assert.assertEquals("Wrong capabilities", new MeterFlags(false, false, false, false), message.getCapabilities());
    Assert.assertEquals("Wrong maxBands", 3, message.getMaxBands().intValue());
    Assert.assertEquals("Wrong maxColor", 4, message.getMaxColor().intValue());
}
Also used : MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures) MeterFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags) MeterBandTypeBitmap(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap) ByteBuf(io.netty.buffer.ByteBuf) MultipartReplyMeterFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase) Test(org.junit.Test)

Example 7 with MultipartReplyMeterFeaturesCase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase in project openflowplugin by opendaylight.

the class MeterFeaturesService method transformToNotification.

@Override
public MeterFeaturesUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
    final int mpSize = result.size();
    Preconditions.checkArgument(mpSize == 1, "unexpected (!=1) mp-reply size received: {}", mpSize);
    MeterFeaturesUpdatedBuilder notification = new MeterFeaturesUpdatedBuilder();
    notification.setId(getDeviceInfo().getNodeId());
    notification.setMoreReplies(Boolean.FALSE);
    notification.setTransactionId(emulatedTxId);
    MultipartReplyMeterFeaturesCase caseBody = (MultipartReplyMeterFeaturesCase) result.get(0).getMultipartReplyBody();
    MultipartReplyMeterFeatures replyBody = caseBody.getMultipartReplyMeterFeatures();
    notification.setMaxBands(replyBody.getMaxBands());
    notification.setMaxColor(replyBody.getMaxColor());
    notification.setMaxMeter(new Counter32(replyBody.getMaxMeter()));
    notification.setMeterCapabilitiesSupported(extractMeterCapabilities(replyBody.getCapabilities()));
    notification.setMeterBandSupported(extractSupportedMeterBand(replyBody, replyBody.getBandTypes()));
    return notification.build();
}
Also used : Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MultipartReplyMeterFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures) MeterFeaturesUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdatedBuilder) MultipartReplyMeterFeaturesCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase)

Aggregations

MultipartReplyMeterFeaturesCase (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCase)6 MultipartReplyMeterFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures)6 ByteBuf (io.netty.buffer.ByteBuf)3 Test (org.junit.Test)3 MeterBandTypeBitmap (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterBandTypeBitmap)3 MeterFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MeterFlags)3 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)3 Counter32 (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32)2 MultipartReplyMeterFeaturesCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesCaseBuilder)2 MultipartReplyMeterFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeaturesBuilder)2 ArrayList (java.util.ArrayList)1 MeterFeaturesUpdatedBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.MeterFeaturesUpdatedBuilder)1 MultipartReplyMeterFeaturesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.statistics.rev131111.multipart.reply.multipart.reply.body.MultipartReplyMeterFeaturesBuilder)1 MeterBand (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterBand)1 MeterCapability (org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterCapability)1 MultipartRequestFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags)1 MultipartReplyMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder)1