yangtools.git
5 years agoEnable findbugs in mockito-configuration 65/76065/2
Robert Varga [Thu, 13 Sep 2018 10:07:13 +0000 (12:07 +0200)]
Enable findbugs in mockito-configuration

This fixes warnings reported and flips the switch.

Change-Id: I4f035e4c3a9c7bc4a764668abb6adb9b8d952c9c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump to odlparent 4.0.0 58/76058/1
Stephen Kitt [Thu, 13 Sep 2018 10:10:06 +0000 (12:10 +0200)]
Bump to odlparent 4.0.0

Change-Id: I67af761a5a5f45fe8a76c3905661cff626355935
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoAdd a license badge 53/76053/1
Robert Varga [Thu, 13 Sep 2018 08:35:38 +0000 (10:35 +0200)]
Add a license badge

This adds a bit of visibility on github.

Change-Id: I4e62496583184ac28a39fcf8efbff869dfc5461e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix Sonar integration 14/76014/5
Robert Varga [Tue, 11 Sep 2018 23:31:30 +0000 (01:31 +0200)]
Fix Sonar integration

Use project-wide merged JaCoCo execution profile for Sonar purposes,
providing real coverage provided by yangtools UTs. This patch is rather
intrusive due to the need to override odlparent settings to make it
work.

Change-Id: I8aacec9bd2ab45d5a4ffe83d692b020d7bf32ab8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix logging template 25/76025/2
Robert Varga [Wed, 12 Sep 2018 09:31:27 +0000 (11:31 +0200)]
Fix logging template

Logger template is missing a placeholder, add it.

Change-Id: Ib1068bc4e122affc69e408da87378230607b7408
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoEnable findbugs in more artifacts 17/76017/4
Robert Varga [Wed, 12 Sep 2018 00:26:19 +0000 (02:26 +0200)]
Enable findbugs in more artifacts

This fixed/enables FB warnings in yang-maven-plugin-spi,
yang-parser-spi, yang-test-util and yang-xpath-api,
yang-parser-impl and ang-maven-plugin-it.

Change-Id: I1b9abdbd32f81b16243c111c74143929a573d76e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix pom.xml formatting 07/76007/1
Robert Varga [Tue, 11 Sep 2018 20:58:18 +0000 (22:58 +0200)]
Fix pom.xml formatting

The patches to enable findbugs had incorrect indentation of
</plugin>. Fix that.

Change-Id: I0c58c600625a44500ff68b39fc6653d7721f2519
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRevert "Experiment: aggregate jacoco for sonar" 06/76006/1
Robert Varga [Tue, 11 Sep 2018 20:55:55 +0000 (22:55 +0200)]
Revert "Experiment: aggregate jacoco for sonar"

This reverts commit 7358371685ccb40a38f7214acd1785d4c9e73236
and cfceb5bc60cbf0d622db1f41466ace602c3ab6e5.

Change-Id: I63153afeedd1ca91835ca6fc63c6af6a71fa3a3b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoExperiment: fix base.directory vs. basedir 99/75999/1
Robert Varga [Tue, 11 Sep 2018 19:42:46 +0000 (21:42 +0200)]
Experiment: fix base.directory vs. basedir

This fixes up previous patch to correctly reference maven
base directory.

Change-Id: Ib10d67ddbc9d1db116a237f99455cb0a676645c3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoExperiment: aggregate jacoco for sonar 96/75996/5
Robert Varga [Tue, 11 Sep 2018 15:04:51 +0000 (17:04 +0200)]
Experiment: aggregate jacoco for sonar

This is a second cut, overriding targets for jacoco and also
pointing sonar to the aggregate report.

Change-Id: I07f13985edfbe766c41f6adff1a714c31b6d017a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRevert "Experiment: merge jacoco reports" 89/75989/1
Robert Varga [Tue, 11 Sep 2018 14:11:41 +0000 (16:11 +0200)]
Revert "Experiment: merge jacoco reports"

This reverts commit 5ae609d30b1584d716e93b5faedcb80e1405fd99.

Change-Id: I75da3ddef983b8eb71f577394e056ce245f05c5d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoExperiment: merge jacoco reports 84/75984/1
Robert Varga [Tue, 11 Sep 2018 12:51:11 +0000 (14:51 +0200)]
Experiment: merge jacoco reports

This is an experiment with sonar, which should allow us to get
better coverage reports.

Change-Id: Ic5649dc88fe36e33a0274f089961a642bfc2e719
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix warnings in yang-model-util 77/75977/1
Robert Varga [Tue, 11 Sep 2018 10:08:48 +0000 (12:08 +0200)]
Fix warnings in yang-model-util

This fixes warnings reported in yang-model-util and enables findbugs
enforcement.

Change-Id: Ieb04815237075f6606711ac72e2b10910b2aa854
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix warnings in yang-model-api 76/75976/1
Robert Varga [Tue, 11 Sep 2018 09:56:33 +0000 (11:56 +0200)]
Fix warnings in yang-model-api

This fixes warnings reported in yang-model-api and enables findbugs
enforcement.

