From 309d5e1561ba42ee491fa33c3b8c24849dc003fa Mon Sep 17 00:00:00 2001 From: Jan Srnicek Date: Tue, 21 Feb 2017 10:41:17 +0100 Subject: Resource nullability check for test runner checks if provided resource path was found Change-Id: I86ed1b6f38bc8f48fd12ebe8620831862840ed11 Signed-off-by: Jan Srnicek --- .../java/io/fd/honeycomb/test/tools/ContainerNodeDataProcessor.java | 2 ++ .../main/java/io/fd/honeycomb/test/tools/ListNodeDataProcessor.java | 3 +++ 2 files changed, 5 insertions(+) diff --git a/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/ContainerNodeDataProcessor.java b/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/ContainerNodeDataProcessor.java index 089bb43cd..b7641e01d 100644 --- a/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/ContainerNodeDataProcessor.java +++ b/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/ContainerNodeDataProcessor.java @@ -48,6 +48,8 @@ final class ContainerNodeDataProcessor extends AbstractYangContextHolder impleme public DataObject getNodeData(@Nonnull YangInstanceIdentifier yangInstanceIdentifier, @Nonnull String resourcePath) { final InputStream resourceStream = this.getClass().getResourceAsStream(resourcePath); + checkState(resourceStream != null, "Resource %s not found", resourcePath); + final YangInstanceIdentifier nodeParent = getNodeParent(yangInstanceIdentifier).orElse(null); final SchemaNode parentSchema = parentSchema(schemaContext(), serializer(), nodeParent, () -> LOG); diff --git a/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/ListNodeDataProcessor.java b/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/ListNodeDataProcessor.java index 375f55307..c14ea354e 100644 --- a/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/ListNodeDataProcessor.java +++ b/infra/test-utils/test-tools/src/main/java/io/fd/honeycomb/test/tools/ListNodeDataProcessor.java @@ -30,6 +30,7 @@ import javax.annotation.Nonnull; import java.io.InputStream; import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkState; import static io.fd.honeycomb.translate.util.JsonUtils.readListEntryFromJson; /** @@ -52,6 +53,8 @@ final class ListNodeDataProcessor extends AbstractYangContextHolder implements Y final YangInstanceIdentifier listParent = listNodeParent(nodeIdentifier); final YangInstanceIdentifier.NodeIdentifierWithPredicates keyedNodeIdentifier = listNodeIdentifier(nodeIdentifier); final InputStream resourceStream = this.getClass().getResourceAsStream(resourcePath); + checkState(resourceStream != null, "Resource %s not found", resourcePath); + final SchemaNode parentSchemaNode = parentSchema(schemaContext(), serializer(), listParent, () -> LOG); final MapEntryNode data = readListEntryFromJson(schemaContext(), resourceStream, parentSchemaNode, keyedNodeIdentifier); -- cgit 1.2.3-korg