|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +package org.apache.paimon.predicate; |
| 20 | + |
| 21 | +import org.apache.paimon.data.BinaryString; |
| 22 | +import org.apache.paimon.data.GenericRow; |
| 23 | + |
| 24 | +import org.junit.jupiter.api.Test; |
| 25 | + |
| 26 | +import java.util.ArrayList; |
| 27 | +import java.util.List; |
| 28 | + |
| 29 | +import static org.assertj.core.api.Assertions.assertThat; |
| 30 | +import static org.assertj.core.api.Assertions.assertThatThrownBy; |
| 31 | + |
| 32 | +class UpperTransformTest { |
| 33 | + |
| 34 | + @Test |
| 35 | + public void testNullInputs() { |
| 36 | + List<Object> inputs = new ArrayList<>(); |
| 37 | + inputs.add(null); |
| 38 | + UpperTransform transform = new UpperTransform(inputs); |
| 39 | + Object result = transform.transform(GenericRow.of()); |
| 40 | + assertThat(result).isNull(); |
| 41 | + } |
| 42 | + |
| 43 | + @Test |
| 44 | + public void testNormalInputs() { |
| 45 | + List<Object> inputs = new ArrayList<>(); |
| 46 | + inputs.add(BinaryString.fromString("hello")); |
| 47 | + UpperTransform transform = new UpperTransform(inputs); |
| 48 | + Object result = transform.transform(GenericRow.of()); |
| 49 | + assertThat(result).isEqualTo(BinaryString.fromString("HELLO")); |
| 50 | + } |
| 51 | + |
| 52 | + @Test |
| 53 | + public void testIllegalInputs() { |
| 54 | + List<Object> inputs = new ArrayList<>(); |
| 55 | + inputs.add(BinaryString.fromString("hello")); |
| 56 | + inputs.add(BinaryString.fromString("hi")); |
| 57 | + assertThatThrownBy(() -> new UpperTransform(inputs)) |
| 58 | + .isInstanceOf(IllegalArgumentException.class); |
| 59 | + } |
| 60 | +} |
0 commit comments