Change-Id: Iad35b5ba7c4b9c0373dbcf7be2d696cb66755600
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove tabs from pom.xmls 75/75975/1
Robert Varga [Tue, 11 Sep 2018 09:30:03 +0000 (11:30 +0200)]
Remove tabs from pom.xmls

This fixes formatting to comply with ODL standards.

Change-Id: Ieffe637a9ce2d5663164e979822be5c2646ecd7e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix warnings in yang-data-api 74/75974/2
Robert Varga [Tue, 11 Sep 2018 09:25:59 +0000 (11:25 +0200)]
Fix warnings in yang-data-api

This fixes warnings reported in yang-data-api and enables findbugs
enforcement.

Change-Id: Ibb999c321b852ad71f21301c31322f9659adffd1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoEnable findbugs in yang-parser-api 73/75973/2
Robert Varga [Tue, 11 Sep 2018 09:03:36 +0000 (11:03 +0200)]
Enable findbugs in yang-parser-api

Flip the switch on enforcement.

Change-Id: I7bcb413c1aafd00ec63efc1ac296332ae0c1118b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix warnings in rfc8040 support 72/75972/2
Robert Varga [Tue, 11 Sep 2018 08:56:20 +0000 (10:56 +0200)]
Fix warnings in rfc8040 support

This fixes warnings reported in rfc8040-model-api and
rfc8040-parser-support, and enables findbugs enforcement.

Change-Id: I4ee91b65cc7f6ae11fffbdd3181d6470d9214c04
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoEnable findbugs in rfc7952 support 71/75971/2
Robert Varga [Tue, 11 Sep 2018 08:54:12 +0000 (10:54 +0200)]
Enable findbugs in rfc7952 support

This just flips the enforcement switch, not further changes.

Change-Id: Idb94e589ec7ba58f9ee22231ff5c6fd0d27fc49f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoEnable findbugs in rfc6536 support 70/75970/2
Robert Varga [Tue, 11 Sep 2018 08:40:42 +0000 (10:40 +0200)]
Enable findbugs in rfc6536 support

This just flips the enforcement switch, not further changes.

Change-Id: Iec68058a4e056b4e7b3320213a3ae290a46d3837
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix warnings in openconfig support 69/75969/2
Robert Varga [Tue, 11 Sep 2018 08:37:47 +0000 (10:37 +0200)]
Fix warnings in openconfig support

This fixes warnings reported in openconfig-model-api and
openconfig-parser-support, and enables findbugs enforcement.

Change-Id: I6769c4b4ddb4f4782911619e4d6c177d55f7dccf
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix warnings in odlext support 68/75968/2
Robert Varga [Tue, 11 Sep 2018 08:33:43 +0000 (10:33 +0200)]
Fix warnings in odlext support

This fixes warnings reported in odlext-model-api and odlext-parser-support,
and enables findbugs enforcement.

Change-Id: I97d0f98052d36fbbbee1590abbc33ad4e9db07a8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix findbugs in yang-common and enable enforcement 67/75967/2
Robert Varga [Tue, 11 Sep 2018 08:24:18 +0000 (10:24 +0200)]
Fix findbugs in yang-common and enable enforcement

Fix trivial issues and suppress places where findbugs does not
understand annotations.

Change-Id: I988e1471b04d42e988f20b9492d6b0f07252f6be
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix javadoc warnings in testutils and enable findbugs 66/75966/2
Robert Varga [Tue, 11 Sep 2018 08:15:04 +0000 (10:15 +0200)]
Fix javadoc warnings in testutils and enable findbugs

This fixes javadoc warnings and enables findbugs in testutils.

Change-Id: If5b4cfe8cc30f8c551534e506be9d322d9c4ce03
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix warnings in concepts and enable findbugs 63/75963/2
Robert Varga [Tue, 11 Sep 2018 08:06:17 +0000 (10:06 +0200)]
Fix warnings in concepts and enable findbugs

This patch fixes all javac/checkstyle/findbugs/javadoc warnings
and enables findbugs enforcement.

Change-Id: I48a488e54cb533dd38fba5c3a61233dadef35e43
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd yang-model-api tests 47/75947/2
Robert Varga [Mon, 10 Sep 2018 17:49:08 +0000 (19:49 +0200)]
Add yang-model-api tests

This improves test coverage by testing default methods in yang-model-api.

Change-Id: Iee9290c86ad7b9ab7c20c56b5ebd51ffa966c4d7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoConsider AugmentationNodes when direct descendant is not found 90/75190/34
Marek Gradzki [Tue, 14 Aug 2018 08:05:37 +0000 (10:05 +0200)]
Consider AugmentationNodes when direct descendant is not found

With previous refactors it is quite easy to arrive at a simple
solution to take augmentations into account. This also

This includes a unit test from upstream based on afi-safi-name
with bgp-openconfig-extensions.

JIRA: YANGTOOLS-892
Change-Id: I237ed2c6cbed458a2109a48b468a30650f103a48
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoEliminate LeafRefValidation.forEachChoice() 33/75933/1
Robert Varga [Mon, 10 Sep 2018 15:19:51 +0000 (17:19 +0200)]
Eliminate LeafRefValidation.forEachChoice()

As it turns out the two call sites can share more code. Introduce
processChildNode(), inlining forEachChoice() and its surrounding
lookup logic.

