|
| 1 | +/* |
| 2 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 3 | + * you may not use this file except in compliance with the License. |
| 4 | + * You may obtain a copy of the License at |
| 5 | + * |
| 6 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 7 | + * |
| 8 | + * Unless required by applicable law or agreed to in writing, software |
| 9 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 10 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 11 | + * See the License for the specific language governing permissions and |
| 12 | + * limitations under the License. |
| 13 | + */ |
| 14 | +package com.facebook.presto.common.function; |
| 15 | + |
| 16 | +import com.facebook.presto.common.type.TimeZoneKey; |
| 17 | +import org.testng.annotations.Test; |
| 18 | + |
| 19 | +import java.util.Collections; |
| 20 | +import java.util.Locale; |
| 21 | +import static org.testng.Assert.assertEquals; |
| 22 | +import static org.testng.Assert.assertNotEquals; |
| 23 | + |
| 24 | +public class TestSqlFunctionProperties |
| 25 | +{ |
| 26 | + @Test |
| 27 | + public void testEquals_SameProperties() { |
| 28 | + SqlFunctionProperties properties1 = SqlFunctionProperties.builder() |
| 29 | + .setParseDecimalLiteralAsDouble(true) |
| 30 | + .setLegacyRowFieldOrdinalAccessEnabled(false) |
| 31 | + .setTimeZoneKey(TimeZoneKey.UTC_KEY) |
| 32 | + .setLegacyTimestamp(false) |
| 33 | + .setLegacyMapSubscript(false) |
| 34 | + .setSessionStartTime(123456789L) |
| 35 | + .setSessionLocale(Locale.US) |
| 36 | + .setSessionUser("user1") |
| 37 | + .setFieldNamesInJsonCastEnabled(true) |
| 38 | + .setLegacyJsonCast(false) |
| 39 | + .setExtraCredentials(Collections.singletonMap("key", "value")) |
| 40 | + .setWarnOnCommonNanPatterns(false) |
| 41 | + .setCanonicalizedJsonExtract(true) |
| 42 | + .build(); |
| 43 | + SqlFunctionProperties properties2 = SqlFunctionProperties.builder() |
| 44 | + .setParseDecimalLiteralAsDouble(true) |
| 45 | + .setLegacyRowFieldOrdinalAccessEnabled(false) |
| 46 | + .setTimeZoneKey(TimeZoneKey.UTC_KEY) |
| 47 | + .setLegacyTimestamp(false) |
| 48 | + .setLegacyMapSubscript(false) |
| 49 | + .setSessionStartTime(123456789L) |
| 50 | + .setSessionLocale(Locale.US) |
| 51 | + .setSessionUser("user1") |
| 52 | + .setFieldNamesInJsonCastEnabled(true) |
| 53 | + .setLegacyJsonCast(false) |
| 54 | + .setExtraCredentials(Collections.singletonMap("key", "value")) |
| 55 | + .setWarnOnCommonNanPatterns(false) |
| 56 | + .setCanonicalizedJsonExtract(true) |
| 57 | + .build(); |
| 58 | + assertEquals(properties1, properties2); |
| 59 | + } |
| 60 | + @Test |
| 61 | + public void testEquals_DifferentProperties() { |
| 62 | + SqlFunctionProperties properties1 = SqlFunctionProperties.builder() |
| 63 | + .setParseDecimalLiteralAsDouble(true) |
| 64 | + .setLegacyRowFieldOrdinalAccessEnabled(false) |
| 65 | + .setTimeZoneKey(TimeZoneKey.UTC_KEY) |
| 66 | + .setLegacyTimestamp(false) |
| 67 | + .setLegacyMapSubscript(false) |
| 68 | + .setSessionStartTime(123456789L) |
| 69 | + .setSessionLocale(Locale.US) |
| 70 | + .setSessionUser("user1") |
| 71 | + .setFieldNamesInJsonCastEnabled(true) |
| 72 | + .setLegacyJsonCast(false) |
| 73 | + .setExtraCredentials(Collections.singletonMap("key", "value")) |
| 74 | + .setWarnOnCommonNanPatterns(false) |
| 75 | + .setCanonicalizedJsonExtract(true) |
| 76 | + .build(); |
| 77 | + SqlFunctionProperties properties2 = SqlFunctionProperties.builder() |
| 78 | + .setParseDecimalLiteralAsDouble(true) |
| 79 | + .setLegacyRowFieldOrdinalAccessEnabled(false) |
| 80 | + .setTimeZoneKey(TimeZoneKey.UTC_KEY) |
| 81 | + .setLegacyTimestamp(false) |
| 82 | + .setLegacyMapSubscript(false) |
| 83 | + .setSessionStartTime(123456789L) |
| 84 | + .setSessionLocale(Locale.US) |
| 85 | + .setSessionUser("user1") |
| 86 | + .setFieldNamesInJsonCastEnabled(true) |
| 87 | + .setLegacyJsonCast(false) |
| 88 | + .setExtraCredentials(Collections.singletonMap("key", "value")) |
| 89 | + .setWarnOnCommonNanPatterns(false) |
| 90 | + .setCanonicalizedJsonExtract(false) // Different value |
| 91 | + .build(); |
| 92 | + assertNotEquals(properties1, properties2); |
| 93 | + } |
| 94 | +} |
0 commit comments