import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
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;
@Mock private LeafSchemaNode leafReplayLog;
@Mock private LeafSchemaNode leafEvents;
- private static Set<Module> modules;
- private static SchemaContext schemaContext;
- private static SchemaContext schemaContextMonitoring;
+ private static Collection<? extends Module> modules;
+ private static EffectiveModelContext schemaContext;
+ private static EffectiveModelContext schemaContextMonitoring;
- private static Set<Module> modulesRest;
+ private static Collection<? extends Module> modulesRest;
@BeforeClass
public static void loadTestSchemaContextAndModules() throws Exception {
// verify loaded modules
verifyLoadedModules((ContainerNode) mods);
+ // verify deviations
+ verifyDeviations((ContainerNode) mods);
}
@Test
assertNotNull(normNode);
final List<Object> listOfValues = new ArrayList<>();
- for (final DataContainerChild<? extends PathArgument, ?> child : ((ContainerNode) normNode).getValue()) {
+ for (final DataContainerChild<? extends PathArgument, ?> child : normNode.getValue()) {
if (child.getNodeType().equals(MonitoringModule.CONT_CAPABILITES_QNAME)) {
for (final DataContainerChild<? extends PathArgument, ?> dataContainerChild : ((ContainerNode) child)
.getValue()) {
}
}
+ /**
+ * Verify whether the loaded modules contain any deviations.
+ *
+ * @param containerNode
+ * modules
+ */
+ private static void verifyDeviations(final ContainerNode containerNode) {
+ int deviationsFound = 0;
+ for (final DataContainerChild child : containerNode.getValue()) {
+ if (child instanceof MapNode) {
+ for (final MapEntryNode mapEntryNode : ((MapNode) child).getValue()) {
+ for (final DataContainerChild dataContainerChild : mapEntryNode
+ .getValue()) {
+ if (dataContainerChild.getNodeType()
+ .equals(IetfYangLibrary.SPECIFIC_MODULE_DEVIATION_LIST_QNAME)) {
+ deviationsFound++;
+ }
+ }
+ }
+ }
+ }
+ Assert.assertTrue(deviationsFound > 0);
+ }
+
/**
* Verify loaded modules.
*
for (final DataContainerChild<? extends PathArgument, ?> child : containerNode.getValue()) {
if (child instanceof LeafNode) {
- assertEquals(IetfYangLibrary.MODULE_SET_ID_LEAF_QNAME, ((LeafNode<?>) child).getNodeType());
+ assertEquals(IetfYangLibrary.MODULE_SET_ID_LEAF_QNAME, child.getNodeType());
}
if (child instanceof MapNode) {
- assertEquals(IetfYangLibrary.MODULE_QNAME_LIST, ((MapNode) child).getNodeType());
+ assertEquals(IetfYangLibrary.MODULE_QNAME_LIST, child.getNodeType());
for (final MapEntryNode mapEntryNode : ((MapNode) child).getValue()) {
String name = "";
String revision = "";
.getValue()) {
switch (dataContainerChild.getNodeType().getLocalName()) {
case IetfYangLibrary.SPECIFIC_MODULE_NAME_LEAF:
- name = String.valueOf(((LeafNode<?>) dataContainerChild).getValue());
+ name = String.valueOf(dataContainerChild.getValue());
break;
case IetfYangLibrary.SPECIFIC_MODULE_REVISION_LEAF:
- revision = String.valueOf(((LeafNode<?>) dataContainerChild).getValue());
+ revision = String.valueOf(dataContainerChild.getValue());
break;
default :
LOG.info("Unknown local name '{}' of node.",
* @param expectedModules Modules from <code>SchemaContext</code>
* @param loadedModules Loaded modules into Restconf module
*/
- private static void verifyLoadedModules(final Set<Module> expectedModules,
+ private static void verifyLoadedModules(final Collection<? extends Module> expectedModules,
final Map<String, String> loadedModules) {
assertEquals("Number of loaded modules is not as expected", expectedModules.size(), loadedModules.size());
for (final Module m : expectedModules) {