JIRA: YANGTOOLS-892
Change-Id: I2091abcd579ce1d48a628c3bdea9b4514b050e29
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoOptimize QNameWithPredicateImpl 18/75918/1
Robert Varga [Mon, 10 Sep 2018 10:42:51 +0000 (12:42 +0200)]
Optimize QNameWithPredicateImpl

Create a dedicated QName-only implementation, saving some space.

Change-Id: I0218763aaf4e809f50b580677fc0b634b7c918fa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoSplit up LeafRefValidation.validateNodeData() 11/75911/8
Robert Varga [Mon, 10 Sep 2018 10:02:20 +0000 (12:02 +0200)]
Split up LeafRefValidation.validateNodeData()

Turn this method into a dispatch and move logic into dedicated
methods. This makes it easier to follow the code flow and eliminate
duplicates.

JIRA: YANGTOOLS-892
Change-Id: I840fa0d2e8c7ea86efa05c1afea825e85d890837
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMinor code cleanups 15/75915/2
Robert Varga [Mon, 10 Sep 2018 09:43:07 +0000 (11:43 +0200)]
Minor code cleanups

- static private method
- reduce use of ChoiceSchemaNode.getCaseNodeByName()
- QNameWithPredicateBuilder(QName)

Change-Id: I9cf97ba4c6ef667e39212f511e17bb18b4002bc3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoUse Iterables.filter() instead of FluentIterable 09/75909/1
Robert Varga [Mon, 10 Sep 2018 08:36:12 +0000 (10:36 +0200)]
Use Iterables.filter() instead of FluentIterable

This removes allocation of one instance of FluentIterable, reducing
the amount of garbage we produce.

Change-Id: I93953f1263426f7fff20e579e56f82506fb423d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRename LeafRefValidatation to LeafRefValidation 36/75836/2
Robert Varga [Fri, 7 Sep 2018 10:22:25 +0000 (12:22 +0200)]
Rename LeafRefValidatation to LeafRefValidation

This is a naming typo which went unnoticed for quite some time,
rename the implementation class and instantiate a proxy for
compatibility.

JIRA: YANGTOOLS-892
Change-Id: I3ec77d7df41942502394047e9e13007c6693d3af
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRework choice iteration in LeafRefValidatation 31/75831/3
Robert Varga [Fri, 7 Sep 2018 09:14:48 +0000 (11:14 +0200)]
Rework choice iteration in LeafRefValidatation

Rather than extracting ChoiceNodes into a temporary list, use
a consumer which will be invoked for each of them.

JIRA: YANGTOOLS-892
Change-Id: I0956bed6e446c1ee4bf44c88fcc361abe8a508e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCleanup map iteration in LeafRefValidatation 30/75830/3
Robert Varga [Fri, 7 Sep 2018 09:07:09 +0000 (11:07 +0200)]
Cleanup map iteration in LeafRefValidatation

We have two codepaths for non-filtered and filtered map entry case,
which end up iterating over map entries. Rewrite the code in terms
of an optionally-filtered stream, reducing code duplication.

JIRA: YANGTOOLS-892
Change-Id: I3ca37edb66373cc5ab4632210980cd4a467fd198
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRework path LeafRefValidatation path tracking 29/75829/1
Robert Varga [Fri, 7 Sep 2018 08:36:20 +0000 (10:36 +0200)]
Rework path LeafRefValidatation path tracking

Rather than using a plain iterable sourced from LeafRefPath.getPathFromRoot(),
maintain a Deque sourced via getPathTowardsRoot(). This eliminates the need
for Iterables.skip() as well as not forcing getPathFromRoot() being initialized.

Change-Id: I23c054a63b2c0ceed24fcf48d2636508ee13d568
JIRA: YANGTOOLS-892
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoPass down predicates instead of the entire predicate node 80/75780/2
Robert Varga [Wed, 5 Sep 2018 22:15:47 +0000 (00:15 +0200)]
Pass down predicates instead of the entire predicate node

Since we are not using the rest of the data, it is much simpler
to just pass down predicates. It also reduces confusion as to
what state we are propagating.

Change-Id: If790fcc2a8d023cb863d09162b25d644b0dd4638
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not validate non-existent roots 79/75779/3
Robert Varga [Wed, 5 Sep 2018 21:39:18 +0000 (23:39 +0200)]
Do not validate non-existent roots

If we have no data there is no point to validate anything, and
having the root value as an invariant makes code a lot simpler.

JIRA: YANGTOOLS-892
Change-Id: Ifd68b09c03d90c8881381809047e59f3fe92682b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd LeafRefValidatation.computeValues() 78/75778/3
Robert Varga [Wed, 5 Sep 2018 21:24:30 +0000 (23:24 +0200)]
Add LeafRefValidatation.computeValues()

This separates out the heavy-weight value computation, simplifying
callers a bit.

JIRA: YANGTOOLS-892
Change-Id: I218659f830aec822f80decd3622c9890df832379
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoEliminate leafRefTargetNodeDataLog() 77/75777/3
Robert Varga [Wed, 5 Sep 2018 20:12:02 +0000 (22:12 +0200)]
Eliminate leafRefTargetNodeDataLog()

