Fix nullness errors reported by Eclipse
[mdsal.git] / binding / yang-binding / src / test / java / org / opendaylight / yangtools / yang / binding / InstanceIdentifierTest.java
index 3a9d3752fd9db9db7e670a16b9e687afb5491a75..a666235b309c93d68320992d6306b7051f51e4e6 100644 (file)
@@ -11,9 +11,12 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Mockito.mock;
 
+import com.google.common.base.VerifyException;
 import com.google.common.collect.ImmutableList;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -25,6 +28,7 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdenti
 import org.opendaylight.yangtools.yang.binding.test.mock.FooChild;
 import org.opendaylight.yangtools.yang.binding.test.mock.InstantiatedFoo;
 import org.opendaylight.yangtools.yang.binding.test.mock.Node;
+import org.opendaylight.yangtools.yang.binding.test.mock.NodeAugmentation;
 import org.opendaylight.yangtools.yang.binding.test.mock.NodeChild;
 import org.opendaylight.yangtools.yang.binding.test.mock.NodeChildKey;
 import org.opendaylight.yangtools.yang.binding.test.mock.NodeKey;
@@ -143,7 +147,7 @@ public class InstanceIdentifierTest {
 
         assertFalse(instanceIdentifier1.equals(instanceIdentifier3));
         assertFalse(instanceIdentifier1.equals(instanceIdentifier4));
-        final InstanceIdentifier instanceIdentifier5 = InstanceIdentifier.create(Node.class);
+        final InstanceIdentifier<Node> instanceIdentifier5 = InstanceIdentifier.create(Node.class);
         final Field hashField = InstanceIdentifier.class.getDeclaredField("hash");
         hashField.setAccessible(true);
         hashField.set(instanceIdentifier5, instanceIdentifier1.hashCode());
@@ -153,7 +157,7 @@ public class InstanceIdentifierTest {
         assertNotNull(InstanceIdentifier.create(ImmutableList.copyOf(instanceIdentifier1.getPathArguments())));
         assertNotNull(InstanceIdentifier.create(Nodes.class).child(Node.class));
         assertNotNull(InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(5)));
-        assertNotNull(instanceIdentifier5.augmentation(DataObject.class));
+        assertNotNull(instanceIdentifier5.augmentation(NodeAugmentation.class));
         assertNotNull(instanceIdentifier1.hashCode());
         assertNotNull(instanceIdentifier1.toString());
 
@@ -177,7 +181,7 @@ public class InstanceIdentifierTest {
     @Test
     public void firstKeyOfTest() {
         final InstanceIdentifier<Node> instanceIdentifier =
-                InstanceIdentifier.builder(Nodes.class).child(Node.class,new NodeKey(10)).build();
+                InstanceIdentifier.builder(Nodes.class).child(Node.class, new NodeKey(10)).build();
         final InstanceIdentifier<DataObject> instanceIdentifier1 = InstanceIdentifier.create(DataObject.class);
         assertNotNull(instanceIdentifier.firstKeyOf(Node.class));
         assertNull(instanceIdentifier1.firstKeyOf(Node.class));
@@ -261,4 +265,11 @@ public class InstanceIdentifierTest {
         assertTrue(builder3.hashCode() != builder4.hashCode());
     }
 
+    @Test
+    public void verifyTargetTest() {
+        final InstanceIdentifier<Nodes> nodeId = InstanceIdentifier.create(Nodes.class);
+        assertSame(nodeId, nodeId.verifyTarget(Nodes.class));
+        assertThrows(VerifyException.class, () -> nodeId.verifyTarget(Node.class));
+    }
+
 }