Search in sources :

Example 1 with AbstractRequestContext

use of org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext in project openflowplugin by opendaylight.

the class AbstractCompatibleStatServiceTest method setUp.

@Override
public void setUp() {
    rqContext = new AbstractRequestContext<Object>(42L) {

        @Override
        public void close() {
        // NOOP
        }
    };
    final Answer closeRequestFutureAnswer = invocation -> {
        rqContext.setResult(rpcResult);
        rqContext.close();
        return null;
    };
    Mockito.when(featuresOutput.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
    Mockito.when(deviceContext.getDeviceState()).thenReturn(deviceState);
    Mockito.when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
    Mockito.when(deviceInfo.getNodeId()).thenReturn(NODE_ID);
    Mockito.when(deviceInfo.getVersion()).thenReturn(OFConstants.OFP_VERSION_1_3);
    Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(null);
    Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
    Mockito.doAnswer(answerVoidToCallback).when(outboundQueueProvider).commitEntry(Matchers.eq(42L), requestInput.capture(), Matchers.any(FutureCallback.class));
    Mockito.when(translatorLibrary.lookupTranslator(Matchers.any(TranslatorKey.class))).thenReturn(translator);
    service = AggregateFlowsInTableService.createWithOook(rqContextStack, deviceContext, new AtomicLong(20L));
}
Also used : MultipartReplyAggregateCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyAggregateCaseBuilder) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInput) Matchers(org.mockito.Matchers) Mock(org.mockito.Mock) NotificationPublishService(org.opendaylight.controller.md.sal.binding.api.NotificationPublishService) DeviceState(org.opendaylight.openflowplugin.api.openflow.device.DeviceState) Captor(org.mockito.Captor) GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsOutput) Answer(org.mockito.stubbing.Answer) ArgumentCaptor(org.mockito.ArgumentCaptor) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) MultipartReplyAggregateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.aggregate._case.MultipartReplyAggregateBuilder) MessageTranslator(org.opendaylight.openflowplugin.api.openflow.device.MessageTranslator) BigInteger(java.math.BigInteger) AggregateFlowsInTableService(org.opendaylight.openflowplugin.impl.statistics.services.AggregateFlowsInTableService) Counter32(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter32) MultipartRequestInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartRequestInput) AbstractRequestContext(org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext) GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetAggregateFlowStatisticsFromFlowTableForAllFlowsInputBuilder) Test(org.junit.Test) MultipartReplyMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessageBuilder) FutureCallback(com.google.common.util.concurrent.FutureCallback) OFConstants(org.opendaylight.openflowplugin.api.OFConstants) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) AtomicLong(java.util.concurrent.atomic.AtomicLong) Mockito(org.mockito.Mockito) EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) RpcResultBuilder(org.opendaylight.yangtools.yang.common.RpcResultBuilder) MultipartType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType) TranslatorKey(org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey) AggregateFlowStatisticsUpdate(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.AggregateFlowStatisticsUpdate) TableId(org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TableId) Assert(org.junit.Assert) Collections(java.util.Collections) AggregatedFlowStatistics(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatistics) AbstractStatsServiceTest(org.opendaylight.openflowplugin.impl.statistics.services.AbstractStatsServiceTest) Counter64(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Counter64) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) AggregatedFlowStatisticsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.get.aggregate.flow.statistics.from.flow.table._for.given.match.output.AggregatedFlowStatisticsBuilder) Answer(org.mockito.stubbing.Answer) AtomicLong(java.util.concurrent.atomic.AtomicLong) EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) TranslatorKey(org.opendaylight.openflowplugin.api.openflow.md.core.TranslatorKey) FutureCallback(com.google.common.util.concurrent.FutureCallback)

Example 2 with AbstractRequestContext

use of org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext in project openflowplugin by opendaylight.

the class AbstractRequestCallbackTest method initialization.

@Before
public void initialization() {
    dummyRequestContext = new AbstractRequestContext(DUMMY_XID) {

        @Override
        public void close() {
        }
    };
    abstractRequestCallback = new AbstractRequestCallback(dummyRequestContext, DUMMY_REQUEST_TYPE, new MessageIntelligenceAgencyImpl(), DUMMY_EVENT_IDENTIFIER) {

        @Override
        public void onSuccess(Object object) {
        }
    };
}
Also used : MessageIntelligenceAgencyImpl(org.opendaylight.openflowplugin.impl.statistics.ofpspecific.MessageIntelligenceAgencyImpl) AbstractRequestContext(org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext) Before(org.junit.Before)

Example 3 with AbstractRequestContext

use of org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext in project openflowplugin by opendaylight.

the class AbstractSingleStatsServiceTest method init.

@Override
public void init() throws Exception {
    super.init();
    rqContext = new AbstractRequestContext<Object>(42L) {

        @Override
        public void close() {
        // NOOP
        }
    };
    final Answer closeRequestFutureAnswer = invocation -> {
        rqContext.setResult(rpcResult);
        rqContext.close();
        return null;
    };
    Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
    Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(null);
    Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(Matchers.any(EventIdentifier.class));
}
Also used : Mockito(org.mockito.Mockito) Answer(org.mockito.stubbing.Answer) EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Matchers(org.mockito.Matchers) Mock(org.mockito.Mock) AbstractRequestContext(org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext) RequestContext(org.opendaylight.openflowplugin.api.openflow.device.RequestContext) NotificationPublishService(org.opendaylight.controller.md.sal.binding.api.NotificationPublishService) Answer(org.mockito.stubbing.Answer) EventIdentifier(org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier)

Example 4 with AbstractRequestContext

use of org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext in project openflowplugin by opendaylight.

the class OpendaylightFlowStatisticsServiceImpl1Test method setUp.

public void setUp() {
    final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
    flowStatisticsService = OpendaylightFlowStatisticsServiceImpl.createWithOook(rqContextStack, deviceContext, convertorManager);
    AbstractRequestContext<Object> rqContext = new AbstractRequestContext<Object>(42L) {

        @Override
        public void close() {
        // NOOP
        }
    };
    Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
}
Also used : AbstractRequestContext(org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext) ConvertorManager(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorManager)

Aggregations

AbstractRequestContext (org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext)4 Matchers (org.mockito.Matchers)2 Mock (org.mockito.Mock)2 Mockito (org.mockito.Mockito)2 Answer (org.mockito.stubbing.Answer)2 NotificationPublishService (org.opendaylight.controller.md.sal.binding.api.NotificationPublishService)2 EventIdentifier (org.opendaylight.openflowplugin.api.openflow.statistics.ofpspecific.EventIdentifier)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 FutureCallback (com.google.common.util.concurrent.FutureCallback)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 BigInteger (java.math.BigInteger)1 Collections (java.util.Collections)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Assert (org.junit.Assert)1 Before (org.junit.Before)1 Test (org.junit.Test)1 ArgumentCaptor (org.mockito.ArgumentCaptor)1 Captor (org.mockito.Captor)1 OFConstants (org.opendaylight.openflowplugin.api.OFConstants)1 DeviceInfo (org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo)1