use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId 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.BundleId 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());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.BundleId 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);
}
}
Aggregations