Search in sources :

Example 1 with BundlePropertyExperimenter

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenter in project openflowplugin by opendaylight.

the class BundleAddMessageConverterTest method testConvert.

private void testConvert(final BundleInnerMessage message, Class clazz, final boolean withProperty) throws Exception {
    final BundleAddMessageSal original = createMessage(withProperty, message);
    final BundleAddMessageOnf converted = converter.convert(original);
    Assert.assertEquals("Wrong BundleId", new BundleId(original.getSalAddMessageData().getBundleId().getValue()), converted.getOnfAddMessageGroupingData().getBundleId());
    Assert.assertEquals("Wrong flags", new BundleFlags(original.getSalAddMessageData().getFlags().isAtomic(), original.getSalAddMessageData().getFlags().isOrdered()), converted.getOnfAddMessageGroupingData().getFlags());
    Assert.assertEquals("Wrong inner message conversion", clazz, converted.getOnfAddMessageGroupingData().getBundleInnerMessage().getImplementedInterface());
    if (withProperty) {
        final BundlePropertyExperimenter originalProperty = (BundlePropertyExperimenter) original.getSalAddMessageData().getBundleProperty().get(0).getBundlePropertyEntry();
        final BundlePropertyExperimenter convertedProperty = (BundlePropertyExperimenter) converted.getOnfAddMessageGroupingData().getBundleProperty().get(0).getBundlePropertyEntry();
        Assert.assertEquals("Wrong property ExperimenterId", new ExperimenterId(originalProperty.getExperimenter()), convertedProperty.getExperimenter());
        Assert.assertEquals("Wrong property experimenter type", originalProperty.getExpType(), convertedProperty.getExpType());
        Assert.assertEquals("Wrong property data", originalProperty.getBundlePropertyExperimenterData(), convertedProperty.getBundlePropertyExperimenterData());
    } else {
        Assert.assertTrue("Properties not empty", converted.getOnfAddMessageGroupingData().getBundleProperty().isEmpty());
    }
}
Also used : BundleAddMessageOnf(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleAddMessageOnf) BundleId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId) BundlePropertyExperimenter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenter) BundleAddMessageSal(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.bundle.service.rev170124.send.experimenter.input.experimenter.message.of.choice.BundleAddMessageSal) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) BundleFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)

Example 2 with BundlePropertyExperimenter

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenter in project openflowplugin by opendaylight.

the class AbstractBundleMessageFactory method writeBundleProperties.

void writeBundleProperties(final List<BundleProperty> properties, final ByteBuf outBuffer) {
    for (BundleProperty property : properties) {
        BundlePropertyType type = property.getType();
        if (type != null && type.equals(BundlePropertyType.ONFETBPTEXPERIMENTER)) {
            final int startIndex = outBuffer.writerIndex();
            outBuffer.writeShort(type.getIntValue());
            int lengthIndex = outBuffer.writerIndex();
            outBuffer.writeShort(EncodeConstants.EMPTY_LENGTH);
            writeBundleExperimenterProperty((BundlePropertyExperimenter) property.getBundlePropertyEntry(), outBuffer);
            outBuffer.setShort(lengthIndex, outBuffer.writerIndex() - startIndex);
        } else {
            LOG.warn("Trying to serialize unknown bundle property (type: {}), skipping", type != null ? type.getIntValue() : 0);
        }
    }
}
Also used : BundleProperty(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty) BundlePropertyType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundlePropertyType)

Example 3 with BundlePropertyExperimenter

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenter in project openflowplugin by opendaylight.

the class BundleControlConverterTest method testConvert.

private static void testConvert(final BundleControlSal ofpMessage, final BundleControlOnf ofjMessage, final boolean withProperty) {
    Assert.assertEquals("Wrong BundleId", new BundleId(ofpMessage.getSalControlData().getBundleId().getValue()), ofjMessage.getOnfControlGroupingData().getBundleId());
    Assert.assertEquals("Wrong type", BundleControlType.forValue(ofpMessage.getSalControlData().getType().getIntValue()), ofjMessage.getOnfControlGroupingData().getType());
    Assert.assertEquals("Wrong flags", new BundleFlags(ofpMessage.getSalControlData().getFlags().isAtomic(), ofpMessage.getSalControlData().getFlags().isOrdered()), ofjMessage.getOnfControlGroupingData().getFlags());
    if (withProperty) {
        final BundlePropertyExperimenter originalProperty = (BundlePropertyExperimenter) ofpMessage.getSalControlData().getBundleProperty().get(0).getBundlePropertyEntry();
        final BundlePropertyExperimenter convertedProperty = (BundlePropertyExperimenter) ofjMessage.getOnfControlGroupingData().getBundleProperty().get(0).getBundlePropertyEntry();
        Assert.assertEquals("Wrong property ExperimenterId", new ExperimenterId(originalProperty.getExperimenter()), convertedProperty.getExperimenter());
        Assert.assertEquals("Wrong property experimenter type", originalProperty.getExpType(), convertedProperty.getExpType());
        Assert.assertEquals("Wrong property data", originalProperty.getBundlePropertyExperimenterData(), convertedProperty.getBundlePropertyExperimenterData());
    } else {
        Assert.assertTrue("Properties not empty", ofjMessage.getOnfControlGroupingData().getBundleProperty().isEmpty());
    }
}
Also used : BundleId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId) BundlePropertyExperimenter(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenter) ExperimenterId(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId) BundleFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)

Example 4 with BundlePropertyExperimenter

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenter 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

BundleFlags (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags)3 BundlePropertyExperimenter (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.property.grouping.bundle.property.entry.BundlePropertyExperimenter)3 ExperimenterId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ExperimenterId)2 BundleId (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId)2 BundleProperty (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.common.grouping.BundleProperty)2 ByteBuf (io.netty.buffer.ByteBuf)1 Test (org.junit.Test)1 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 BundlePropertyType (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundlePropertyType)1 BundleAddMessageOnf (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleAddMessageOnf)1 BundleControlOnf (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnf)1