YANGTOOLS-706: Refactor YangInferencePipeline
[yangtools.git] / yang / yang-parser-impl / src / test / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / effective / ConstraintDefinitionsTest.java
index 3d3baa895826dd08161f4bcd68c7fe5b716720f6..fb5281ef44a43b4e3a4c25f3bc9a9c8540c975b6 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.parser.stmt.rfc6020.effective;
 
 import static org.junit.Assert.assertEquals;
@@ -19,7 +18,7 @@ import java.net.URISyntaxException;
 import java.text.ParseException;
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.data.util.ConstraintDefinitions;
 import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
@@ -28,27 +27,22 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.opendaylight.yangtools.yang.parser.impl.DefaultReactors;
 import org.opendaylight.yangtools.yang.parser.rfc6020.repo.YangStatementStreamSource;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
-import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
-import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
 
 public class ConstraintDefinitionsTest {
 
     @Test
     public void testConstraintDefinitions() throws ParseException, ReactorException, URISyntaxException, IOException,
             YangSyntaxErrorException {
-        final CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-
-        reactor.addSource(YangStatementStreamSource.create(
-            YangTextSchemaSource.forResource("/constraint-definitions-test/foo.yang")));
-        final SchemaContext schemaContext = reactor.buildEffective();
+        final SchemaContext schemaContext = DefaultReactors.defaultReactor().newBuild()
+                .addSource(YangStatementStreamSource.create(
+                    YangTextSchemaSource.forResource("/constraint-definitions-test/foo.yang")))
+                .buildEffective();
         assertNotNull(schemaContext);
 
-        final Module testModule = schemaContext.findModuleByName("foo",
-            SimpleDateFormatUtil.getRevisionFormat().parse("2016-09-20"));
-        assertNotNull(testModule);
-
+        final Module testModule = schemaContext.findModule("foo", Revision.of("2016-09-20")).get();
         final LeafSchemaNode mandatoryLeaf1 = (LeafSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "mandatory-leaf-1"));
         assertNotNull(mandatoryLeaf1);
@@ -70,8 +64,8 @@ public class ConstraintDefinitionsTest {
         assertNotNull(mandatoryLeaf3);
         ConstraintDefinition constraints3 = mandatoryLeaf3.getConstraints();
 
-        assertNotEquals(ConstraintDefinitions.hashCode(constraints2), ConstraintDefinitions.hashCode(constraints3));
-        assertFalse(ConstraintDefinitions.equals(constraints2, constraints3));
+        assertEquals(ConstraintDefinitions.hashCode(constraints2), ConstraintDefinitions.hashCode(constraints3));
+        assertTrue(ConstraintDefinitions.equals(constraints2, constraints3));
 
         final LeafSchemaNode mandatoryLeaf4 = (LeafSchemaNode) testModule.getDataChildByName(
                 QName.create(testModule.getQNameModule(), "mandatory-leaf-4"));
@@ -120,6 +114,6 @@ public class ConstraintDefinitionsTest {
 
         final String constraintsString = ConstraintDefinitions.toString(constraints4);
         assertEquals("EffectiveConstraintDefinitionImpl{whenCondition=foo = 'bar', mustConstraints=[bar != 'foo'], "
-                + "mandatory=true, minElements=50, maxElements=100}", constraintsString);
+                + "minElements=50, maxElements=100}", constraintsString);
     }
 }
\ No newline at end of file