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.assertNotNull;
12 import static org.junit.Assert.assertTrue;
14 import ch.vorburger.xtendbeans.XtendBeanGenerator;
15 import com.google.common.net.InetAddresses;
16 import org.junit.Test;
17 import org.opendaylight.genius.mdsalutil.ActionInfo;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.dst.choice.grouping.dst.choice.DstOfArpSpaCase;
20 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.NxActionRegLoadNodesNodeTableFlowApplyActionsCase;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.reg.load.grouping.NxRegLoad;
22 import org.opendaylight.yangtools.yang.common.Empty;
23 import org.opendaylight.yangtools.yang.common.Uint64;
26 * Test for {@link ActionLoadIpToSpa}.
28 public class ActionLoadIpToSpaTest {
29 private static final String IP_ADDRESS = "1.2.3.4";
31 private final XtendBeanGenerator generator = new XtendBeanGenerator();
34 public void actionInfoTest() {
35 verifyAction(new ActionLoadIpToSpa(IP_ADDRESS).buildAction());
38 private static void verifyAction(Action action) {
39 assertTrue(action.getAction() instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase);
40 NxActionRegLoadNodesNodeTableFlowApplyActionsCase actionCase =
41 (NxActionRegLoadNodesNodeTableFlowApplyActionsCase) action.getAction();
42 assertNotNull(actionCase.getNxRegLoad());
43 NxRegLoad nxRegLoad = actionCase.getNxRegLoad();
44 assertTrue(nxRegLoad.getDst().getDstChoice() instanceof DstOfArpSpaCase);
45 DstOfArpSpaCase dstOfArpSpaCase = (DstOfArpSpaCase) nxRegLoad.getDst().getDstChoice();
46 assertEquals(Empty.getInstance(),dstOfArpSpaCase.getOfArpSpa());
47 assertEquals(0, nxRegLoad.getDst().getStart().intValue());
48 assertEquals(31, nxRegLoad.getDst().getEnd().intValue());
50 Uint64.valueOf(InetAddresses.coerceToInteger(InetAddresses.forString(IP_ADDRESS)) & 0xffffffffL),
51 nxRegLoad.getValue());
55 public void generateAction() {
56 ActionInfo actionInfo = new ActionLoadIpToSpa(IP_ADDRESS);
57 assertEquals("new ActionLoadIpToSpa(0, \"" + IP_ADDRESS + "\")", generator.getExpression(actionInfo));