Now that we captured invariants, we can proceed to turn
leafRefTargetNodeDataLog() into a simpler lambda form.

JIRA: YANGTOOLS-892
Change-Id: I4644d0f3bc31f9f9cb3643e8443159522f14ccaa
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoUntangle result processing logic. 76/75776/1
Robert Varga [Wed, 5 Sep 2018 19:33:55 +0000 (21:33 +0200)]
Untangle result processing logic.

leafRefTargetNodeDataLog() is needlessly complex, where it is called
with 3 different sets of arguments from validateLeafRefTargetNodeData()
only.

Inline two of those callers, reducing nesting significantly and
making the code flow more obvious.

Change-Id: I68205d58677e2392989a5fc064a986f5c1716666
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMove LeafRefPath creation from fast path 72/75772/3
Robert Varga [Wed, 5 Sep 2018 18:15:00 +0000 (20:15 +0200)]
Move LeafRefPath creation from fast path

LeafRefValidation is the fast path and LeafRefPath we are creating
is in an invariant. Cache it in LeafRefContext as needed.

JIRA: YANGTOOLS-892
Change-Id: I40ef136630b7cdacca84b2f08a9e0491daa03c14
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCleanup leafref path parsing 71/75771/1
Robert Varga [Wed, 5 Sep 2018 17:39:45 +0000 (19:39 +0200)]
Cleanup leafref path parsing

We have a String on input and LeafRefPathParserImpl uses ANTLR's
CharStreams -- hence it makes no sense to bounce input through
an InputStream.

Remove this atrocity, eliminating an IOException/IllegalStateException
error path in process.

JIRA: YANGTOOLS-892
Change-Id: I78eadf30da6a1e64621ca4c14dfa13e84524b591
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCleanup LeafRefContext(Tree)Builder 70/75770/1
Robert Varga [Wed, 5 Sep 2018 17:28:16 +0000 (19:28 +0200)]
Cleanup LeafRefContext(Tree)Builder

These are package-private classes, make them final, eliminate
unneeded methods and improve code formatting.

JIRA: YANGTOOLS-892
Change-Id: I8a4925a665b1bcac7abd8088719e80f53229bafe
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCleanup LeafRefPath 61/75761/1
Robert Varga [Wed, 5 Sep 2018 15:46:13 +0000 (17:46 +0200)]
Cleanup LeafRefPath

Remove commented-out code and cleanup javadocs.

Change-Id: I7d6d62bd091191d3ab914a5767eaf4a2ab7830b4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not leak Optional in QNameWithPredicateImpl.toString() 60/75760/1
Robert Varga [Wed, 5 Sep 2018 15:19:49 +0000 (17:19 +0200)]
Do not leak Optional in QNameWithPredicateImpl.toString()

The toString() method blindly appends the revision, leading to
Optional[] being present in the result. Fix the method to look
at the returned version and append the query only when it is
present -- just like QName does.

Change-Id: I47dcdaa3c7ca7b3bfaf34898f76b10dfb2ddbe00
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoConsider namespace in namesakes 53/75753/2
Robert Varga [Wed, 5 Sep 2018 10:53:46 +0000 (12:53 +0200)]
Consider namespace in namesakes

XML (unlike JSON) has explicit namespaces which we need to take
into consideration when determining whether two elements have the
same name.

JIRA: YANGTOOLS-900
Change-Id: I0d53bee5d18d211343c094941985bd3f0b6a8776
Signed-off-by: Isabel Lloret <illoret@indra.es>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoNote UniqueConstraint changes 09/75709/1
Robert Varga [Tue, 4 Sep 2018 08:07:25 +0000 (10:07 +0200)]
Note UniqueConstraint changes

We should not be using Collection here, but rather Set. Mark the
change for 3.0.0.

Change-Id: I42c5070f7f243f3ad03e481d47757812029b5d55
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRevert "Avoid depending on immutables.value at runtime" 62/75662/1
Robert Varga [Mon, 3 Sep 2018 07:07:23 +0000 (09:07 +0200)]
Revert "Avoid depending on immutables.value at runtime"

This reverts commit 8ed3332603523219d19bd8481664790db4d8acc7. It
should not be necessary with immutables.org-2.7.1.

Change-Id: Ifb323f6f17b9ec1119b74f036925b05fa44addce
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoClean various constructs 50/75550/4
Stephen Kitt [Wed, 29 Aug 2018 16:38:57 +0000 (18:38 +0200)]
Clean various constructs

* Remove intern() on constant strings.
* Avoid some casts by changing test instance types.
* Remove a number of unnecessary type specifiers and casts.
* Remove an unnecessary return.
* Use StringBuilder::append()'s substring parameters instead of a
  separate String::substring().

Change-Id: Iaaa206d233fbc43ed1bed2d651c549643e6e7697
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoDrop commons-lang dependency 51/75551/1
Stephen Kitt [Wed, 29 Aug 2018 15:59:30 +0000 (17:59 +0200)]
Drop commons-lang dependency

yang-data-impl's test dependency on commons-lang is unused.

