Mark potentially-static methods as static
[genius.git] / mdsalutil / mdsalutil-api / src / test / java / org / opendaylight / genius / mdsalutil / actions / ActionSetIcmpTypeTest.java
1 /*
2  * Copyright © 2016, 2017 Red Hat, Inc. and others.
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.actions;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12 import static org.junit.Assert.assertTrue;
13
14 import ch.vorburger.xtendbeans.XtendBeanGenerator;
15 import org.junit.Test;
16 import org.opendaylight.genius.mdsalutil.ActionInfo;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCase;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv4Match;
20
21 /**
22  * Test class for {@link ActionSetIcmpType}.
23  */
24 public class ActionSetIcmpTypeTest {
25     private static final short TYPE = (short) 2;
26
27     private final XtendBeanGenerator generator = new XtendBeanGenerator();
28
29     @Test
30     public void actionInfoTest() {
31         verifyAction(new ActionSetIcmpType(TYPE).buildAction());
32     }
33
34     private static void verifyAction(Action action) {
35         assertTrue(action.getAction() instanceof SetFieldCase);
36         SetFieldCase actionCase = (SetFieldCase) action.getAction();
37         assertNotNull(actionCase.getSetField().getIcmpv4Match());
38         Icmpv4Match icmpv4Match = actionCase.getSetField().getIcmpv4Match();
39         assertEquals(TYPE, icmpv4Match.getIcmpv4Type().shortValue());
40     }
41
42     @Test
43     public void generateAction() {
44         ActionInfo actionInfo = new ActionSetIcmpType(TYPE);
45         assertEquals("new ActionSetIcmpType(0, 2 as short)", generator.getExpression(actionInfo));
46     }
47 }