New test utility AssertDataObjects 42/46842/9
authorMichael Vorburger <vorburger@redhat.com>
Wed, 12 Oct 2016 15:10:48 +0000 (17:10 +0200)
committerRobert Varga <nite@hq.sk>
Thu, 20 Oct 2016 21:06:17 +0000 (21:06 +0000)
commit18170324fab2eb494c7d8721521a429802dd48f9
tree7cc0fe0ef58586f2541a45718c1bbd3019c9af3f
parent082ccfc61766e06fb45c545780b53849f0c19771
New test utility AssertDataObjects

This adapts https://github.com/vorburger/xtendbeans to OpenDaylight.

That library can be used as-is for "normal" Java objects, such as Flow
beans, as seen e.g. in https://git.opendaylight.org/gerrit/#/c/42109/.

This change make it possible to use that library to compare actual
DataObject obtained from the DataBroker with expected objects in tests,
as illustrated e.g. in https://git.opendaylight.org/gerrit/#/c/44000/
(Those objects have a number of peculiarities which need adaption,
provided by the classes in this change.)

One can use AssertDataObjects.assertEqualBeans(Object expected, Object
actual)
WITHOUT ever writing any Xtend code, and WITHOUT any code generation,
and use this utility JUST to get a very readable text diff between two
object trees; this will look like shown in this presentation screenshot:
https://docs.google.com/presentation/d/1bnwj8CrFGo5KekONYSeIHySdkoXZiewJxkHcZjXnzkQ/edit#slide=id.g17d8ae4d92_0_150

It is ALSO possible, but not required, to use the text syntax shown (see
linked screenshot) to declare the expected object by copy/paste of that
syntax into an *.xtend source file (from which an Xtend Maven plugin
code
generates Java code), because that text "happens" (intentionally) to be
valid Xtend.

This last step is purely optional though, and while some downstream
projects may adopt this to define expected objects in a readable syntax,
others may not, and simply define their expected objects with normal
Java code and Builders (or reading them from XML, or whatever) - yet can
still use this this new utility - just for a great diff / comparison
kind of view, only.

This code has dependencies on yangtools, mdsal, plus a test
model for its self test - and the external xtendbeans library (which
should be considered like any of the 100s of other ext. deps. we have).

Change-Id: I34aac96bd13b936d6fb76a484a512081c18e0b11
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
12 files changed:
binding/mdsal-binding-test-utils/pom.xml [new file with mode: 0644]
binding/mdsal-binding-test-utils/src/main/java/org/opendaylight/mdsal/binding/testutils/AssertDataObjects.java [new file with mode: 0644]
binding/mdsal-binding-test-utils/src/main/java/org/opendaylight/mdsal/binding/testutils/AugmentableExtension.java [new file with mode: 0644]
binding/mdsal-binding-test-utils/src/main/java/org/opendaylight/mdsal/binding/testutils/XtendBuilderExtensions.java [new file with mode: 0644]
binding/mdsal-binding-test-utils/src/main/java/org/opendaylight/mdsal/binding/testutils/XtendYangBeanGenerator.java [new file with mode: 0644]
binding/mdsal-binding-test-utils/src/test/java/org/opendaylight/mdsal/binding/testutils/AssertDataObjectsTest.java [new file with mode: 0644]
binding/mdsal-binding-test-utils/src/test/java/org/opendaylight/mdsal/binding/testutils/AssertNonDataObjectsTest.java [new file with mode: 0644]
binding/mdsal-binding-test-utils/src/test/java/org/opendaylight/mdsal/binding/testutils/AugmentableExtensionTest.java [new file with mode: 0644]
binding/mdsal-binding-test-utils/src/test/java/org/opendaylight/mdsal/binding/testutils/ExampleYangObjects.java [new file with mode: 0644]
binding/mdsal-binding-test-utils/src/test/java/org/opendaylight/mdsal/binding/testutils/ExpectedObjects.java [new file with mode: 0644]
binding/pom.xml
common/artifacts/pom.xml