2 * Copyright © 2017 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
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
8 package org.opendaylight.netvirt.elanmanager.tests.utils;
10 import static org.opendaylight.yangtools.testutils.mockito.MoreAnswers.realOrException;
12 import com.google.common.util.concurrent.ListenableFuture;
13 import java.util.List;
14 import org.mockito.Mockito;
15 import org.opendaylight.genius.interfacemanager.IfmUtil;
16 import org.opendaylight.genius.interfacemanager.commons.InterfaceManagerCommonUtils;
17 import org.opendaylight.genius.testutils.TestInterfaceManager;
18 import org.opendaylight.serviceutils.tools.mdsal.rpc.FutureRpcResults;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceInput;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutput;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpidFromInterfaceOutputBuilder;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInput;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutputBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.OdlInterfaceRpcService;
27 import org.opendaylight.yangtools.yang.common.RpcResult;
28 import org.slf4j.Logger;
29 import org.slf4j.LoggerFactory;
32 public abstract class ElanEgressActionsHelper implements OdlInterfaceRpcService {
33 private static final Logger LOG = LoggerFactory.getLogger(ElanEgressActionsHelper.class);
34 private InterfaceManagerCommonUtils interfaceManagerCommonUtils;
35 private TestInterfaceManager testInterfaceManager;
37 public static ElanEgressActionsHelper newInstance(InterfaceManagerCommonUtils interfaceManagerCommonUtils,
38 TestInterfaceManager testInterfaceManager) {
39 ElanEgressActionsHelper instance = Mockito.mock(ElanEgressActionsHelper.class, realOrException());
40 instance.interfaceManagerCommonUtils = interfaceManagerCommonUtils;
41 instance.testInterfaceManager = testInterfaceManager;
46 public ListenableFuture<RpcResult<GetEgressActionsForInterfaceOutput>> getEgressActionsForInterface(
47 GetEgressActionsForInterfaceInput input) {
48 return FutureRpcResults.fromBuilder(LOG, input, () -> {
49 List<Action> actionsList = IfmUtil.getEgressActionsForInterface(input.getIntfName(),
50 input.getTunnelKey() != null ? input.getTunnelKey().toJava() : null,
51 input.getActionKey(), interfaceManagerCommonUtils, false);
52 return new GetEgressActionsForInterfaceOutputBuilder().setAction(actionsList);
57 public ListenableFuture<RpcResult<GetDpidFromInterfaceOutput>> getDpidFromInterface(
58 GetDpidFromInterfaceInput input) {
59 return FutureRpcResults.fromBuilder(LOG, input, () -> {
60 return new GetDpidFromInterfaceOutputBuilder().setDpid(
61 testInterfaceManager.getDpnForInterface(input.getIntfName()));