use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.bundle.add.message.onf.OnfAddMessageGroupingDataBuilder in project openflowplugin by opendaylight.
the class BundleAddMessageConverter method convert.
@Override
public BundleAddMessageOnf convert(BundleAddMessageSal experimenterMessageCase) throws ConversionException {
final OnfAddMessageGroupingDataBuilder dataBuilder = new OnfAddMessageGroupingDataBuilder();
dataBuilder.setBundleId(experimenterMessageCase.getSalAddMessageData().getBundleId());
dataBuilder.setFlags(experimenterMessageCase.getSalAddMessageData().getFlags());
dataBuilder.setBundleProperty(experimenterMessageCase.getSalAddMessageData().getBundleProperty());
final BundleInnerMessage innerMessage = experimenterMessageCase.getSalAddMessageData().getBundleInnerMessage();
final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
data.setDatapathId(digDatapathId(node));
if (innerMessage.getImplementedInterface().equals(BundleAddFlowCase.class) || innerMessage.getImplementedInterface().equals(BundleUpdateFlowCase.class) || innerMessage.getImplementedInterface().equals(BundleRemoveFlowCase.class)) {
dataBuilder.setBundleInnerMessage(convertBundleFlowCase(innerMessage, data));
} else if (innerMessage.getImplementedInterface().equals(BundleAddGroupCase.class) || innerMessage.getImplementedInterface().equals(BundleUpdateGroupCase.class) || innerMessage.getImplementedInterface().equals(BundleRemoveGroupCase.class)) {
dataBuilder.setBundleInnerMessage(convertBundleGroupCase(innerMessage, data));
} else if (innerMessage.getImplementedInterface().equals(BundleUpdatePortCase.class)) {
dataBuilder.setBundleInnerMessage(convertBundlePortCase(innerMessage, data));
} else {
throw new ConversionException("Unsupported inner message");
}
return new BundleAddMessageOnfBuilder().setOnfAddMessageGroupingData(dataBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.bundle.add.message.onf.OnfAddMessageGroupingDataBuilder 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);
}
}
Aggregations