New test utility AssertDataObjects
[mdsal.git] / binding / mdsal-binding-test-utils / src / test / java / org / opendaylight / mdsal / binding / testutils / AssertNonDataObjectsTest.java
1 /*
2  * Copyright (c) 2016 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.mdsal.binding.testutils;
9
10 import ch.vorburger.xtendbeans.AssertBeans;
11 import org.junit.Test;
12 import org.opendaylight.yangtools.yang.binding.DataObject;
13
14 /**
15  * Tests that the {@link AssertDataObjects} utility also works for any Java
16  * object that is not a {@link DataObject}, like the {@link AssertBeans} which
17  * it's based on. There is absolutely no particular reason why it wouldn't,
18  * because {@link AssertDataObjects} is essentially just a customization of
19  * {@link AssertBeans} - this is just to make sure none of the base
20  * functionality gets broken in the customization.
21  *
22  * @author Michael Vorburger
23  */
24 public class AssertNonDataObjectsTest {
25
26     public static class SomeBean {
27         private String name;
28
29         public String getName() {
30             return name;
31         }
32
33         public void setName(String name) {
34             this.name = name;
35         }
36     }
37
38     @Test
39     public void testString() {
40         AssertDataObjects.assertEqualBeans("hello, world", "hello, world");
41     }
42
43     @Test
44     public void testSomeBean() {
45         SomeBean first = new SomeBean();
46         first.setName("hello, world");
47
48         SomeBean second = new SomeBean();
49         second.setName("hello, world");
50
51         AssertDataObjects.assertEqualBeans(first, second);
52     }
53
54 }