Merge "SouthboundIT: make "value mandatory" a builder property"
authorSam Hague <shague@redhat.com>
Sat, 23 Jan 2016 22:48:37 +0000 (22:48 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Sat, 23 Jan 2016 22:48:37 +0000 (22:48 +0000)
southbound/southbound-it/src/test/java/org/opendaylight/ovsdb/southbound/it/SouthboundIT.java

index 425ba4c9da7820166853926fd5941225a24d143c..96dd3c4a5e75418572658d48aa9d41db2f4ecd59 100644 (file)
@@ -1594,6 +1594,8 @@ public class SouthboundIT extends AbstractMdsalTestBase {
 
         protected abstract void setValue(Builder<T> builder, String value);
 
+        protected abstract boolean isValueMandatory();
+
         public final T build(final String testName, final String key, final String value) {
             final Builder<T> builder = builder();
             this.counter++;
@@ -1626,6 +1628,11 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         protected void setValue(Builder<PortExternalIds> builder, String value) {
             ((PortExternalIdsBuilder) builder).setExternalIdValue(value);
         }
+
+        @Override
+        protected boolean isValueMandatory() {
+            return true;
+        }
     }
 
     private static final class SouthboundInterfaceExternalIdsBuilder extends KeyValueBuilder<InterfaceExternalIds> {
@@ -1643,6 +1650,11 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         protected void setValue(Builder<InterfaceExternalIds> builder, String value) {
             ((InterfaceExternalIdsBuilder) builder).setExternalIdValue(value);
         }
+
+        @Override
+        protected boolean isValueMandatory() {
+            return true;
+        }
     }
 
     private static final class SouthboundOptionsBuilder extends KeyValueBuilder<Options> {
@@ -1660,6 +1672,11 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         protected void setValue(Builder<Options> builder, String value) {
             ((OptionsBuilder) builder).setValue(value);
         }
+
+        @Override
+        protected boolean isValueMandatory() {
+            return false;
+        }
     }
 
     private static final class SouthboundInterfaceOtherConfigsBuilder extends KeyValueBuilder<InterfaceOtherConfigs> {
@@ -1677,6 +1694,11 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         protected void setValue(Builder<InterfaceOtherConfigs> builder, String value) {
             ((InterfaceOtherConfigsBuilder) builder).setOtherConfigValue(value);
         }
+
+        @Override
+        protected boolean isValueMandatory() {
+            return false;
+        }
     }
 
     private static final class SouthboundPortOtherConfigsBuilder extends KeyValueBuilder<PortOtherConfigs> {
@@ -1694,6 +1716,11 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         protected void setValue(Builder<PortOtherConfigs> builder, String value) {
             ((PortOtherConfigsBuilder) builder).setOtherConfigValue(value);
         }
+
+        @Override
+        protected boolean isValueMandatory() {
+            return false;
+        }
     }
 
     private static final class SouthboundBridgeOtherConfigsBuilder extends KeyValueBuilder<BridgeOtherConfigs> {
@@ -1711,6 +1738,11 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         protected void setValue(Builder<BridgeOtherConfigs> builder, String value) {
             ((BridgeOtherConfigsBuilder) builder).setBridgeOtherConfigValue(value);
         }
+
+        @Override
+        protected boolean isValueMandatory() {
+            return false;
+        }
     }
 
     private static final class SouthboundBridgeExternalIdsBuilder extends KeyValueBuilder<BridgeExternalIds> {
@@ -1728,6 +1760,11 @@ public class SouthboundIT extends AbstractMdsalTestBase {
         protected void setValue(Builder<BridgeExternalIds> builder, String value) {
             ((BridgeExternalIdsBuilder) builder).setBridgeExternalIdValue(value);
         }
+
+        @Override
+        protected boolean isValueMandatory() {
+            return true;
+        }
     }
 
     /*
@@ -1755,13 +1792,13 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                 .input(builder.build(testOneName, idKey, idValue))
                 .expectInputAsOutput()
                 .build());
+        builder.reset();
 
         // Test Case 2:  TestFive
         // Test Type:    Positive
         // Description:  Create a termination point with multiple (five) values
         // Expected:     A port is created with the five values specified below
         final String testFiveName = "TestFive" + testName;
-        builder.reset();
         testCases.add(new SouthboundTestCaseBuilder<T>()
                 .name(testFiveName)
                 .input(
@@ -1772,37 +1809,32 @@ public class SouthboundIT extends AbstractMdsalTestBase {
                         builder.build(testFiveName, idKey, idValue))
                 .expectInputAsOutput()
                 .build());
+        builder.reset();
 
-        if ((builder instanceof SouthboundBridgeExternalIdsBuilder) ||
-                (builder instanceof SouthboundInterfaceExternalIdsBuilder) ||
-                (builder instanceof SouthboundPortExternalIdsBuilder)) {
-            LOG.info("generateKeyValueTestCases: instance skipping test case 3 TestOneGoodOneMalformedValue");
+        if (!builder.isValueMandatory()) {
+            // Test Case 3:  TestOneGoodOneMalformedValue
+            // Test Type:    Negative
+            // Description:
+            //     One perfectly fine input
+            //        (TestOneGoodOneMalformedValue_GoodKey_1,
+            //        TestOneGoodOneMalformedValue_GoodValue_1)
+            //     and one malformed input which only has key specified
+            //        (TestOneGoodOneMalformedValue_NoValueForKey_2,
+            //        UNSPECIFIED)
+            // Expected:     A port is created without any values
+            final String testOneGoodOneMalformedValueName = "TestOneGoodOneMalformedValue" + testName;
+            testCases.add(new SouthboundTestCaseBuilder<T>()
+                    .name(testOneGoodOneMalformedValueName)
+                    .input(
+                            builder.build(testOneGoodOneMalformedValueName, GOOD_KEY, GOOD_VALUE),
+                            builder.build(testOneGoodOneMalformedValueName, NO_VALUE_FOR_KEY, null))
+                    .expectNoOutput()
+                    .build());
             builder.reset();
-
-            return testCases;
+        } else {
+            LOG.info("generateKeyValueTestCases: skipping test case 3 for {}", builder.getClass().getSimpleName());
         }
 
-        // Test Case 3:  TestOneGoodOneMalformedValue
-        // Test Type:    Negative
-        // Description:
-        //     One perfectly fine input
-        //        (TestOneGoodOneMalformedValue_GoodKey_1,
-        //        TestOneGoodOneMalformedValue_GoodValue_1)
-        //     and one malformed input which only has key specified
-        //        (TestOneGoodOneMalformedValue_NoValueForKey_2,
-        //        UNSPECIFIED)
-        // Expected:     A port is created without any values
-        final String testOneGoodOneMalformedValueName = "TestOneGoodOneMalformedValue" + testName;
-        builder.reset();
-        testCases.add(new SouthboundTestCaseBuilder<T>()
-                .name(testOneGoodOneMalformedValueName)
-                .input(
-                        builder.build(testOneGoodOneMalformedValueName, GOOD_KEY, GOOD_VALUE),
-                        builder.build(testOneGoodOneMalformedValueName, NO_VALUE_FOR_KEY, null))
-                .expectNoOutput()
-                .build());
-        builder.reset();
-
         return testCases;
     }