2 * Copyright (c) 2016 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.mdsal.binding.testutils;
10 import static com.google.common.truth.Truth.assertThat;
12 import ch.vorburger.xtendbeans.AssertBeans;
13 import org.junit.ComparisonFailure;
14 import org.junit.Test;
15 import org.opendaylight.yangtools.yang.binding.DataObject;
18 * Tests that the {@link AssertDataObjects} utility also works for any Java
19 * object that is not a {@link DataObject}, like the {@link AssertBeans} which
20 * it's based on. There is absolutely no particular reason why it wouldn't,
21 * because {@link AssertDataObjects} is essentially just a customization of
22 * {@link AssertBeans} - this is just to make sure none of the base
23 * functionality gets broken in the customization.
25 * @author Michael Vorburger
27 public class AssertNonDataObjectsTest {
29 public static class SomeBean {
32 public String getName() {
36 public void setName(String name) {
42 public void testString() {
43 AssertDataObjects.assertEqualBeans("hello, world", "hello, world");
47 public void testSomeBean() {
48 SomeBean first = new SomeBean();
49 first.setName("hello, world");
51 SomeBean second = new SomeBean();
52 second.setName("hello, world");
54 AssertDataObjects.assertEqualBeans(first, second);
58 public void testSomeBeanMismatch() {
59 SomeBean expected = new SomeBean();
60 expected.setName("hello, world 1");
62 SomeBean actual = new SomeBean();
63 actual.setName("hello, world 2");
66 AssertDataObjects.assertEqualBeans(expected, actual);
67 } catch (ComparisonFailure e) {
68 assertThat(e.getExpected()).contains("hello, world 1");
69 assertThat(e.getActual()).contains("hello, world 2");