From f15aed916c69b0766c7bed2dc7fe534f48b97ac9 Mon Sep 17 00:00:00 2001 From: Maros Marsalek Date: Thu, 14 Jul 2016 10:41:49 +0200 Subject: HONEYCOMB-122: Reader registry integration tests Add IT test for read infrastructure + some additional unit tests + Make Read/Write Factory autoCloseable Change-Id: I6eab8e6df2c2132af01cea0a9c4b9bece7dc9b74 Signed-off-by: Maros Marsalek --- .../io/fd/honeycomb/v3po/translate/util/RWUtils.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java') diff --git a/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java index ba9d8e16f..2a565d9f2 100644 --- a/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java +++ b/v3po/translate-utils/src/main/java/io/fd/honeycomb/v3po/translate/util/RWUtils.java @@ -117,7 +117,7 @@ public final class RWUtils { } /** - * Create a map from a collection, checking for duplicity in the process + * Create an ordered map from a collection, checking for duplicity in the process. */ @Nonnull public static Map uniqueLinkedIndex(@Nonnull final Collection values, @Nonnull final Function keyFunction) { @@ -152,6 +152,9 @@ public final class RWUtils { /** * Transform a keyed instance identifier into a wildcarded one. + *

+ * ! This has to be called also for wildcarded List instance identifiers + * due to weird behavior of equals in InstanceIdentifier ! */ @SuppressWarnings("unchecked") public static InstanceIdentifier makeIidWildcarded(final InstanceIdentifier id) { @@ -162,6 +165,19 @@ public final class RWUtils { return (InstanceIdentifier) InstanceIdentifier.create(transformedPathArguments); } + /** + * Transform a keyed instance identifier into a wildcarded one, keeping keys except the last item. + */ + @SuppressWarnings("unchecked") + public static InstanceIdentifier makeIidLastWildcarded(final InstanceIdentifier id) { + final InstanceIdentifier.Item wildcardedItem = new InstanceIdentifier.Item<>(id.getTargetType()); + final Iterable pathArguments = id.getPathArguments(); + return (InstanceIdentifier) InstanceIdentifier.create( + Iterables.concat( + Iterables.limit(pathArguments, Iterables.size(pathArguments) - 1), + Collections.singleton(wildcardedItem))); + } + private static InstanceIdentifier.PathArgument cleanPathArgumentFromKeys(final InstanceIdentifier.PathArgument pathArgument) { return pathArgument instanceof InstanceIdentifier.IdentifiableItem ? new InstanceIdentifier.Item<>(pathArgument.getType()) -- cgit 1.2.3-korg