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 ch.vorburger.xtendbeans.XtendBeanGenerator;
14 import java.util.Collections;
15 import java.util.List;
16 import org.junit.Test;
17 import org.opendaylight.genius.mdsalutil.InstructionInfo;
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.WriteActionsCase;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
25 * Test for {@link InstructionWriteActions}.
27 public class InstructionWriteActionsTest {
29 private static final InstructionWriteActions INSTRUCTION_INFO
30 = new InstructionWriteActions(Collections.singletonList(new ActionGroup(1L)));
33 public void newInstruction() {
34 verifyInstructionInfo(INSTRUCTION_INFO);
37 private void verifyInstructionInfo(InstructionInfo instructionInfo) {
38 Instruction instruction = instructionInfo.buildInstruction(2);
39 assertEquals(2, instruction.key().getOrder().intValue());
40 assertTrue(instruction.getInstruction() instanceof WriteActionsCase);
41 WriteActionsCase writeActionsCase = (WriteActionsCase) instruction.getInstruction();
42 List<Action> actions = writeActionsCase.getWriteActions().getAction();
43 assertEquals(1, actions.size());
44 Action action = actions.get(0);
45 assertTrue(action.getAction() instanceof GroupActionCase);
49 public void xtendBeanGenerator() {
50 XtendBeanGenerator generator = new XtendBeanGenerator();
51 assertEquals("new InstructionWriteActions(#[\n"
52 + " (new ActionGroupBuilder => [\n"
55 + "])", generator.getExpression(INSTRUCTION_INFO));