Merge "New match Reg4 type and temporary SMAC table definitions"
[genius.git] / mdsalutil / mdsalutil-api / src / test / java / org / opendaylight / genius / mdsalutil / tests / ActionInfoImmutableTest.java
1 /*
2  * Copyright (c) 2016 Red Hat and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.genius.mdsalutil.tests;
9
10 import static org.junit.Assert.assertEquals;
11
12 import java.math.BigInteger;
13 import java.util.ArrayList;
14 import java.util.List;
15 import org.junit.Test;
16 import org.opendaylight.genius.mdsalutil.ActionInfo;
17 import org.opendaylight.genius.mdsalutil.ActionType;
18 import org.opendaylight.genius.mdsalutil.FlowEntity;
19 import org.opendaylight.genius.mdsalutil.InstructionInfo;
20 import org.opendaylight.genius.mdsalutil.InstructionType;
21 import org.opendaylight.genius.mdsalutil.actions.ActionNxConntrack;
22
23 public class ActionInfoImmutableTest {
24
25     @Test
26     public void actionInfoActionKeyDoesNotMagicallyChangeOnFlowEntityGetFlowBuilder() {
27         FlowEntity flowEntity = new FlowEntity(BigInteger.valueOf(123L));
28         flowEntity.setFlowId("TEST");
29         flowEntity.setCookie(BigInteger.valueOf(110100480L));
30         ActionInfo actionInfo = new ActionNxConntrack(27, 1, 0, 0, (short) 255);
31         List<ActionInfo> actionInfos = new ArrayList<>();
32         actionInfos.add(actionInfo);
33         flowEntity.getInstructionInfoList().add(new InstructionInfo(InstructionType.apply_actions, actionInfos));
34         assertEquals(27, flowEntity.getInstructionInfoList().get(0).getActionInfos().get(0).getActionKey());
35
36         flowEntity.getFlowBuilder();
37         assertEquals(27, flowEntity.getInstructionInfoList().get(0).getActionInfos().get(0).getActionKey());
38         flowEntity.getFlowBuilder();
39         assertEquals(27, flowEntity.getInstructionInfoList().get(0).getActionInfos().get(0).getActionKey());
40     }
41
42 }