Add YangNames test 56/66756/1
authorRobert Varga <robert.varga@pantheon.tech>
Mon, 25 Dec 2017 14:29:17 +0000 (15:29 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 25 Dec 2017 16:02:00 +0000 (17:02 +0100)
This adds a simplistic test to ensure YangNames.parseFileName() works
as expected.

Change-Id: Ic619ebdce2a0641418283b4621be4c676341a053
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-common/src/test/java/org/opendaylight/yangtools/yang/common/YangNamesTest.java [new file with mode: 0644]

diff --git a/yang/yang-common/src/test/java/org/opendaylight/yangtools/yang/common/YangNamesTest.java b/yang/yang-common/src/test/java/org/opendaylight/yangtools/yang/common/YangNamesTest.java
new file mode 100644 (file)
index 0000000..c957b61
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2017 Pantheon Technologies s.r.o. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * 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.yangtools.yang.common;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.AbstractMap.SimpleImmutableEntry;
+import org.junit.Test;
+
+public class YangNamesTest {
+    @Test
+    public void testParseFileName() {
+        assertEquals(new SimpleImmutableEntry<>("foo", null), YangNames.parseFilename("foo"));
+        assertEquals(new SimpleImmutableEntry<>("foo", "bar"), YangNames.parseFilename("foo@bar"));
+        assertEquals(new SimpleImmutableEntry<>("foo@bar", "baz"), YangNames.parseFilename("foo@bar@baz"));
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void testParseFileNameNull() {
+        YangNames.parseFilename(null);
+    }
+}