Search in sources :

Example 6 with BundleProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty in project openflowplugin by opendaylight.

the class BundleAddMessageFactory method serialize.

@Override
public void serialize(BundleAddMessageOnf input, ByteBuf outBuffer) {
    outBuffer.writeInt(input.getOnfAddMessageGroupingData().getBundleId().getValue().intValue());
    outBuffer.writeZero(2);
    writeBundleFlags(input.getOnfAddMessageGroupingData().getFlags(), outBuffer);
    int msgStart = outBuffer.writerIndex();
    final BundleInnerMessage message = input.getOnfAddMessageGroupingData().getBundleInnerMessage();
    serializeInnerMessage(message, outBuffer);
    int msgLength = outBuffer.writerIndex() - msgStart;
    List<BundleProperty> bundleProperties = input.getOnfAddMessageGroupingData().getBundleProperty();
    if (bundleProperties != null && !bundleProperties.isEmpty()) {
        outBuffer.writeZero(paddingNeeded(msgLength));
        writeBundleProperties(input.getOnfAddMessageGroupingData().getBundleProperty(), outBuffer);
    }
}
Also used : BundleProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty) BundleInnerMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.add.message.grouping.BundleInnerMessage)

Example 7 with BundleProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty in project openflowplugin by opendaylight.

the class BundleControlConverterTest method createOFPMessage.

private static BundleControlSal createOFPMessage(final boolean withProperty) {
    final SalControlDataBuilder dataBuilder = new SalControlDataBuilder();
    dataBuilder.setBundleId(new BundleId(1L));
    dataBuilder.setType(BundleControlType.ONFBCTOPENREQUEST);
    dataBuilder.setFlags(new BundleFlags(true, false));
    List<BundleProperty> properties = new ArrayList<>();
    if (withProperty) {
        properties.add(BundleTestUtils.createExperimenterProperty(Mockito.mock(BundlePropertyExperimenterData.class)));
    }
    dataBuilder.setBundleProperty(properties);
    return new BundleControlSalBuilder().setSalControlData(dataBuilder.build()).build();
}
Also used : BundleControlSalBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.BundleControlSalBuilder) SalControlDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.bundle.control.sal.SalControlDataBuilder) BundleId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId) ArrayList(java.util.ArrayList) BundleProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty) BundleFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)

Example 8 with BundleProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty in project openflowplugin by opendaylight.

the class BundleControlConverterTest method createOFJMessage.

private static BundleControlOnf createOFJMessage(final boolean withProperty) {
    final BundleControlOnfBuilder builder = new BundleControlOnfBuilder();
    final OnfControlGroupingDataBuilder dataBuilder = new OnfControlGroupingDataBuilder();
    dataBuilder.setBundleId(new BundleId(1L));
    dataBuilder.setType(BundleControlType.ONFBCTOPENREPLY);
    dataBuilder.setFlags(new BundleFlags(false, false));
    List<BundleProperty> properties = new ArrayList<>();
    if (withProperty) {
        properties.add(BundleTestUtils.createExperimenterProperty(Mockito.mock(BundlePropertyExperimenterData.class)));
    }
    dataBuilder.setBundleProperty(properties);
    return new BundleControlOnfBuilder().setOnfControlGroupingData(dataBuilder.build()).build();
}
Also used : BundleId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId) OnfControlGroupingDataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.bundle.control.onf.OnfControlGroupingDataBuilder) ArrayList(java.util.ArrayList) BundleProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty) BundleControlOnfBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnfBuilder) BundleFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)

Example 9 with BundleProperty

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty in project openflowplugin by opendaylight.

the class BundleControlFactoryTest method testDeserializeWithProperties.

@Test
public void testDeserializeWithProperties() {
    ByteBuf buffer = ByteBufUtils.hexStringToByteBuf(// bundle ID
    "00 00 00 01 " + // type
    "00 05 " + // flags
    "00 02 " + // type 1
    "ff ff " + // length 1
    "00 0c " + // experimenter ID 1
    "00 00 00 01 " + // experimenter type 1
    "00 00 00 02 " + // experimenter data 1
    "00 00 00 00 " + // type 2
    "00 00 " + // length 2
    "00 04 " + // data 2
    "00 00 00 00");
    Mockito.when(registry.getDeserializer(Matchers.any(MessageCodeKey.class))).thenReturn(experimenterPropertyDeserializer);
    ((DeserializerRegistryInjector) factory).injectDeserializerRegistry(registry);
    BundleControlOnf builtByFactory = factory.deserialize(buffer);
    Assert.assertEquals(1, builtByFactory.getOnfControlGroupingData().getBundleId().getValue().intValue());
    BundleFlags flags = new BundleFlags(false, true);
    Assert.assertEquals("Wrong atomic flag", flags.isAtomic(), builtByFactory.getOnfControlGroupingData().getFlags().isAtomic());
    Assert.assertEquals("Wrong ordered flag", flags.isOrdered(), builtByFactory.getOnfControlGroupingData().getFlags().isOrdered());
    Assert.assertEquals("Wrong type", BundleControlType.ONFBCTCOMMITREPLY, builtByFactory.getOnfControlGroupingData().getType());
    BundleProperty property = builtByFactory.getOnfControlGroupingData().getBundleProperty().get(0);
    Assert.assertEquals("Wrong bundle property type", BundlePropertyType.ONFETBPTEXPERIMENTER, property.getType());
    BundlePropertyExperimenter experimenterProperty = (BundlePropertyExperimenter) property.getBundlePropertyEntry();
    Assert.assertEquals("Wrong experimenter ID", 1, experimenterProperty.getExperimenter().getValue().intValue());
    Assert.assertEquals("Wrong experimenter type", 2, experimenterProperty.getExpType().longValue());
    Mockito.verify(experimenterPropertyDeserializer, Mockito.times(1)).deserialize(buffer);
}
Also used : DeserializerRegistryInjector(org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector) MessageCodeKey(org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey) BundleControlOnf(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnf) BundleProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty) BundlePropertyExperimenter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenter) ByteBuf(io.netty.buffer.ByteBuf) BundleFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags) Test(org.junit.Test)

Aggregations

BundleProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty)8 BundleFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)5 ArrayList (java.util.ArrayList)4 BundleId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId)4 BundlePropertyType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundlePropertyType)2 BundleControlOnfBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnfBuilder)2 OnfControlGroupingDataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.bundle.control.onf.OnfControlGroupingDataBuilder)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 DeserializerRegistryInjector (org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector)1 ExperimenterIdTypeDeserializerKey (org.opendaylight.openflowjava.protocol.api.keys.ExperimenterIdTypeDeserializerKey)1 MessageCodeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)1 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)1 BundleAddMessageSalBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.BundleAddMessageSalBuilder)1 BundleControlSalBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.BundleControlSalBuilder)1 SalAddMessageDataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.bundle.add.message.sal.SalAddMessageDataBuilder)1 SalControlDataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.bundle.control.sal.SalControlDataBuilder)1 BundleControlType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleControlType)1 BundleInnerMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.add.message.grouping.BundleInnerMessage)1