2 * Copyright © 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 org.junit.Test;
16 import org.opendaylight.genius.mdsalutil.ActionInfo;
17 import org.opendaylight.genius.mdsalutil.tests.UintXtendBeanGenerator;
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.DstOfMetadataCase;
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.Uint16;
24 import org.opendaylight.yangtools.yang.common.Uint64;
27 * Test for {@link ActionNxLoadMetadata}.
29 public class ActionNxLoadMetadataTest {
30 private static final Uint64 VALUE = Uint64.valueOf(10);
31 private static final Integer START = 0;
32 private static final Integer END = 23;
34 private final XtendBeanGenerator generator = new UintXtendBeanGenerator();
37 public void actionInfoTest() {
38 verifyAction(new ActionNxLoadMetadata(VALUE, START, END).buildAction());
41 private static void verifyAction(Action action) {
42 assertTrue(action.getAction() instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase);
43 NxActionRegLoadNodesNodeTableFlowApplyActionsCase actionCase =
44 (NxActionRegLoadNodesNodeTableFlowApplyActionsCase) action.getAction();
45 assertNotNull(actionCase.getNxRegLoad());
46 NxRegLoad nxRegLoad = actionCase.getNxRegLoad();
47 assertTrue(nxRegLoad.getDst().getDstChoice() instanceof DstOfMetadataCase);
48 DstOfMetadataCase dstOfMetadataCase = (DstOfMetadataCase) nxRegLoad.getDst().getDstChoice();
49 assertEquals(Empty.getInstance(), dstOfMetadataCase.getOfMetadata());
50 assertEquals(Uint16.valueOf(START), nxRegLoad.getDst().getStart());
51 assertEquals(Uint16.valueOf(END), nxRegLoad.getDst().getEnd());
52 assertEquals(VALUE, nxRegLoad.getValue());
56 public void generateAction() {
57 ActionInfo actionInfo = new ActionNxLoadMetadata(VALUE, START, END);
58 assertEquals("new ActionNxLoadMetadata(0, (u64)" + VALUE + ", " + START + ", " + END + ")",
59 generator.getExpression(actionInfo));