Change-Id: I46d543ede3190537ff9f9dacffa57a78e1e1f462
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoOmit empty attributes in toString() 12/75512/1
Robert Varga [Mon, 27 Aug 2018 15:05:09 +0000 (17:05 +0200)]
Omit empty attributes in toString()

Do not emit attributes when they are empty, which brings
the verbosity down quite a bit -- as this is typically the case.

Change-Id: Icb2fa7abb02e9714fed640ec07af1623056a73db
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoOptimize ImmutableNodes.fromInstanceId() 96/75496/3
Robert Varga [Mon, 27 Aug 2018 09:23:09 +0000 (11:23 +0200)]
Optimize ImmutableNodes.fromInstanceId()

We are doing a single pass over the YangInstanceIdentifier, hence
we can simply iterate over the nodes, without creating another
YangInstanceIdentifier at each step.

Also cleanup method visibility, mark methods final and merge some
common codepaths.

JIRA: YANGTOOLS-897
Change-Id: I7bd599436dd16f943bae71f3adce289164be25c2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRe-phrase error message 75/75475/1
Robert Varga [Fri, 24 Aug 2018 16:09:26 +0000 (18:09 +0200)]
Re-phrase error message

As per request, this patch re-phrases the error message and includes
some useful information.

Change-Id: I5915d8e5ad62e036aa429275f30ffdd0c6e3f009
JIRA: YANGTOOLS-894
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMove artifacts to top-level directory 90/75390/2
Robert Varga [Wed, 22 Aug 2018 21:50:55 +0000 (23:50 +0200)]
Move artifacts to top-level directory

common/artifacts is not really useful, move it to artifacts.

Change-Id: I3045e95e5d5db3cb7df4efabbb296a869ceb3a4b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMigrate to to newer xmlunit 73/75273/1
Robert Varga [Fri, 17 Aug 2018 15:17:59 +0000 (17:17 +0200)]
Migrate to to newer xmlunit

This migrates to newer xmlunit with the xmlunit-legacy bridge.

Change-Id: Id6114a0e6afd06994d9e14c95e7d10991c4e7b5c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix unique argument parser 27/75227/3
Robert Varga [Thu, 16 Aug 2018 12:30:11 +0000 (14:30 +0200)]
Fix unique argument parser

Unique argument can use horizontal tabs and line-breaks as separators
in addition to spaces. Deal with them instead of rejecting input.

Change-Id: I5fb6137b9b73c5c844a05cc59fb9261868834a24
JIRA: YANGTOOLS-893
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoImprove IfFeaturePredicateVisitor 13/75113/5
Robert Varga [Sat, 11 Aug 2018 00:10:23 +0000 (02:10 +0200)]
Improve IfFeaturePredicateVisitor

We need to detect parser errors and not print them to stderr,
create an abstract class with the validation functionality
and use it when parsing an if-feature argument.

Change-Id: I63ad241bcfeeda7cb05f1472f593167d5ce08404
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove unneeded junit/mockito dependencies 63/74863/6
Robert Varga [Mon, 6 Aug 2018 14:30:49 +0000 (16:30 +0200)]
Remove unneeded junit/mockito dependencies

This cleans up pom.xmls to not include unneded dependencies.

Change-Id: I9029bedcba58abaa5f6956a76b3e864650be3d90
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCleanup mockito deprecation 98/75098/1
Robert Varga [Fri, 10 Aug 2018 11:07:39 +0000 (13:07 +0200)]
Cleanup mockito deprecation

Migrate to new API.

Change-Id: Id824fa266ff31472d10a12909445083c3dc9f9ed
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoLoosen RpcResultBuilder argument 97/75097/2
Robert Varga [Fri, 10 Aug 2018 10:57:10 +0000 (12:57 +0200)]
Loosen RpcResultBuilder argument

withRpcErrors can accept a collection of any RpcError subclasses,
express that in the API contract.

Change-Id: I8f302874cb509474e3a974e3b4730338984eda78
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDo not use SchemaNodeIdentifierBuildNamespace prerequisites 72/73972/19
Robert Varga [Thu, 12 Jul 2018 09:26:35 +0000 (11:26 +0200)]
Do not use SchemaNodeIdentifierBuildNamespace prerequisites

Incremental lookups on ChildSchemaNodeNamespace allow us to react
to childen being created, hence we do not have an assumption that
the target node must be instantiated by someone else (like eager
instantiation).

This will also allow us better recovery if the target node is not
going to appear due to being disabled by if-feature.

JIRA: YANGTOOLS-694
Change-Id: Ibc05e18037bb85d42ed7123293e7f83f896aad5d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd NamespaceBehaviour.toString() 53/74953/1
Robert Varga [Wed, 8 Aug 2018 15:54:06 +0000 (17:54 +0200)]
Add NamespaceBehaviour.toString()

A toString() method aids debugging immensely, define some basic
implementations.

Change-Id: I69c6b0027d81ae3a7c6a9304129feef6453e2f1f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix yang-data-jaxen dependencies 62/74862/2
Robert Varga [Mon, 6 Aug 2018 14:32:51 +0000 (16:32 +0200)]
Fix yang-data-jaxen dependencies

We should depend on yang-data-impl for testing only.

