Move Bug5437Test to yang-model-util-ut
[yangtools.git] / yang / yang-parser-rfc7950 / src / test / java / org / opendaylight / yangtools / yang / stmt / MustAndWhenStmtTest.java
index 98e6656c3f78f3fabfa6815bdd1c7ba0b25addf2..9ef264fb5739b31df6d881faa638b85fd424fd58 100644 (file)
@@ -5,14 +5,13 @@
  * 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.stmt;
 
 import static org.hamcrest.CoreMatchers.anyOf;
 import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
 import static org.junit.Assert.assertTrue;
 import static org.opendaylight.yangtools.yang.stmt.StmtTestUtils.sourceForResource;
 
@@ -44,19 +43,19 @@ public class MustAndWhenStmtTest {
         assertNotNull(container);
         assertTrue(container.isPresenceContainer());
 
-        final Collection<MustDefinition> musts = container.getMustConstraints();
+        final Collection<? extends MustDefinition> musts = container.getMustConstraints();
         assertEquals(2, musts.size());
 
-        final Iterator<MustDefinition> mustsIterator = musts.iterator();
+        final Iterator<? extends MustDefinition> mustsIterator = musts.iterator();
         MustDefinition mustStmt = mustsIterator.next();
-        assertThat(mustStmt.getXpath().getOriginalString(), anyOf(is("ifType != 'ethernet' or (ifType = 'ethernet' and "
+        assertThat(mustStmt.getXpath().toString(), anyOf(is("ifType != 'ethernet' or (ifType = 'ethernet' and "
                 + "ifMTU = 1500)"), is("ifType != 'atm' or (ifType = 'atm' and ifMTU <= 17966 and ifMTU >= 64)")));
         assertThat(mustStmt.getErrorMessage(), anyOf(is(Optional.of("An ethernet MTU must be 1500")),
             is(Optional.of("An atm MTU must be 64 .. 17966"))));
         assertThat(mustStmt.getErrorAppTag(), anyOf(is(Optional.of("An ethernet error")),
             is(Optional.of("An atm error"))));
         mustStmt = mustsIterator.next();
-        assertThat(mustStmt.getXpath().getOriginalString(), anyOf(
+        assertThat(mustStmt.getXpath().toString(), anyOf(
             is("ifType != 'ethernet' or (ifType = 'ethernet' and ifMTU = 1500)"),
             is("ifType != 'atm' or (ifType = 'atm' and ifMTU <= 17966 and ifMTU >= 64)")));
         assertThat(mustStmt.getErrorMessage(), anyOf(is(Optional.of("An ethernet MTU must be 1500")),
@@ -78,6 +77,6 @@ public class MustAndWhenStmtTest {
         final ContainerSchemaNode container = (ContainerSchemaNode) testModule.getDataChildByName(
             QName.create(testModule.getQNameModule(), "test-container"));
         assertNotNull(container);
-        assertEquals("conditional-leaf = 'autumn-leaf'", container.getWhenCondition().get().getOriginalString());
+        assertEquals("conditional-leaf = 'autumn-leaf'", container.getWhenCondition().orElseThrow().toString());
     }
 }