2 * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
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.tests;
10 import static com.google.common.truth.Truth.assertThat;
11 import static org.opendaylight.mdsal.binding.testutils.AssertDataObjects.assertEqualBeans;
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;
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
26 public class FlowEntityAssertBeansTest {
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();
36 @Test(expected = ComparisonFailure.class)
37 public void testFlowEntityAssertEqualBeans() {
38 assertEqualBeans(FLOW1, FLOW2);
42 public void testXtendBeanGenerator() {
43 XtendBeanGenerator generator = new UintXtendBeanGenerator();
44 assertThat(generator.getExpression(FLOW1)).isEqualTo("(new FlowEntityBuilder => [\n"
45 + " cookie = (u64)1114112\n"
48 + " hardTimeOut = 0\n"
49 + " idleTimeOut = 0\n"
50 + " instructionInfoList = #[\n"
52 + " matchInfoList = #[\n"
53 + " new MatchIpv4Source(new Ipv4Prefix(\"10.0.0.1/32\"))\n"
56 + " sendFlowRemFlag = false\n"
57 + " strictFlag = false\n"
58 + " tableId = 1 as short\n"