Change-Id: Ib7028a1e44f504c08fe5a41707e2089d7d770f27
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRevert "Relax identity statement argument checks" 49/74849/2
Robert Varga [Mon, 6 Aug 2018 12:26:27 +0000 (14:26 +0200)]
Revert "Relax identity statement argument checks"

This reverts commit ea997a6251751745bb5553c8540313dda7fc4106.

Change-Id: I582b8a577f433c82a95944f819088e69936cde28
JIRA: YANGTOOLS-867
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoUse CheckUtil instead of CheckUtils 87/74687/8
Stephen Kitt [Tue, 31 Jul 2018 10:20:34 +0000 (12:20 +0200)]
Use CheckUtil instead of CheckUtils

In Checkstyle 8.11, CheckUtils became CheckUtil.

Change-Id: I9508d4893ca36b1f1ae3fc13d8715b23eb3a59df
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoSwitch to odl-guava feature 82/74682/7
Stephen Kitt [Tue, 31 Jul 2018 09:29:06 +0000 (11:29 +0200)]
Switch to odl-guava feature

Change-Id: I7bf4883e1a7a766a4d267f948ba2d6c901a12eac
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoBuild with Mockito 2.1 89/74589/11
Stephen Kitt [Fri, 27 Jul 2018 15:50:25 +0000 (17:50 +0200)]
Build with Mockito 2.1

This adjusts to Mockito changes, including most tests.

Change-Id: I75bea532168c68a4a468f2b41a458d40429ccbe8
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoUse odlparent-4.0.0-SNAPSHOT 64/74664/8
Robert Varga [Mon, 30 Jul 2018 17:27:35 +0000 (19:27 +0200)]
Use odlparent-4.0.0-SNAPSHOT

This is a pre-integration on snapshots, so we get a lookahead for
yangtools-2.1.x.

Change-Id: Iec981bbf6acc781beb6d63cf99cd0855dd3f5266
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMake empty augmentations disappear 93/74793/8
Robert Varga [Fri, 3 Aug 2018 09:13:53 +0000 (11:13 +0200)]
Make empty augmentations disappear

Augmentations are pure structural elements, which should disappear
when empty, as they have no semantic meaning.

JIRA: YANGTOOLS-585
Change-Id: I73d269e0da144180a455286420d35f1936434108
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMake empty lists and choices disappear 83/35583/40
Robert Varga [Tue, 31 Jul 2018 00:10:03 +0000 (02:10 +0200)]
Make empty lists and choices disappear

This achieves automatic lifecycle behavior, so that lists disappear
as soon as they have zero elements.

Bug4454 test is updated to account for the list disappearing under
normal operation.

JIRA: YANGTOOLS-585
Change-Id: I68220043c0f335324e5a8788b2872f57b750aae9
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump versions to 2.1.0-SNAPSHOT 00/74800/2
Robert Varga [Fri, 3 Aug 2018 13:01:45 +0000 (15:01 +0200)]
Bump versions to 2.1.0-SNAPSHOT

This starts the development of 2.1.x release train.

Change-Id: I9f369f7386291a8555ac66057f9d71f27b0ab68f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAllows to find child of Operation definition (RPC, Action) 48/74848/1
Jakub Tóth [Mon, 6 Aug 2018 11:43:58 +0000 (13:43 +0200)]
Allows to find child of Operation definition (RPC, Action)

Change-Id: Ie1048ed6d294a507cc90c65ded7dbfb6d8c6018f
Signed-off-by: Jakub Tóth <jakub.toth@pantheon.tech>
5 years agoMake sure we mark phase modification 06/74806/4
Robert Varga [Fri, 3 Aug 2018 18:23:46 +0000 (20:23 +0200)]
Make sure we mark phase modification

Once we resolve the target we need to paint it, so it does not
complete before our modification has had a chance to run.

JIRA: YANGTOOLS-859
Change-Id: I8b29a8eef4d01f8c02d13d759061e93c379029e5
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMigrate @Nullable annotation 07/74807/2
Robert Varga [Fri, 3 Aug 2018 18:32:07 +0000 (20:32 +0200)]
Migrate @Nullable annotation

Migrating the annotation fixes an eclipse warning.

Change-Id: I8a07c05e4bf0b61c5dfa2b0ba1d15bb0a7ae89e8
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoCentralize AugmentationIdentifier instantiation 94/74794/4
Robert Varga [Fri, 3 Aug 2018 09:58:08 +0000 (11:58 +0200)]
Centralize AugmentationIdentifier instantiation

We have duplicate code all over the place, centralize this in
DataSchemaContextNode.

Change-Id: Icb79740b3a113d0383d583403d48e9a5f427eb66
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRemove duplicate instantiation of EffectiveAugmentationSchema 92/74792/5
Robert Varga [Fri, 3 Aug 2018 09:34:53 +0000 (11:34 +0200)]
Remove duplicate instantiation of EffectiveAugmentationSchema

We have four independent call sites, doing the same thing. Unify
all the callers behind EffectiveAugmentationSchema.create().

Change-Id: Ib4e4202cd64cff15d35cf275afbba7c00f853121
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoMove search methods to NormalizedNodeContext 89/71789/14
Robert Varga [Mon, 30 Apr 2018 19:22:19 +0000 (21:22 +0200)]
Move search methods to NormalizedNodeContext

