From 9dbfb75bafbfbb390ae06392e85f49bc4210e9f6 Mon Sep 17 00:00:00 2001 From: Robin Friedmann Date: Mon, 5 Feb 2024 11:12:15 +0100 Subject: [PATCH] Implement unit tests for FilterPathTests (#12067) Signed-off-by: Robin Friedmann --- .../xcontent/filtering/FilterPathTests.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libs/core/src/test/java/org/opensearch/core/xcontent/filtering/FilterPathTests.java b/libs/core/src/test/java/org/opensearch/core/xcontent/filtering/FilterPathTests.java index 0c5a17b70a956..a48c03300c781 100644 --- a/libs/core/src/test/java/org/opensearch/core/xcontent/filtering/FilterPathTests.java +++ b/libs/core/src/test/java/org/opensearch/core/xcontent/filtering/FilterPathTests.java @@ -32,6 +32,7 @@ package org.opensearch.core.xcontent.filtering; +import java.util.HashSet; import org.opensearch.common.util.set.Sets; import org.opensearch.test.OpenSearchTestCase; @@ -369,4 +370,20 @@ public void testMultipleFilterPaths() { assertThat(filterPath.getSegment(), is(emptyString())); assertSame(filterPath, FilterPath.EMPTY); } + + public void testCompileWithEmptyString() { + Set filters = new HashSet<>(); + filters.add(""); + FilterPath[] filterPaths = FilterPath.compile(filters); + assertNotNull(filterPaths); + assertEquals(0, filterPaths.length); + } + + public void testCompileWithNull() { + Set filters = new HashSet<>(); + filters.add(null); + FilterPath[] filterPaths = FilterPath.compile(filters); + assertNotNull(filterPaths); + assertEquals(0, filterPaths.length); + } }