2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.model.util;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
13 import com.google.common.collect.ImmutableSet;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
17 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
18 import org.opendaylight.yangtools.yang.model.spi.SimpleSchemaContext;
19 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
21 public class YT691Test {
23 public void testGetAllModuleIdentifiers() {
24 final SourceIdentifier foo = new SourceIdentifier("foo", "2016-01-01");
25 final SourceIdentifier sub1Foo = new SourceIdentifier("sub1-foo", "2016-01-01");
26 final SourceIdentifier sub2Foo = new SourceIdentifier("sub2-foo", "2016-01-01");
27 final SourceIdentifier bar = new SourceIdentifier("bar", "2016-01-01");
28 final SourceIdentifier sub1Bar = new SourceIdentifier("sub1-bar", "2016-01-01");
29 final SourceIdentifier baz = new SourceIdentifier("baz", "2016-01-01");
30 final Set<SourceIdentifier> testSet = ImmutableSet.of(foo, sub1Foo, sub2Foo, bar, sub1Bar, baz);
31 final EffectiveModelContext context = YangParserTestUtils.parseYangResourceDirectory("/yt691");
32 final Set<SourceIdentifier> allModuleIdentifiers = SchemaContextUtil.getConstituentModuleIdentifiers(context);
33 assertEquals(6, allModuleIdentifiers.size());
34 final Set<SourceIdentifier> allModuleIdentifiersResolved = SchemaContextUtil.getConstituentModuleIdentifiers(
35 SimpleSchemaContext.forModules(context.getModules()));
36 assertEquals(6, allModuleIdentifiersResolved.size());
37 assertEquals(allModuleIdentifiersResolved, allModuleIdentifiers);
38 assertEquals(allModuleIdentifiers, testSet);
39 assertTrue(allModuleIdentifiers.contains(foo));