use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags 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.BundleFlags in project openflowplugin by opendaylight.
the class BundleAddMessageConverterTest method createMessage.
private static BundleAddMessageSal createMessage(final boolean withProperty, final BundleInnerMessage innerMessage) {
final SalAddMessageDataBuilder dataBuilder = new SalAddMessageDataBuilder();
dataBuilder.setBundleId(new BundleId(1L));
dataBuilder.setFlags(new BundleFlags(true, false));
List<BundleProperty> properties = new ArrayList<>();
if (withProperty) {
properties.add(BundleTestUtils.createExperimenterProperty(Mockito.mock(BundlePropertyExperimenterData.class)));
}
dataBuilder.setBundleProperty(properties);
dataBuilder.setBundleInnerMessage(innerMessage);
return new BundleAddMessageSalBuilder().setSalAddMessageData(dataBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags 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());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags in project openflowplugin by opendaylight.
the class BundleAddMessageFactoryTest method testSerialize.
private void testSerialize(final boolean withProperty, final BundleInnerMessage innerMessage) {
final BundleAddMessageOnfBuilder builder = new BundleAddMessageOnfBuilder();
final OnfAddMessageGroupingDataBuilder dataBuilder = new OnfAddMessageGroupingDataBuilder();
dataBuilder.setBundleId(new BundleId(1L));
dataBuilder.setFlags(new BundleFlags(true, false));
dataBuilder.setBundleInnerMessage(innerMessage);
if (withProperty) {
dataBuilder.setBundleProperty(new ArrayList<>(Collections.singleton(BundleTestUtils.createExperimenterProperty(propertyExperimenterData))));
Mockito.when(registry.getSerializer(Matchers.any())).thenReturn(caseSerializer).thenReturn(propertySerializer);
} else {
Mockito.when(registry.getSerializer(Matchers.any())).thenReturn(caseSerializer);
}
builder.setOnfAddMessageGroupingData(dataBuilder.build());
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
((SerializerRegistryInjector) factory).injectSerializerRegistry(registry);
factory.serialize(builder.build(), out);
Assert.assertEquals("Wrong bundle ID", 1L, out.readUnsignedInt());
long padding = out.readUnsignedShort();
Assert.assertEquals("Wrong flags", 1, out.readUnsignedShort());
Mockito.verify(caseSerializer).serialize(Mockito.any(), Mockito.any());
if (withProperty) {
Mockito.verify(propertySerializer).serialize(propertyExperimenterData, out);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleFlags 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());
}
Aggregations