Update NodeIdentifierWithPredicates construction
[netconf.git] / restconf / restconf-nb-rfc8040 / src / test / java / org / opendaylight / restconf / nb / rfc8040 / utils / parser / YangInstanceIdentifierSerializerTest.java
index b508f2048e01b0ee26545ef744896319ecc17998..8721346af16251099bf58b228dfac007d7693121 100644 (file)
@@ -5,13 +5,12 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.restconf.nb.rfc8040.utils.parser;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
@@ -19,10 +18,13 @@ import org.junit.Before;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
+import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
 import org.opendaylight.restconf.nb.rfc8040.utils.parser.builder.ParserBuilderConstants;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
@@ -86,8 +88,7 @@ public class YangInstanceIdentifierSerializerTest {
         final YangInstanceIdentifier data = YangInstanceIdentifier.builder()
                 .node(QName.create("serializer:test", "2016-06-06", "contA"))
                 .node(list)
-                .node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
-                        list, QName.create(list, "list-key"), 100))
+                .node(NodeIdentifierWithPredicates.of(list, QName.create(list, "list-key"), 100))
                 .node(leafList)
                 .node(new NodeWithValue<>(leafList, "instance"))
                 .build();
@@ -217,7 +218,7 @@ public class YangInstanceIdentifierSerializerTest {
 
     /**
      * Negative test when it is not possible to find child node of current node. Test is expected to fail with
-     * <code>IllegalArgumentException</code> and error message is compared to expected error message.
+     * <code>RestconfDocumentedException</code> and error message is compared to expected error message.
      */
     @Test
     public void serializeChildNodeNotFoundNegativeTest() {
@@ -226,7 +227,7 @@ public class YangInstanceIdentifierSerializerTest {
                 .node(QName.create("serializer:test", "2016-06-06", "not-existing-leaf"))
                 .build();
 
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierSerializer.create(this.schemaContext, data);
     }
 
@@ -296,9 +297,8 @@ public class YangInstanceIdentifierSerializerTest {
 
         final YangInstanceIdentifier data = YangInstanceIdentifier.builder()
                 .node(list)
-                .node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
-                        list, QName.create(list, "list-key"), 100))
-                .node(new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(child)))
+                .node(NodeIdentifierWithPredicates.of(list, QName.create(list, "list-key"), 100))
+                .node(new AugmentationIdentifier(ImmutableSet.of(child)))
                 .node(child)
                 .build();
 
@@ -311,7 +311,7 @@ public class YangInstanceIdentifierSerializerTest {
     /**
      * Test of serialization when nodes in input <code>YangInstanceIdentifier</code> are defined in two different
      * modules by using augmentation. Augmented node in data supplied for serialization has wrong namespace.
-     * <code>IllegalArgumentException</code> is expected because augmented node is defined in other module than its
+     * <code>RestconfDocumentedException</code> is expected because augmented node is defined in other module than its
      * parent and will not be found.
      */
     @Test
@@ -322,13 +322,12 @@ public class YangInstanceIdentifierSerializerTest {
 
         final YangInstanceIdentifier data = YangInstanceIdentifier.builder()
                 .node(list)
-                .node(new YangInstanceIdentifier.NodeIdentifierWithPredicates(
-                        list, QName.create(list, "list-key"), 100))
-                .node(new YangInstanceIdentifier.AugmentationIdentifier(Sets.newHashSet(child)))
+                .node(NodeIdentifierWithPredicates.of(list, QName.create(list, "list-key"), 100))
+                .node(new AugmentationIdentifier(ImmutableSet.of(child)))
                 .node(child)
                 .build();
 
-        this.thrown.expect(IllegalArgumentException.class);
+        this.thrown.expect(RestconfDocumentedException.class);
         YangInstanceIdentifierSerializer.create(this.schemaContext, data);
     }
 }