Specialize relative leafref types during instantiation
[mdsal.git] / binding / mdsal-binding-java-api-generator / src / test / java / org / opendaylight / mdsal / binding / java / api / generator / BuilderGeneratorTest.java
index 79cbe70982680c2fac3110fc5033a422e9fb962d..3e9b7b6cdbdb0cb6ab745ba0d716635b3b542d01 100644 (file)
@@ -11,6 +11,7 @@ import static org.junit.Assert.assertEquals;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.when;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -90,17 +91,14 @@ public class BuilderGeneratorTest {
                 + " hashing\n"
                 + " * results across all implementations.\n"
                 + " *\n"
-                + " * @param <T$$> implementation type, which has to also implement AugmentationHolder interface\n"
-                + " *              contract.\n"
                 + " * @param obj Object for which to generate hashCode() result.\n"
                 + " * @return Hash code value of data modeled by this interface.\n"
                 + " * @throws NullPointerException if {@code obj} is null\n"
                 + " */\n"
-                + "static <T$$ extends test.test & AugmentationHolder<?>> int bindingHashCode(final @NonNull T$$ obj) {"
-                + "\n"
+                + "static int bindingHashCode(final test.@NonNull test obj) {\n"
                 + "    final int prime = 31;\n"
                 + "    int result = 1;\n"
-                + "    result = prime * result + CodeHelpers.hashAugmentations(obj);\n"
+                + "    result = prime * result + obj.augmentations().hashCode();\n"
                 + "    return result;\n"
                 + "}\n", genHashCode(mockAugment(mockGenType(TEST))).toString());
     }
@@ -113,18 +111,15 @@ public class BuilderGeneratorTest {
                 + " hashing\n"
                 + " * results across all implementations.\n"
                 + " *\n"
-                + " * @param <T$$> implementation type, which has to also implement AugmentationHolder interface\n"
-                + " *              contract.\n"
                 + " * @param obj Object for which to generate hashCode() result.\n"
                 + " * @return Hash code value of data modeled by this interface.\n"
                 + " * @throws NullPointerException if {@code obj} is null\n"
                 + " */\n"
-                + "static <T$$ extends test.test & AugmentationHolder<?>> int bindingHashCode(final @NonNull T$$ obj) {"
-                + "\n"
+                + "static int bindingHashCode(final test.@NonNull test obj) {\n"
                 + "    final int prime = 31;\n"
                 + "    int result = 1;\n"
                 + "    result = prime * result + Objects.hashCode(obj.getTest());\n"
-                + "    result = prime * result + CodeHelpers.hashAugmentations(obj);\n"
+                + "    result = prime * result + obj.augmentations().hashCode();\n"
                 + "    return result;\n"
                 + "}\n", genHashCode(mockAugment(mockGenType("get" + TEST))).toString());
     }
@@ -137,19 +132,16 @@ public class BuilderGeneratorTest {
                 + " hashing\n"
                 + " * results across all implementations.\n"
                 + " *\n"
-                + " * @param <T$$> implementation type, which has to also implement AugmentationHolder interface\n"
-                + " *              contract.\n"
                 + " * @param obj Object for which to generate hashCode() result.\n"
                 + " * @return Hash code value of data modeled by this interface.\n"
                 + " * @throws NullPointerException if {@code obj} is null\n"
                 + " */\n"
-                + "static <T$$ extends test.test & AugmentationHolder<?>> int bindingHashCode(final @NonNull T$$ obj) {"
-                + "\n"
+                + "static int bindingHashCode(final test.@NonNull test obj) {\n"
                 + "    final int prime = 31;\n"
                 + "    int result = 1;\n"
                 + "    result = prime * result + Objects.hashCode(obj.getTest1());\n"
                 + "    result = prime * result + Objects.hashCode(obj.getTest2());\n"
-                + "    result = prime * result + CodeHelpers.hashAugmentations(obj);\n"
+                + "    result = prime * result + obj.augmentations().hashCode();\n"
                 + "    return result;\n"
                 + "}\n", genHashCode(mockAugment(mockGenTypeMoreMeth("get" + TEST))).toString());
     }
@@ -217,14 +209,11 @@ public class BuilderGeneratorTest {
                 + " * Implementations of this interface are encouraged to defer to this method to get consistent string"
                 + "\n * representations across all implementations.\n"
                 + " *\n"
-                + " * @param <T$$> implementation type, which has to also implement AugmentationHolder interface\n"
-                + " *              contract.\n"
                 + " * @param obj Object for which to generate toString() result.\n"
                 + " * @return {@link String} value of data modeled by this interface.\n"
                 + " * @throws NullPointerException if {@code obj} is null\n"
                 + " */\n"
-                + "static <T$$ extends test.test & AugmentationHolder<test.test>> String bindingToString(final @NonNull"
-                + " T$$ obj) {\n"
+                + "static String bindingToString(final test.@NonNull test obj) {\n"
                 + "    final MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(\"test\");\n"
                 + "    CodeHelpers.appendValue(helper, \"augmentation\", obj.augmentations().values());\n"
                 + "    return helper.toString();\n"
@@ -238,14 +227,11 @@ public class BuilderGeneratorTest {
                 + " * Implementations of this interface are encouraged to defer to this method to get consistent string"
                 + "\n * representations across all implementations.\n"
                 + " *\n"
-                + " * @param <T$$> implementation type, which has to also implement AugmentationHolder interface\n"
-                + " *              contract.\n"
                 + " * @param obj Object for which to generate toString() result.\n"
                 + " * @return {@link String} value of data modeled by this interface.\n"
                 + " * @throws NullPointerException if {@code obj} is null\n"
                 + " */\n"
-                + "static <T$$ extends test.test & AugmentationHolder<test.test>> String bindingToString(final @NonNull"
-                + " T$$ obj) {\n"
+                + "static String bindingToString(final test.@NonNull test obj) {\n"
                 + "    final MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(\"test\");\n"
                 + "    CodeHelpers.appendValue(helper, \"test\", obj.gettest());\n"
                 + "    CodeHelpers.appendValue(helper, \"augmentation\", obj.augmentations().values());\n"
@@ -260,14 +246,11 @@ public class BuilderGeneratorTest {
                 + " * Implementations of this interface are encouraged to defer to this method to get consistent string"
                 + "\n * representations across all implementations.\n"
                 + " *\n"
-                + " * @param <T$$> implementation type, which has to also implement AugmentationHolder interface\n"
-                + " *              contract.\n"
                 + " * @param obj Object for which to generate toString() result.\n"
                 + " * @return {@link String} value of data modeled by this interface.\n"
                 + " * @throws NullPointerException if {@code obj} is null\n"
                 + " */\n"
-                + "static <T$$ extends test.test & AugmentationHolder<test.test>> String bindingToString(final @NonNull"
-                + " T$$ obj) {\n"
+                + "static String bindingToString(final test.@NonNull test obj) {\n"
                 + "    final MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper(\"test\");\n"
                 + "    CodeHelpers.appendValue(helper, \"test1\", obj.gettest1());\n"
                 + "    CodeHelpers.appendValue(helper, \"test2\", obj.gettest2());\n"
@@ -359,6 +342,7 @@ public class BuilderGeneratorTest {
         final MethodSignature methSign = mock(MethodSignature.class);
         doReturn(methodeName).when(methSign).getName();
         final Type methType = mock(Type.class);
+        when(methType.getFullyQualifiedName()).thenCallRealMethod();
         doReturn(TYPE_NAME).when(methType).getIdentifier();
         doReturn(TEST).when(methType).getName();
         doReturn(methType).when(methSign).getReturnType();