When we know we have a NormalizedNodeContext we can forgo bouncing
through the navigator to get a target node context. This simplifies
things a bit when we want to implement more complex logic.

This is not exactly extensible way of operation, but we know we will
only be evaluating on our context.

Change-Id: Ib8bea239f3193c54d3eacab903c75f9d43aee4e2
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd yang-xpath-impl 73/71973/23
Robert Varga [Wed, 9 May 2018 18:54:22 +0000 (20:54 +0200)]
Add yang-xpath-impl

This adds an antlr-based XPath parser, which results in
yang-xpath-api expressions.

The grammar file (xpath.g4) is taken from
https://github.com/antlr/grammars-v4/blob/master/xpath/xpath.g4
at commit a3ff48932b0168d93d184a988fa40723b60f6c27.

JIRA: YANGTOOLS-877
Change-Id: Ic7cfdb2d8d132577840f910786f72ed75b17c79e
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix LeafRefContext for relative refs defined in external grouping 30/74630/2
Marek Gradzki [Mon, 30 Jul 2018 06:45:29 +0000 (08:45 +0200)]
Fix LeafRefContext for relative refs defined in external grouping

LeafRefPathParserListenerImpl builds LeafRefPath
using namespace of the module which contains leafref definition.

While it is valid approach for absolute paths with prefix (YANGTOOLS-749),
it cannot be used with groupings, because they are bound to namespace
when contents of the grouping is added to the schema tree.

This patch fixes the relative path case
by using the module which uses leafref.

JIRA: YANGTOOLS-891
Change-Id: Ia903138f80c437937374eb7d3460fdbe8b2a97c2
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
5 years agoJaxen binding should use DataSchemaContextTree 28/71528/12
Robert Varga [Fri, 27 Apr 2018 20:46:32 +0000 (22:46 +0200)]
Jaxen binding should use DataSchemaContextTree

Context tree is a simple structure which allows traversal of nodes
in the order of NormalizedNodes in a strictly-forward way.

This allows us to not muck with SchemaContext when we need to look
up our SchemaNode, as it is readily available.

Change-Id: Ic6c67c1e064ffe74433debd4f1a63e24a8571791
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd yang-xpath-api 18/71818/20
Robert Varga [Fri, 4 May 2018 21:46:12 +0000 (23:46 +0200)]
Add yang-xpath-api

This patch adds the basic model of a YANG-extended XPath 1.0
expression.

JIRA: YANGTOOLS-877
Change-Id: Id5f619e6acd956b7b43f9faba75f34051e3dc509
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoUpdate toString() encapsulation 37/74737/1
Robert Varga [Wed, 1 Aug 2018 12:40:43 +0000 (14:40 +0200)]
Update toString() encapsulation

Since we do not know the contents/format of toString() return,
make sure we bracket it.

Change-Id: Id552bb59bf3beb62548d5860ab9abe2db062bf80
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoPropagate delegate.toString() as symbolic name 27/74727/1
Robert Varga [Wed, 1 Aug 2018 10:31:22 +0000 (12:31 +0200)]
Propagate delegate.toString() as symbolic name

With use of delegated ByteSources we are losing location of the
source, as there is no symbolic name being filled in.

Change-Id: Ie53207ca3af13de49a8b45d11b78ebb828145e66
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRework identifier path subscription 94/74694/4
Robert Varga [Tue, 31 Jul 2018 13:21:19 +0000 (15:21 +0200)]
Rework identifier path subscription

Rather than creating multiple prerequisites, define the logic
inside a dedicated class, which gets reused.

JIRA: YANGTOOLS-859
Change-Id: I25259bd4571bc684b0f25d9d058efd5ff1d7798b
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAvoid depending on immutables.value at runtime 83/74683/2
Stephen Kitt [Tue, 31 Jul 2018 09:29:37 +0000 (11:29 +0200)]
Avoid depending on immutables.value at runtime

Change-Id: I7e4ffea6b51523341e46380c3754d788f676a664
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoIntroduce map-related ImmutableNodes operations 72/74672/6
Robert Varga [Mon, 30 Jul 2018 22:23:52 +0000 (00:23 +0200)]
Introduce map-related ImmutableNodes operations

These will come in handy for creating empty lists.

JIRA: YANGTOOLS-585
Change-Id: I3173baa03d540196caf50312652dba1876b8b1b9
Signed-off-by: Maros Marsalek <mmarsale@cisco.com>
Signed-off-by: Igor Foltin <ifoltin@cisco.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoExpand CompatUtils to handle leaf-lists 23/74623/2
Robert Varga [Mon, 30 Jul 2018 05:21:55 +0000 (07:21 +0200)]
Expand CompatUtils to handle leaf-lists

The rules outlined in compatLeafType are applicable to leaf-lists,
too. Allow leaf-list types to be queried by adding a TypedDataSchemaNode
variant as compatType().

Change-Id: Ia6a3e4cf198069137c470008fde934de64b96996
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoUpdate CursorAwareDataTree{Modification,Snapshot} API 05/74605/2
Robert Varga [Sat, 28 Jul 2018 08:26:56 +0000 (10:26 +0200)]
Update CursorAwareDataTree{Modification,Snapshot} API

