use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder in project openflowplugin by opendaylight.
the class OF10StatsRequestInputFactory method setExperimenter.
private MultipartRequestExperimenterCase setExperimenter(ByteBuf input) {
MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
MultipartRequestExperimenterBuilder experimenterBuilder = new MultipartRequestExperimenterBuilder();
caseBuilder.setMultipartRequestExperimenter(experimenterBuilder.build());
return caseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder in project openflowplugin by opendaylight.
the class MultiLayerExperimenterMultipartService method buildRequest.
@Override
@SuppressWarnings("unchecked")
protected OfHeader buildRequest(Xid xid, SendExperimenterMpRequestInput input) throws ServiceException {
final TypeVersionKey key = new TypeVersionKey<>(input.getExperimenterMessageOfChoice().getImplementedInterface(), getVersion());
final ConverterMessageToOFJava<ExperimenterMessageOfChoice, ExperimenterDataOfChoice> messageConverter = getExtensionConverterProvider().getMessageConverter(key);
if (Objects.isNull(messageConverter)) {
throw new ServiceException(new ConverterNotFoundException(key.toString()));
}
try {
return RequestInputUtils.createMultipartHeader(MultipartType.OFPMPEXPERIMENTER, xid.getValue(), getVersion()).setMultipartRequestBody(new MultipartRequestExperimenterCaseBuilder().setMultipartRequestExperimenter(new MultipartRequestExperimenterBuilder().setExperimenter(messageConverter.getExperimenterId()).setExpType(messageConverter.getType()).setExperimenterDataOfChoice(messageConverter.convert(input.getExperimenterMessageOfChoice())).build()).build()).build();
} catch (final ConversionException e) {
throw new ServiceException(e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder in project openflowplugin by opendaylight.
the class OF10StatsRequestExperimenterTest method testExperimenter.
/**
* Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization.
*/
@Test
public void testExperimenter() throws Exception {
Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(serializer);
OF10StatsRequestInputFactory multipartFactory = new OF10StatsRequestInputFactory();
multipartFactory.injectSerializerRegistry(mockRegistry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
builder.setType(MultipartType.OFPMPEXPERIMENTER);
builder.setFlags(new MultipartRequestFlags(false));
final MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
expBuilder.setExpType(21L);
expBuilder.setExperimenterDataOfChoice(vendorData);
caseBuilder.setMultipartRequestExperimenter(expBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV10(out, (byte) 16, 16);
Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder in project openflowplugin by opendaylight.
the class MultipartRequestInputMessageFactory method setExperimenter.
private MultipartRequestExperimenterCase setExperimenter(ByteBuf input) {
MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
MultipartRequestExperimenterBuilder experimenterBuilder = new MultipartRequestExperimenterBuilder();
caseBuilder.setMultipartRequestExperimenter(experimenterBuilder.build());
return caseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.request.multipart.request.body.multipart.request.experimenter._case.MultipartRequestExperimenterBuilder in project openflowplugin by opendaylight.
the class MultipartRequestExperimenterTest method testExperimenter.
/**
* Testing OF10StatsRequestInputFactory (Experimenter) for correct serialization.
*/
@Test
public void testExperimenter() throws Exception {
Mockito.when(mockRegistry.getSerializer(Matchers.<ExperimenterIdTypeSerializerKey<ExperimenterDataOfChoice>>any())).thenReturn(serializer);
MultipartRequestInputFactory multipartFactory = new MultipartRequestInputFactory();
multipartFactory.injectSerializerRegistry(mockRegistry);
MultipartRequestInputBuilder builder = new MultipartRequestInputBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setType(MultipartType.OFPMPEXPERIMENTER);
builder.setFlags(new MultipartRequestFlags(false));
final MultipartRequestExperimenterCaseBuilder caseBuilder = new MultipartRequestExperimenterCaseBuilder();
MultipartRequestExperimenterBuilder expBuilder = new MultipartRequestExperimenterBuilder();
expBuilder.setExperimenter(new ExperimenterId(42L));
expBuilder.setExpType(21L);
expBuilder.setExperimenterDataOfChoice(vendorData);
caseBuilder.setMultipartRequestExperimenter(expBuilder.build());
builder.setMultipartRequestBody(caseBuilder.build());
MultipartRequestInput message = builder.build();
ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
multipartFactory.serialize(message, out);
BufferHelper.checkHeaderV13(out, (byte) 18, 24);
Assert.assertEquals("Wrong type", 65535, out.readUnsignedShort());
Assert.assertEquals("Wrong flags", 0, out.readUnsignedShort());
Mockito.verify(serializer, Mockito.times(1)).serialize(vendorData, out);
}
Aggregations