Switch to MD-SAL APIs
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / statistics / services / AbstractSingleStatsServiceTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.openflowplugin.impl.statistics.services;
9
10 import org.mockito.Mock;
11 import org.mockito.Mockito;
12 import org.mockito.stubbing.Answer;
13 import org.opendaylight.mdsal.binding.api.NotificationPublishService;
14 import org.opendaylight.openflowplugin.api.openflow.device.RequestContext;
15 import org.opendaylight.openflowplugin.impl.rpc.AbstractRequestContext;
16 import org.opendaylight.yangtools.yang.common.RpcResult;
17
18 public abstract class AbstractSingleStatsServiceTest extends AbstractStatsServiceTest {
19
20     @Mock
21     protected NotificationPublishService notificationPublishService;
22
23     protected RequestContext<Object> rqContext;
24
25     protected RpcResult<Object> rpcResult;
26
27     @Override
28     public void init() throws Exception {
29         super.init();
30         rqContext = new AbstractRequestContext<Object>(42L) {
31             @Override
32             public void close() {
33                 //NOOP
34             }
35         };
36         final Answer closeRequestFutureAnswer = invocation -> {
37             rqContext.setResult(rpcResult);
38             rqContext.close();
39             return null;
40         };
41
42         Mockito.when(rqContextStack.<Object>createRequestContext()).thenReturn(rqContext);
43         Mockito.doAnswer(closeRequestFutureAnswer).when(multiMsgCollector).endCollecting(null);
44     }
45 }