TestIMdsalApiManager assertFlowsInAnyOrder LOG.warn 94/52494/1
authorMichael Vorburger <vorburger@redhat.com>
Wed, 1 Mar 2017 11:56:08 +0000 (12:56 +0100)
committerMichael Vorburger <vorburger@redhat.com>
Wed, 1 Mar 2017 11:56:08 +0000 (12:56 +0100)
based on the discussion in
https://git.opendaylight.org/gerrit/#/c/50467/

Change-Id: Iefe24270d1861e2eddc12bdec577cb14591f429f
Signed-off-by: Michael Vorburger <vorburger@redhat.com>
mdsalutil/mdsalutil-api/src/test/java/org/opendaylight/genius/mdsalutil/interfaces/testutils/TestIMdsalApiManager.java

index ddde6dfd88d8c17f31c6df3c8e76d10250e09c2f..a26654bb3d46851c9525ef64505e6078874cd93d 100644 (file)
@@ -24,6 +24,8 @@ import org.mockito.Mockito;
 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
 import org.opendaylight.genius.mdsalutil.FlowEntity;
 import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Fake IMdsalApiManager useful for tests.
@@ -40,6 +42,8 @@ import org.opendaylight.genius.mdsalutil.interfaces.IMdsalApiManager;
  */
 public abstract class TestIMdsalApiManager implements IMdsalApiManager {
 
+    private static final Logger LOG = LoggerFactory.getLogger(TestIMdsalApiManager.class);
+
     private List<FlowEntity> flows;
 
     public static TestIMdsalApiManager newInstance() {
@@ -104,6 +108,13 @@ public abstract class TestIMdsalApiManager implements IMdsalApiManager {
         try {
             assertThat(flows).containsExactlyElementsIn(expectedFlowsAsNewArrayList);
         } catch (AssertionError e) {
+            // We LOG the expected and actual flow in case of a failed assertion
+            // because, even though that is typically just a HUGE String that's
+            // hard to read (the diff printed subsequently by assertEqualBeans
+            // is, much, more readable), there are cases when looking more closely
+            // at the full toString() output of the flows is still useful, so:
+            LOG.warn("assert fail; expected flows: {}", expectedFlowsAsNewArrayList);
+            LOG.warn("assert fail; actual flows  : {}", flows);
             // The point of this is basically just that our assertEqualBeans output,
             // in case of a comparison failure, is *A LOT* more clearly readable
             // than what G Truth (or Hamcrest) can do based on toString.