YANGTOOLS-844: Filtering/SimpleSchemaContext violate getModules() contract 12/67212/13
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 16 Jan 2018 16:21:50 +0000 (17:21 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Wed, 17 Jan 2018 17:30:11 +0000 (18:30 +0100)
commit638d4c43bcbfd308b9c80da4f4c286941567d974
treef55670bd9cd5c8c0bd2a66fc5bf66746f0188185
parentb4e30ef6985789be1c7f73579b39791e03a7660c
YANGTOOLS-844: Filtering/SimpleSchemaContext violate getModules() contract

getModules() is explicit about how the modules should be ordered,
which is not compatible with ModuleDependencySort. As it turns out
ModuleDependencySort is only needed in MD-SAL codegen, where we
already invoke it explicitly.

Explicitly sort modules according to requirements of getModules(),
fulfilling that contract.

This also affects findModule(String) and related functions, which
are sorted, but in inverse order of what is specified. Fix that
by adjusting AbstractSchemaContext.REVISION_COMPARATOR and
introducing NAME_REVISION_COMPARATOR for use in places where modules
are not guaranteed to have a unique name.

Change-Id: Ie91685b830694764158381e4696e3f7d5bb57fba
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/AbstractSchemaContext.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/FilteringSchemaContextProxy.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/SimpleSchemaContext.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SchemaContextProxyTest.java
yang/yang-model-util/src/test/java/org/opendaylight/yangtools/yang/model/util/SimpleSchemaContextTest.java [new file with mode: 0644]