Skip to content

Commit

Permalink
Fix test cases (#28922)
Browse files Browse the repository at this point in the history
* Refactor DumperConfiguration

* Refactor DumperConfiguration

* Refactor DumperConfiguration

* Refactor DumperConfiguration

* Fix test case

* Fix test case

* Fix test case
  • Loading branch information
terrymanu authored Nov 2, 2023
1 parent e664f0e commit 0de4f9b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -129,15 +129,15 @@ private List<PipelineColumnMetaData> mockOrderColumnsMetaDataList() {

@Test
void assertWriteRowsEventWithoutCustomColumns() throws ReflectiveOperationException {
assertWriteRowsEvent0(null, 3);
assertWriteRowsEvent0(Collections.emptyMap(), 3);
}

@Test
void assertWriteRowsEventWithCustomColumns() throws ReflectiveOperationException {
assertWriteRowsEvent0(mockTargetTableColumnsMap(), 1);
}

private void assertWriteRowsEvent0(final Map<LogicTableName, Set<ColumnName>> targetTableColumnsMap, final int expectedColumnCount) throws ReflectiveOperationException {
private void assertWriteRowsEvent0(final Map<LogicTableName, Collection<ColumnName>> targetTableColumnsMap, final int expectedColumnCount) throws ReflectiveOperationException {
dumperConfig.setTargetTableColumnsMap(targetTableColumnsMap);
WriteRowsEvent rowsEvent = new WriteRowsEvent();
rowsEvent.setDatabaseName("");
Expand All @@ -151,21 +151,21 @@ private void assertWriteRowsEvent0(final Map<LogicTableName, Set<ColumnName>> ta
assertThat(((DataRecord) actual.get(0)).getColumnCount(), is(expectedColumnCount));
}

private Map<LogicTableName, Set<ColumnName>> mockTargetTableColumnsMap() {
private Map<LogicTableName, Collection<ColumnName>> mockTargetTableColumnsMap() {
return Collections.singletonMap(new LogicTableName("t_order"), Collections.singleton(new ColumnName("order_id")));
}

@Test
void assertUpdateRowsEventWithoutCustomColumns() throws ReflectiveOperationException {
assertUpdateRowsEvent0(null, 3);
assertUpdateRowsEvent0(Collections.emptyMap(), 3);
}

@Test
void assertUpdateRowsEventWithCustomColumns() throws ReflectiveOperationException {
assertUpdateRowsEvent0(mockTargetTableColumnsMap(), 1);
}

private void assertUpdateRowsEvent0(final Map<LogicTableName, Set<ColumnName>> targetTableColumnsMap, final int expectedColumnCount) throws ReflectiveOperationException {
private void assertUpdateRowsEvent0(final Map<LogicTableName, Collection<ColumnName>> targetTableColumnsMap, final int expectedColumnCount) throws ReflectiveOperationException {
dumperConfig.setTargetTableColumnsMap(targetTableColumnsMap);
UpdateRowsEvent rowsEvent = new UpdateRowsEvent();
rowsEvent.setDatabaseName("test");
Expand All @@ -182,15 +182,15 @@ private void assertUpdateRowsEvent0(final Map<LogicTableName, Set<ColumnName>> t

@Test
void assertDeleteRowsEventWithoutCustomColumns() throws ReflectiveOperationException {
assertDeleteRowsEvent0(null, 3);
assertDeleteRowsEvent0(Collections.emptyMap(), 3);
}

@Test
void assertDeleteRowsEventWithCustomColumns() throws ReflectiveOperationException {
assertDeleteRowsEvent0(mockTargetTableColumnsMap(), 1);
}

private void assertDeleteRowsEvent0(final Map<LogicTableName, Set<ColumnName>> targetTableColumnsMap, final int expectedColumnCount) throws ReflectiveOperationException {
private void assertDeleteRowsEvent0(final Map<LogicTableName, Collection<ColumnName>> targetTableColumnsMap, final int expectedColumnCount) throws ReflectiveOperationException {
dumperConfig.setTargetTableColumnsMap(targetTableColumnsMap);
DeleteRowsEvent rowsEvent = new DeleteRowsEvent();
rowsEvent.setDatabaseName("");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private List<PipelineColumnMetaData> mockOrderColumnsMetaDataList() {

@Test
void assertWriteRowEventWithoutCustomColumns() throws ReflectiveOperationException {
assertWriteRowEvent0(null, 3);
assertWriteRowEvent0(Collections.emptyMap(), 3);
}

@Test
Expand Down

0 comments on commit 0de4f9b

Please sign in to comment.