Create an explicit openCursor() method and return Optional instead
of a Nullable.

Change-Id: I6a9f11726f85acb86e6aaf30b7ede12b8420da37
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoBump versions for next version 71/74371/1
Robert Varga [Tue, 24 Jul 2018 08:07:28 +0000 (10:07 +0200)]
Bump versions for next version

Bumps versions to 2.0.10/1.0.10-SNAPSHOT.

Change-Id: I8ff720c54951498aa81dc3dc6f10fe40a039e23c
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoFix LeafRefValidatation for refs defined in augmentations 38/74338/2
Marek Gradzki [Tue, 17 Jul 2018 12:09:23 +0000 (14:09 +0200)]
Fix LeafRefValidatation for refs defined in augmentations

LeafRefValidatation.validateNodeData traverses
children of a NormalizedNode
that contain leafrefs or are leafrefs' targets.

Information about referencing nodes and nodes being referenced
is stored in LeafRefContext under QName key.

But AugmentationNode has no QName, so validation was failing
with UnsupportedOperationException.

As a fix, validateNodeData is recursively invoked on AugmentationNode,
to fall into DataContainerNode case.

JIRA: YANGTOOLS-821
Change-Id: I5de7c814f0abe0aec31cced24ea09692bd63a584
Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
5 years agoBump to odlparent 3.1.3 34/74234/1
Stephen Kitt [Thu, 19 Jul 2018 12:56:35 +0000 (14:56 +0200)]
Bump to odlparent 3.1.3

Change-Id: I9bdc0215beda398b989bce092df37f3a84f9105a
Signed-off-by: Stephen Kitt <skitt@redhat.com>
5 years agoBump to next development version 72/74072/1
Robert Varga [Mon, 16 Jul 2018 16:42:21 +0000 (18:42 +0200)]
Bump to next development version

This bumps artifacts 2.0.9/1.0.9-SNAPSHOT.

Change-Id: Ifb1d79ee70e02545b025d2929af7eead9f8958f3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoRefactor YangFunctionContext 58/74058/5
Robert Varga [Mon, 16 Jul 2018 08:04:04 +0000 (10:04 +0200)]
Refactor YangFunctionContext

This fixes code duplication, making sonar happy.

Change-Id: I068b46d654d8f8df378fda7434eb97fba6b8e92f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd AbstractEffectiveOperationContainerSchemaNode 60/74060/4
Robert Varga [Mon, 16 Jul 2018 08:47:32 +0000 (10:47 +0200)]
Add AbstractEffectiveOperationContainerSchemaNode

InputEffectiveStatementImpl and OutputEffectiveStatementImpl are
pretty much exactly the same, add a common superclass to hold their
implementation.

Change-Id: I1b7b174a006da8430f233a1ac43591cdf6563912
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoIntroduce AbstractEffectiveOperationDefinition 59/74059/4
Robert Varga [Mon, 16 Jul 2018 08:35:38 +0000 (10:35 +0200)]
Introduce AbstractEffectiveOperationDefinition

RpcEffectiveStatementImpl and ActionEffectiveStatementImpl share
most of their implementation, extract it into a common class --
AbstractEffectiveOperationDefinition

Change-Id: I8ef70d065a0f5c667843613a2df939ce4a5fb5b3
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoDeclaredStatements can contain default implementations 54/74054/8
Robert Varga [Sun, 15 Jul 2018 23:51:59 +0000 (01:51 +0200)]
DeclaredStatements can contain default implementations

This eliminates code duplication in implementations, hence is useful
to centralize as a default method.

Change-Id: Icbb1c23018d0104d2e86cb309063b6f924b35337
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd ConfigStatementContainerDeclaredStatement 53/74053/2
Robert Varga [Sun, 15 Jul 2018 23:38:16 +0000 (01:38 +0200)]
Add ConfigStatementContainerDeclaredStatement

The missing link between ConfigContainerStatement and DeclaredStatement
is filled in, providing a default implementation getConfig().

Change-Id: Icc9c65b0d74bcb0a8a8d1db13514c3ffca86038d
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoAdd DeclaredStatement utility methods 52/74052/1
Robert Varga [Sun, 15 Jul 2018 23:17:09 +0000 (01:17 +0200)]
Add DeclaredStatement utility methods

Effective and Declared statements should share utility methods,
hence update DeclaredStatement to include them.

Change-Id: Ifb9a2b4aedd41ef93c02995e99dc51897dc57db1
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
5 years agoYANGTOOLS-890 - Fix XML parser bug 33/73933/4
Michal Cmarada [Wed, 11 Jul 2018 15:18:59 +0000 (17:18 +0200)]
YANGTOOLS-890 - Fix XML parser bug

When model contains list which has the same name as its
encapsulating parent container it leads to
IllegalStateException: Attributes can be extracted only
from START_ELEMENT. This is caused by list not beeing
processed correctly and one additional empty list item
is created. To fix this it is necessary to end the loop
when end list element is reached.

Change-Id: I0d6f6ec356e503fcfc941f18d9133ea0c9cebc6c
Signed-off-by: Michal Cmarada <michal.cmarada@pantheon.tech>