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.instructions;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
13 import java.util.Collections;
14 import java.util.List;
15 import org.junit.Test;
16 import org.opendaylight.genius.mdsalutil.InstructionInfo;
17 import org.opendaylight.genius.mdsalutil.InstructionType;
18 import org.opendaylight.genius.mdsalutil.actions.ActionGroup;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCase;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
25 * Test for {@link InstructionApplyActions}.
27 public class InstructionApplyActionsTest {
29 public void backwardsCompatibleInstruction() {
30 verifyInstructionInfo(
31 new InstructionInfo(InstructionType.apply_actions, Collections.singletonList(new ActionGroup(1L))));
35 public void newInstruction() {
36 verifyInstructionInfo(new InstructionApplyActions(Collections.singletonList(new ActionGroup(1L))));
39 private void verifyInstructionInfo(InstructionInfo instructionInfo) {
40 Instruction instruction = instructionInfo.buildInstruction(2);
41 assertEquals(2, instruction.getKey().getOrder().intValue());
42 assertTrue(instruction.getInstruction() instanceof ApplyActionsCase);
43 ApplyActionsCase applyActionsCase = (ApplyActionsCase) instruction.getInstruction();
44 List<Action> actions = applyActionsCase.getApplyActions().getAction();
45 assertEquals(1, actions.size());
46 Action action = actions.get(0);
47 assertTrue(action.getAction() instanceof GroupActionCase);