Use ByteBuf.readRetainedSlice()
[openflowplugin.git] / extension / openflowplugin-extension-nicira / src / test / java / org / opendaylight / openflowplugin / extension / vendor / nicira / convertor / action / DecNshTtlConvertorTest.java
1 /*
2  * Copyright (c) 2018 SUSE LINUX GmbH.  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.openflowplugin.extension.vendor.nicira.convertor.action;
9
10 import org.junit.Assert;
11 import org.junit.Before;
12 import org.junit.Test;
13 import org.junit.runner.RunWith;
14 import org.mockito.Mock;
15 import org.mockito.Mockito;
16 import org.mockito.junit.MockitoJUnitRunner;
17 import org.opendaylight.openflowplugin.extension.api.path.ActionPath;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.aug.nx.action.ActionDecNshTtl;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.dec.nsh.ttl.grouping.NxActionDecNshTtl;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.write.actions._case.write.actions.action.action.NxActionDecNshTtlNodesNodeTableFlowWriteActionsCase;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.dec.nsh.ttl.grouping.NxDecNshTtl;
23
24 @RunWith(MockitoJUnitRunner.class)
25 public class DecNshTtlConvertorTest {
26
27     @Mock
28     private NxActionDecNshTtlNodesNodeTableFlowWriteActionsCase actionsCase;
29
30     @Mock
31     private Action action;
32
33     private DecNshTtlConvertor decNshTtlConvertor;
34
35     @Before
36     public void setUp() {
37         NxDecNshTtl nxDecNshTtl = Mockito.mock(NxDecNshTtl.class);
38
39         NxActionDecNshTtl nxActionDecNshTtl = Mockito.mock(NxActionDecNshTtl.class);
40         ActionDecNshTtl actionDecNshTtl = Mockito.mock(ActionDecNshTtl.class);
41
42         decNshTtlConvertor = new DecNshTtlConvertor();
43     }
44
45     @Test
46     public void testConvertSalToOf() {
47         ActionDecNshTtl actionDecNshTtl = (ActionDecNshTtl) decNshTtlConvertor.convert(actionsCase).getActionChoice();
48         Assert.assertNotNull(actionDecNshTtl);
49     }
50
51     @Test
52     public void testConvertOfToSal() {
53         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult
54                 = decNshTtlConvertor.convert(action, ActionPath.FLOWS_STATISTICS_UPDATE_APPLY_ACTIONS);
55         Assert.assertNotNull(actionResult);
56         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult1
57                 = decNshTtlConvertor.convert(action, ActionPath.FLOWS_STATISTICS_UPDATE_WRITE_ACTIONS);
58         Assert.assertNotNull(actionResult1);
59         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult2
60                 = decNshTtlConvertor.convert(action, ActionPath.GROUP_DESC_STATS_UPDATED_BUCKET_ACTION);
61         Assert.assertNotNull(actionResult2);
62         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult3
63                 = decNshTtlConvertor.convert(action, ActionPath.INVENTORY_FLOWNODE_TABLE_WRITE_ACTIONS);
64         Assert.assertNotNull(actionResult3);
65         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult4
66                 = decNshTtlConvertor.convert(action, ActionPath.FLOWS_STATISTICS_RPC_APPLY_ACTIONS);
67         Assert.assertNotNull(actionResult4);
68         org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action actionResult5
69                 = decNshTtlConvertor.convert(action, ActionPath.FLOWS_STATISTICS_RPC_WRITE_ACTIONS);
70         Assert.assertNotNull(actionResult5);
71     }
72 }