Skip to content

Commit e004410

Browse files
authored
[FLINK-37671] Fix ChangelogMode#toString (#26452)
1 parent 795fcbe commit e004410

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

Diff for: flink-table/flink-table-common/src/main/java/org/apache/flink/table/connector/ChangelogMode.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public String toString() {
149149
return kinds.toString();
150150
} else {
151151
return kinds.stream()
152-
.map(kind -> kind == RowKind.DELETE ? "~D" : kind.toString())
152+
.map(kind -> kind == RowKind.DELETE ? "~DELETE" : kind.toString())
153153
.collect(Collectors.joining(", ", "[", "]"));
154154
}
155155
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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.flink.table.connector;
20+
21+
import org.apache.flink.types.RowKind;
22+
23+
import org.junit.jupiter.params.ParameterizedTest;
24+
import org.junit.jupiter.params.provider.Arguments;
25+
import org.junit.jupiter.params.provider.MethodSource;
26+
27+
import java.util.stream.Stream;
28+
29+
import static org.assertj.core.api.Assertions.assertThat;
30+
31+
/** Tests for base methods of {@link ChangelogMode}. */
32+
class ChangelogModeTest {
33+
34+
public static Stream<Arguments> toStringParams() {
35+
return Stream.of(
36+
Arguments.of(ChangelogMode.upsert(), "[INSERT, UPDATE_AFTER, ~DELETE]"),
37+
Arguments.of(ChangelogMode.upsert(false), "[INSERT, UPDATE_AFTER, DELETE]"),
38+
Arguments.of(ChangelogMode.insertOnly(), "[INSERT]"),
39+
Arguments.of(ChangelogMode.all(), "[INSERT, UPDATE_BEFORE, UPDATE_AFTER, DELETE]"),
40+
Arguments.of(
41+
ChangelogMode.newBuilder()
42+
.addContainedKind(RowKind.INSERT)
43+
.addContainedKind(RowKind.UPDATE_BEFORE)
44+
.addContainedKind(RowKind.UPDATE_AFTER)
45+
.addContainedKind(RowKind.DELETE)
46+
.keyOnlyDeletes(true)
47+
.build(),
48+
"[INSERT, UPDATE_BEFORE, UPDATE_AFTER, ~DELETE]"));
49+
}
50+
51+
@ParameterizedTest
52+
@MethodSource("toStringParams")
53+
void testToString(ChangelogMode mode, String expected) {
54+
assertThat(mode.toString()).isEqualTo(expected);
55+
}
56+
}

0 commit comments

Comments
 (0)