use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnf in project openflowplugin by opendaylight.
the class BundleControlFactory method deserialize.
@Override
public BundleControlOnf deserialize(ByteBuf message) {
BundleId bundleId = new BundleId(message.readUnsignedInt());
BundleControlType type = BundleControlType.forValue(message.readUnsignedShort());
BundleFlags flags = createBundleFlags(message.readUnsignedShort());
OnfControlGroupingDataBuilder builder = new OnfControlGroupingDataBuilder();
List<BundleProperty> properties = createBundleProperties(message);
builder.setBundleId(bundleId).setType(type).setFlags(flags).setBundleProperty(properties);
return new BundleControlOnfBuilder().setOnfControlGroupingData(builder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnf in project openflowplugin by opendaylight.
the class BundleControlConverterTest method testConvertDown.
private void testConvertDown(final boolean withProperty) {
final BundleControlSal original = createOFPMessage(withProperty);
final BundleControlOnf converted = converter.convert(original);
testConvert(original, converted, withProperty);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnf in project openflowplugin by opendaylight.
the class BundleControlFactoryTest method testDeserializeWithoutProperties.
@Test
public void testDeserializeWithoutProperties() {
ByteBuf buffer = ByteBufUtils.hexStringToByteBuf(// bundle ID
"00 00 00 01 " + // type
"00 01 " + // flags
"00 03");
BundleControlOnf builtByFactory = factory.deserialize(buffer);
Assert.assertEquals(1, builtByFactory.getOnfControlGroupingData().getBundleId().getValue().intValue());
BundleFlags flags = new BundleFlags(true, 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.ONFBCTOPENREPLY, builtByFactory.getOnfControlGroupingData().getType());
Assert.assertTrue("Properties not empty", builtByFactory.getOnfControlGroupingData().getBundleProperty().isEmpty());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnf 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleControlOnf 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());
}
}
Aggregations