|
| 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 io.trino.spi.connector; |
| 15 | + |
| 16 | +import com.google.common.collect.ImmutableMap; |
| 17 | +import org.junit.jupiter.api.Test; |
| 18 | + |
| 19 | +import java.util.Optional; |
| 20 | + |
| 21 | +import static io.trino.spi.type.IntegerType.INTEGER; |
| 22 | +import static org.assertj.core.api.Assertions.assertThat; |
| 23 | + |
| 24 | +class TestColumnMetadata |
| 25 | +{ |
| 26 | + @Test |
| 27 | + public void testBuilderFrom() |
| 28 | + { |
| 29 | + ColumnMetadata originColumnMetadata = ColumnMetadata.builder() |
| 30 | + .setName("test_column") |
| 31 | + .setType(INTEGER) |
| 32 | + .setDefaultValue(Optional.of("1")) |
| 33 | + .setNullable(false) |
| 34 | + .setComment(Optional.ofNullable("test_comment")) |
| 35 | + .setExtraInfo(Optional.of("test_extra_info")) |
| 36 | + .setHidden(false) |
| 37 | + .setProperties(ImmutableMap.of("test_key", "test_value")) |
| 38 | + .build(); |
| 39 | + |
| 40 | + ColumnMetadata buildColumnMetadata = ColumnMetadata.builderFrom(originColumnMetadata).build(); |
| 41 | + |
| 42 | + assertThat(buildColumnMetadata).isEqualTo(originColumnMetadata); |
| 43 | + assertThat(buildColumnMetadata.getDefaultValue()).isEqualTo(originColumnMetadata.getDefaultValue()); |
| 44 | + assertThat(buildColumnMetadata.getProperties()).isEqualTo(originColumnMetadata.getProperties()); |
| 45 | + } |
| 46 | +} |
0 commit comments