MRI version bump for Aluminium
[genius.git] / mdsalutil / mdsalutil-api / src / test / java / org / opendaylight / genius / mdsalutil / tests / FlowEntityAssertBeansTest.java
1 /*
2  * Copyright (c) 2017 Red Hat, Inc. 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 com.google.common.truth.Truth.assertThat;
11 import static org.junit.Assert.assertEquals;
12
13 import ch.vorburger.xtendbeans.XtendBeanGenerator;
14 import org.junit.ComparisonFailure;
15 import org.junit.Test;
16 import org.opendaylight.genius.mdsalutil.FlowEntity;
17 import org.opendaylight.genius.mdsalutil.FlowEntityBuilder;
18 import org.opendaylight.genius.mdsalutil.matches.MatchIpv4Source;
19 import org.opendaylight.yangtools.yang.common.Uint64;
20
21 /**
22  * Tests non-regression of FlowEntity related assertions.
23  * See <a href="https://bugs.opendaylight.org/show_bug.cgi?id=8800">Bug 8800</a>.
24  * @author Michael Vorburger.ch
25  */
26 public class FlowEntityAssertBeansTest {
27
28     // FLOW1 & FLOW2 differ by a minor variance in their MatchIpv4Source (NB .1 vs .2)
29     private static final FlowEntity FLOW1 = new FlowEntityBuilder()
30             .addMatchInfoList(new MatchIpv4Source("10.0.0.1", "32")).setFlowId("A").setTableId((short) 1)
31             .setDpnId(Uint64.ONE).build();
32     private static final FlowEntity FLOW2 = new FlowEntityBuilder()
33             .addMatchInfoList(new MatchIpv4Source("10.0.0.2", "32")).setFlowId("A").setTableId((short) 1)
34             .setDpnId(Uint64.ONE).build();
35
36     @Test(expected = ComparisonFailure.class)
37     public void testFlowEntityAssertEquals() {
38         assertEquals(FLOW1.toString(), FLOW2.toString());
39     }
40
41     @Test
42     public void testXtendBeanGenerator() {
43         XtendBeanGenerator generator = new UintXtendBeanGenerator();
44         assertThat(FLOW1.toString()).isEqualTo("FlowEntity{dpnId=1, cookie=1114112, flowId=A, hardTimeOut=0, "
45                 + "idleTimeOut=0, " + "instructionInfoList=[],"
46                 + " matchInfoList=[MatchIpv4Source[Ipv4Prefix{_value=10.0.0.1/32}]],"
47                 + " priority=0, sendFlowRemFlag=false, strictFlag=false, tableId=1}");
48     }
49
50 }