X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=yang%2Fyang-model-util%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fmodel%2Futil%2FYT691Test.java;fp=yang%2Fyang-model-util%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fyangtools%2Fyang%2Fmodel%2Futil%2FYT691Test.java;h=b7afea71d51119900c50119e537a68cf598448b3;hb=6d33cbd4b512dedede99521ae838bfa5ead8c604;hp=0000000000000000000000000000000000000000;hpb=8d29bf214b3703d115777171c7749a14202823c5;p=yangtools.git diff --git a/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/YT691Test.java b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/YT691Test.java new file mode 100644 index 0000000000..b7afea71d5 --- /dev/null +++ b/yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/YT691Test.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * 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.model.util; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.common.collect.ImmutableSet; +import java.util.Optional; +import java.util.Set; +import org.junit.Test; +import org.opendaylight.yangtools.yang.common.Revision; +import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext; +import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier; +import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier; +import org.opendaylight.yangtools.yang.model.spi.SimpleSchemaContext; +import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils; + +public class YT691Test { + @Test + public void testGetAllModuleIdentifiers() { + final Optional revision = Revision.ofNullable("2016-01-01"); + final SourceIdentifier foo = RevisionSourceIdentifier.create("foo", revision); + final SourceIdentifier sub1Foo = RevisionSourceIdentifier.create("sub1-foo", revision); + final SourceIdentifier sub2Foo = RevisionSourceIdentifier.create("sub2-foo", revision); + final SourceIdentifier bar = RevisionSourceIdentifier.create("bar", revision); + final SourceIdentifier sub1Bar = RevisionSourceIdentifier.create("sub1-bar", revision); + final SourceIdentifier baz = RevisionSourceIdentifier.create("baz", revision); + final Set testSet = ImmutableSet.of(foo, sub1Foo, sub2Foo, bar, sub1Bar, baz); + final EffectiveModelContext context = YangParserTestUtils.parseYangResourceDirectory("/yt691"); + final Set allModuleIdentifiers = SchemaContextUtil.getConstituentModuleIdentifiers(context); + assertEquals(6, allModuleIdentifiers.size()); + final Set allModuleIdentifiersResolved = SchemaContextUtil.getConstituentModuleIdentifiers( + SimpleSchemaContext.forModules(context.getModules())); + assertEquals(6, allModuleIdentifiersResolved.size()); + assertEquals(allModuleIdentifiersResolved, allModuleIdentifiers); + assertEquals(allModuleIdentifiers, testSet); + assertTrue(allModuleIdentifiers.contains(foo)); + } +} \ No newline at end of file