From e5c27c9ae1844ff28182c5f253cd9e8858a1805d Mon Sep 17 00:00:00 2001 From: Kartik Ganesh Date: Fri, 22 Apr 2022 15:52:15 -0700 Subject: [PATCH] Added basic unit tests for the FeatureFlags utility class Signed-off-by: Kartik Ganesh --- .../common/util/FeatureFlagTests.java | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 server/src/test/java/org/opensearch/common/util/FeatureFlagTests.java diff --git a/server/src/test/java/org/opensearch/common/util/FeatureFlagTests.java b/server/src/test/java/org/opensearch/common/util/FeatureFlagTests.java new file mode 100644 index 0000000000000..7f416c233080e --- /dev/null +++ b/server/src/test/java/org/opensearch/common/util/FeatureFlagTests.java @@ -0,0 +1,26 @@ +/* + * SPDX-License-Identifier: Apache-2.0 + * + * The OpenSearch Contributors require contributions made to + * this file be licensed under the Apache-2.0 license or a + * compatible open source license. + */ + +package org.opensearch.common.util; + +import org.opensearch.test.OpenSearchTestCase; + +public class FeatureFlagTests extends OpenSearchTestCase { + + public void testMissingFeatureFlag() { + String testFlag = "missingFeatureFlag"; + assertNull(System.getProperty(testFlag)); + assertFalse(FeatureFlags.isEnabled(testFlag)); + } + + public void testNonBooleanFeatureFlag() { + String javaVersionProperty = "java.version"; + assertNotNull(System.getProperty(javaVersionProperty)); + assertFalse(FeatureFlags.isEnabled(javaVersionProperty)); + } +}