Reduce use of getChildByName()
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / codecs / StringPatternCheckingCodecTest.java
index e024f9599b4ae19139a1cbef28af8a2611ae98c4..5922e6bf1d881b1f92ca447daa6efcbaab5946f0 100644 (file)
@@ -5,7 +5,6 @@
  * 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.data.impl.codecs;
 
 import static org.junit.Assert.assertEquals;
@@ -39,13 +38,11 @@ public class StringPatternCheckingCodecTest {
         final QNameModule testModuleQName = QNameModule.create(URI.create("string-pattern-checking-codec-test"));
 
         final Module testModule = schemaContext.findModules("string-pattern-checking-codec-test").iterator().next();
-        final ContainerSchemaNode testContainer = (ContainerSchemaNode) testModule.getDataChildByName(
-                QName.create(testModuleQName, "test-container"));
-        assertNotNull(testContainer);
+        final ContainerSchemaNode testContainer = (ContainerSchemaNode) testModule.findDataChildByName(
+                QName.create(testModuleQName, "test-container")).get();
 
-        final LeafSchemaNode testLeaf = (LeafSchemaNode) testContainer.getDataChildByName(
-                QName.create(testModuleQName, "string-leaf-with-valid-pattern"));
-        assertNotNull(testLeaf);
+        final LeafSchemaNode testLeaf = (LeafSchemaNode) testContainer.findDataChildByName(
+                QName.create(testModuleQName, "string-leaf-with-valid-pattern")).get();
 
         final StringCodec<String> codec = getCodec(testLeaf.getType(), StringCodec.class);
         assertNotNull(codec);
@@ -56,8 +53,8 @@ public class StringPatternCheckingCodecTest {
             codec.deserialize("abcd");
             fail("Exception should have been thrown.");
         } catch (final IllegalArgumentException ex) {
-            LOG.debug("IllegalArgumentException was thrown as expected: {}", ex);
-            assertEquals("Supplied value does not match the regular expression ^[A-Z]+$.", ex.getMessage());
+            LOG.debug("IllegalArgumentException was thrown as expected", ex);
+            assertEquals("Value 'abcd' does not match regular expression '[A-Z]+'", ex.getMessage());
         }
     }
 }