Bump MRI upstreams
[netconf.git] / netconf / sal-netconf-connector / src / test / java / org / opendaylight / netconf / sal / connect / netconf / NetconfToNotificationTest.java
index d9525a07f36d8dda9e83639b3af835b4fecbb250..2bf7bc4b4a73de58688a8768b208e33117c4516d 100644 (file)
@@ -5,31 +5,31 @@
  * 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.netconf.sal.connect.netconf;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertThrows;
 import static org.junit.Assert.assertTrue;
 
-import com.google.common.collect.Iterables;
 import java.io.InputStream;
-import java.util.Set;
+import java.util.Collection;
 import org.junit.Before;
 import org.junit.Test;
-import org.opendaylight.controller.md.sal.dom.api.DOMEvent;
-import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
+import org.opendaylight.mdsal.dom.api.DOMEvent;
+import org.opendaylight.mdsal.dom.api.DOMNotification;
 import org.opendaylight.netconf.api.NetconfMessage;
 import org.opendaylight.netconf.api.xml.XmlUtil;
 import org.opendaylight.netconf.notifications.NetconfNotification;
 import org.opendaylight.netconf.sal.connect.netconf.schema.mapping.NetconfMessageTransformer;
+import org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.Module;
-import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.Document;
 
-public class NetconfToNotificationTest {
+public class NetconfToNotificationTest extends AbstractBaseSchemasTest {
 
     NetconfMessageTransformer messageTransformer;
 
@@ -45,8 +45,9 @@ public class NetconfToNotificationTest {
         userNotification = new NetconfMessage(doc);
     }
 
-    static SchemaContext getNotificationSchemaContext(final Class<?> loadClass, final boolean getExceptionTest) {
-        final SchemaContext context;
+    static EffectiveModelContext getNotificationSchemaContext(final Class<?> loadClass,
+            final boolean getExceptionTest) {
+        final EffectiveModelContext context;
         if (getExceptionTest) {
             context = YangParserTestUtils.parseYangResources(loadClass, "/schemas/user-notification4.yang",
                     "/schemas/user-notification3.yang");
@@ -55,29 +56,31 @@ public class NetconfToNotificationTest {
                 "/schemas/user-notification2.yang");
         }
 
-        final Set<Module> modules = context.getModules();
+        final Collection<? extends Module> modules = context.getModules();
         assertTrue(!modules.isEmpty());
         assertNotNull(context);
         return context;
     }
 
-    @Test(expected =  IllegalArgumentException.class)
+    @Test
     public void testMostRecentWrongYangModel() throws Exception {
-        final SchemaContext schemaContext = getNotificationSchemaContext(getClass(), true);
-        messageTransformer = new NetconfMessageTransformer(schemaContext, true);
-        messageTransformer.toNotification(userNotification);
+        final EffectiveModelContext schemaContext = getNotificationSchemaContext(getClass(), true);
+        messageTransformer = new NetconfMessageTransformer(new EmptyMountPointContext(schemaContext), true,
+            BASE_SCHEMAS.getBaseSchema());
+        assertThrows(IllegalArgumentException.class, () -> messageTransformer.toNotification(userNotification));
     }
 
     @Test
     public void testToNotificationFunction() throws Exception {
-        final SchemaContext schemaContext = getNotificationSchemaContext(getClass(), false);
-        messageTransformer = new NetconfMessageTransformer(schemaContext, true);
+        final EffectiveModelContext schemaContext = getNotificationSchemaContext(getClass(), false);
+        messageTransformer = new NetconfMessageTransformer(new EmptyMountPointContext(schemaContext), true,
+            BASE_SCHEMAS.getBaseSchema());
         final DOMNotification domNotification = messageTransformer.toNotification(userNotification);
         final ContainerNode root = domNotification.getBody();
         assertNotNull(root);
-        assertEquals(6, Iterables.size(root.getValue()));
-        assertEquals("user-visited-page", root.getNodeType().getLocalName());
-        assertEquals(NetconfNotification.RFC3339_DATE_PARSER.apply("2015-10-23T09:42:27.67175+00:00"),
-                ((DOMEvent) domNotification).getEventTime());
+        assertEquals(6, root.body().size());
+        assertEquals("user-visited-page", root.getIdentifier().getNodeType().getLocalName());
+        assertEquals(NetconfNotification.RFC3339_DATE_PARSER.apply("2015-10-23T09:42:27.67175+00:00").toInstant(),
+                ((DOMEvent) domNotification).getEventInstant());
     }
 }