2 * Copyright © 2016, 2017 Red Hat, Inc. and others.
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.genius.mdsalutil.actions;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
13 import ch.vorburger.xtendbeans.XtendBeanGenerator;
14 import org.junit.Test;
15 import org.opendaylight.genius.mdsalutil.ActionInfo;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfIpDstCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegMoveNodesNodeTableFlowApplyActionsCase;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.move.grouping.NxRegMove;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.src.choice.grouping.src.choice.SrcOfIpSrcCase;
21 import org.opendaylight.yangtools.yang.common.Empty;
24 * Test class for {@link ActionMoveSourceDestinationIp}.
26 public class ActionMoveSourceDestinationIpTest {
27 private final XtendBeanGenerator generator = new XtendBeanGenerator();
30 public void actionInfoTest() {
31 verifyAction(new ActionMoveSourceDestinationIp().buildAction());
34 private static void verifyAction(Action action) {
35 assertTrue(action.getAction() instanceof NxActionRegMoveNodesNodeTableFlowApplyActionsCase);
36 NxActionRegMoveNodesNodeTableFlowApplyActionsCase actionCase =
37 (NxActionRegMoveNodesNodeTableFlowApplyActionsCase) action.getAction();
38 NxRegMove nxRegMove = actionCase.getNxRegMove();
39 assertTrue(nxRegMove.getSrc().getSrcChoice() instanceof SrcOfIpSrcCase);
40 SrcOfIpSrcCase srcChoice = (SrcOfIpSrcCase) nxRegMove.getSrc().getSrcChoice();
41 assertEquals(Empty.getInstance(),srcChoice.getOfIpSrc());
42 assertEquals(0, nxRegMove.getSrc().getStart().intValue());
43 assertTrue(nxRegMove.getDst().getDstChoice() instanceof DstOfIpDstCase);
44 DstOfIpDstCase dstChoice = (DstOfIpDstCase) nxRegMove.getDst().getDstChoice();
45 assertEquals(Empty.getInstance(),dstChoice.getOfIpDst());
46 assertEquals(0, nxRegMove.getDst().getStart().intValue());
47 assertEquals(31, nxRegMove.getDst().getEnd().intValue());
51 public void generateAction() {
52 ActionInfo actionInfo = new ActionMoveSourceDestinationIp();
53 assertEquals("new ActionMoveSourceDestinationIp", generator.getExpression(actionInfo));