Search in sources :

Example 11 with BundleFlags

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags in project openflowplugin by opendaylight.

the class BundleControlFactoryTest method testSerialize.

private void testSerialize(final boolean withProperty) {
    final OnfControlGroupingDataBuilder dataBuilder = new OnfControlGroupingDataBuilder();
    dataBuilder.setBundleId(new BundleId(1L));
    dataBuilder.setType(BundleControlType.ONFBCTOPENREQUEST);
    dataBuilder.setFlags(new BundleFlags(true, true));
    if (withProperty) {
        dataBuilder.setBundleProperty(new ArrayList<>(Collections.singleton(BundleTestUtils.createExperimenterProperty(propertyExperimenterData))));
        Mockito.when(registry.getSerializer(Matchers.any())).thenReturn(propertySerializer);
        ((SerializerRegistryInjector) factory).injectSerializerRegistry(registry);
    }
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(new BundleControlOnfBuilder().setOnfControlGroupingData(dataBuilder.build()).build(), out);
    Assert.assertEquals("Wrong bundle ID", 1L, out.readUnsignedInt());
    Assert.assertEquals("Wrong type", BundleControlType.ONFBCTOPENREQUEST.getIntValue(), out.readUnsignedShort());
    Assert.assertEquals("Wrong flags", 3, out.readUnsignedShort());
    if (withProperty) {
        Assert.assertEquals("Wrong property type", BundlePropertyType.ONFETBPTEXPERIMENTER.getIntValue(), out.readUnsignedShort());
        // length
        out.readUnsignedShort();
        Assert.assertEquals("Wrong experimenter ID", 1, out.readUnsignedInt());
        Assert.assertEquals("Wrong experimenter type", 2, out.readUnsignedInt());
        Mockito.verify(propertySerializer, Mockito.times(1)).serialize(propertyExperimenterData, out);
    } else {
        Assert.assertTrue("Unexpected data", out.readableBytes() == 0);
    }
}
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) SerializerRegistryInjector(org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector) BundleControlOnfBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnfBuilder) ByteBuf(io.netty.buffer.ByteBuf) BundleFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)

Aggregations

BundleFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)11 BundleId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId)8 ByteBuf (io.netty.buffer.ByteBuf)5 BundleProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty)5 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 BundlePropertyExperimenter (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenter)3 BundleControlOnfBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnfBuilder)3 OnfControlGroupingDataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.bundle.control.onf.OnfControlGroupingDataBuilder)3 SerializerRegistryInjector (org.opendaylight.openflowjava.protocol.api.extensibility.SerializerRegistryInjector)2 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)2 BundleControlOnf (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnf)2 DeserializerRegistryInjector (org.opendaylight.openflowjava.protocol.api.extensibility.DeserializerRegistryInjector)1 MessageCodeKey (org.opendaylight.openflowjava.protocol.api.keys.MessageCodeKey)1 BundleAddMessageSal (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.BundleAddMessageSal)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