Propagate EffectiveModelContext to more places
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / leafref / context / DataTreeCandidateValidatorTest.java
index 46a6338e955f95f49fce35fca2b7248006a7297c..eee5c861c97998c10237870345fa36b2f2019ba8 100644 (file)
@@ -12,7 +12,6 @@ import static org.junit.Assert.assertTrue;
 
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Set;
 import org.apache.log4j.BasicConfigurator;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -34,6 +33,7 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeConfiguration;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
+import org.opendaylight.yangtools.yang.data.api.schema.tree.DataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefContext;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefDataValidationFailedException;
 import org.opendaylight.yangtools.yang.data.impl.leafref.LeafRefValidation;
@@ -45,16 +45,16 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuil
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.tree.InMemoryDataTreeFactory;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
 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.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class DataTreeCandidateValidatorTest {
 
-    private static SchemaContext context;
+    private static EffectiveModelContext context;
     private static Module valModule;
     private static QNameModule valModuleQname;
     private static LeafRefContext rootLeafRefContext;
@@ -99,11 +99,10 @@ public class DataTreeCandidateValidatorTest {
     }
 
     @BeforeClass
-    public static void init()  {
+    public static void init() throws DataValidationFailedException {
         context = YangParserTestUtils.parseYangResourceDirectory("/leafref-validation");
 
-        final Set<Module> modules = context.getModules();
-        for (final Module module : modules) {
+        for (final Module module : context.getModules()) {
             if (module.getName().equals("leafref-validation")) {
                 valModule = module;
             }
@@ -175,7 +174,7 @@ public class DataTreeCandidateValidatorTest {
     }
 
     @Test
-    public void dataTreeCanditateValidationTest() {
+    public void dataTreeCanditateValidationTest() throws DataValidationFailedException {
         write();
 
         write2();
@@ -189,7 +188,7 @@ public class DataTreeCandidateValidatorTest {
         writeIntoMapEntry();
     }
 
-    private static void writeContributors() {
+    private static void writeContributors() throws DataValidationFailedException {
 
         final ContainerSchemaNode contributorContSchemaNode = (ContainerSchemaNode) valModule
                 .findDataChildByName(odlContributor).get();
@@ -232,7 +231,7 @@ public class DataTreeCandidateValidatorTest {
 
     }
 
-    private static void writeIntoMapEntry() {
+    private static void writeIntoMapEntry() throws DataValidationFailedException {
 
         final Map<QName, Object> keys = new HashMap<>();
         keys.put(name, "New Project");
@@ -278,7 +277,7 @@ public class DataTreeCandidateValidatorTest {
 
     }
 
-    private static void writeMapEntry() {
+    private static void writeMapEntry() throws DataValidationFailedException {
 
         final Map<QName, Object> keys = new HashMap<>();
         keys.put(name, "New Project");
@@ -330,7 +329,7 @@ public class DataTreeCandidateValidatorTest {
 
     }
 
-    private static void write() {
+    private static void write() throws DataValidationFailedException {
 
         final ContainerSchemaNode contributorContSchemaNode = (ContainerSchemaNode) valModule
                 .findDataChildByName(odlContributor).get();
@@ -378,7 +377,7 @@ public class DataTreeCandidateValidatorTest {
         assertTrue(exception);
     }
 
-    private static void write2() {
+    private static void write2() throws DataValidationFailedException {
 
         final ContainerSchemaNode odlCon = (ContainerSchemaNode) valModule.findDataChildByName(odl).get();
         final ContainerSchemaNode con1Con = (ContainerSchemaNode) odlCon.findDataChildByName(con1).get();
@@ -553,7 +552,7 @@ public class DataTreeCandidateValidatorTest {
         return mapEntryBuilder.build();
     }
 
-    private static void delete() {
+    private static void delete() throws DataValidationFailedException {
 
         final YangInstanceIdentifier contributorPath = YangInstanceIdentifier
                 .of(odlContributor);
@@ -562,8 +561,7 @@ public class DataTreeCandidateValidatorTest {
         delete.delete(contributorPath);
         delete.ready();
 
-        final DataTreeCandidate deleteContributorsCanditate = inMemoryDataTree
-                .prepare(delete);
+        final DataTreeCandidate deleteContributorsCanditate = inMemoryDataTree.prepare(delete);
 
         LOG.debug("*************************");
         LOG.debug("Before delete: ");