Search in sources :

Example 1 with SendExperimenterInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SendExperimenterInput in project openflowplugin by opendaylight.

the class SalExperimenterMessageServiceImpl method buildRequest.

@Override
protected OfHeader buildRequest(Xid xid, SendExperimenterInput input) throws ServiceException {
    final TypeVersionKey key = new TypeVersionKey(input.getExperimenterMessageOfChoice().getImplementedInterface(), getVersion());
    final ConverterMessageToOFJava<ExperimenterMessageOfChoice, ExperimenterDataOfChoice> messageConverter = extensionConverterProvider.getMessageConverter(key);
    if (messageConverter == null) {
        throw new ServiceException(new ConverterNotFoundException(key.toString()));
    }
    final ExperimenterInputBuilder experimenterInputBld;
    if (messageConverter instanceof BundleMessageDataInjector) {
        ((BundleMessageDataInjector) messageConverter).setNode(input.getNode());
        ((BundleMessageDataInjector) messageConverter).setXid(xid.getValue());
    }
    try {
        experimenterInputBld = new ExperimenterInputBuilder().setExperimenter(messageConverter.getExperimenterId()).setExpType(messageConverter.getType()).setExperimenterDataOfChoice(messageConverter.convert(input.getExperimenterMessageOfChoice())).setVersion(getVersion()).setXid(xid.getValue());
    } catch (ConversionException e) {
        throw new ServiceException(e);
    }
    return experimenterInputBld.build();
}
Also used : TypeVersionKey(org.opendaylight.openflowplugin.extension.api.TypeVersionKey) ConversionException(org.opendaylight.openflowplugin.extension.api.exception.ConversionException) ExperimenterInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder) ServiceException(org.opendaylight.openflowplugin.impl.services.util.ServiceException) ExperimenterMessageOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice) ConverterNotFoundException(org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException) BundleMessageDataInjector(org.opendaylight.openflowplugin.extension.api.BundleMessageDataInjector) ExperimenterDataOfChoice(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)

Example 2 with SendExperimenterInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SendExperimenterInput in project openflowplugin by opendaylight.

the class SalExperimenterMessageServiceImplTest method testBuildRequest.

@Test
public void testBuildRequest() throws Exception {
    SendExperimenterInput sendExperimenterInput = buildSendExperimenterInput();
    final OfHeader request = salExperimenterMessageService.buildRequest(new Xid(DUMMY_XID_VALUE), sendExperimenterInput);
    assertEquals(DUMMY_XID_VALUE, request.getXid());
    assertTrue(request instanceof ExperimenterInput);
    final ExperimenterInput input = (ExperimenterInput) request;
    assertEquals(43L, input.getExperimenter().getValue().longValue());
    assertEquals(44L, input.getExpType().longValue());
    Mockito.verify(extensionConverter).convert(sendExperimenterInput.getExperimenterMessageOfChoice());
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) OfHeader(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader) SendExperimenterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SendExperimenterInput) ExperimenterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput) SendExperimenterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SendExperimenterInput) Test(org.junit.Test)

Example 3 with SendExperimenterInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SendExperimenterInput in project openflowplugin by opendaylight.

the class SalExperimenterMessageServiceImplTest method testSendExperimenter.

@Test
public void testSendExperimenter() throws Exception {
    SendExperimenterInput sendExperimenterInput = buildSendExperimenterInput();
    salExperimenterMessageService.sendExperimenter(sendExperimenterInput);
    verify(mockedRequestContextStack).createRequestContext();
}
Also used : SendExperimenterInput(org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SendExperimenterInput) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 SendExperimenterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.message.service.rev151020.SendExperimenterInput)2 Xid (org.opendaylight.openflowplugin.api.openflow.device.Xid)1 BundleMessageDataInjector (org.opendaylight.openflowplugin.extension.api.BundleMessageDataInjector)1 TypeVersionKey (org.opendaylight.openflowplugin.extension.api.TypeVersionKey)1 ConversionException (org.opendaylight.openflowplugin.extension.api.exception.ConversionException)1 ConverterNotFoundException (org.opendaylight.openflowplugin.extension.api.exception.ConverterNotFoundException)1 ServiceException (org.opendaylight.openflowplugin.impl.services.util.ServiceException)1 ExperimenterInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInput)1 ExperimenterInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.ExperimenterInputBuilder)1 OfHeader (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader)1 ExperimenterDataOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.experimenter.core.ExperimenterDataOfChoice)1 ExperimenterMessageOfChoice (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.experimenter.core.message.ExperimenterMessageOfChoice)1