raminqaf commented on code in PR #29674: URL: https://github.com/apache/flink/pull/29674#discussion_r4525814675
########## flink-table/flink-table-common/src/test/java/org/apache/flink/table/catalog/StartModeTest.java: ########## @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.flink.table.catalog; + +import org.apache.flink.table.api.ValidationException; +import org.apache.flink.table.catalog.Interval.TimeUnit; + +import org.junit.jupiter.api.Test; + +import java.time.Duration; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +/** Tests for {@link StartMode}. */ +class StartModeTest { + + @Test + void offsetMustBeAPositiveWholeNumberOfSecondsThatFitsAnInt() { + assertThat(StartMode.fromNow(Duration.ofSeconds(Integer.MAX_VALUE)).getInterval()) + .isEqualTo(Interval.of(Integer.MAX_VALUE, TimeUnit.SECOND)); + + assertThatThrownBy(() -> StartMode.fromNow(Duration.ZERO)) + .isInstanceOf(ValidationException.class) + .hasMessage("The start mode offset must be positive, but was: PT0S."); + assertThatThrownBy(() -> StartMode.resumeOrFromNow(Duration.ofSeconds(-1))) + .isInstanceOf(ValidationException.class) + .hasMessage("The start mode offset must be positive, but was: PT-1S."); + assertThatThrownBy(() -> StartMode.resumeOrFromNow(Duration.ofMillis(1500))) + .isInstanceOf(ValidationException.class) + .hasMessage( + "The start mode offset must be a whole number of seconds, but was: PT1.5S."); + assertThatThrownBy(() -> StartMode.fromNow(Duration.ofSeconds(Integer.MAX_VALUE + 1L))) + .isInstanceOf(ValidationException.class) + .hasMessage( + "The start mode offset must be at most 2147483647 seconds, but was: PT596523H14M8S."); + } Review Comment: I would rename this test and make it parasitized. We can have one tests that checks fromNow with Integer.MAX_VLAUE in seconds. and one CSVSource for the failed tests. ``` @CsvSource( delimiter = '|', value = { "PT0S | The start mode offset must be positive, but was: PT0S.", "PT-1S | The start mode offset must be positive, but was: PT-1S.", "PT1.5S | The start mode offset must be a whole number of seconds, but was: PT1.5S.", "PT2147483648S | The start mode offset must be at most 2147483647 seconds, but was: PT596523H14M8S." }) ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
