Skip to content

Commit

Permalink
resolve test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
renliangyu857 committed Nov 1, 2022
1 parent 0dcf6b4 commit 19f5995
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Expand Up @@ -290,7 +290,7 @@ public String buildImageSQL(TableMeta tableMeta) {
paramAppenderList = new ArrayList<>();
}
SQLInsertRecognizer recognizer = (SQLInsertRecognizer) sqlRecognizer;
int insertNum = recognizer.getInsertParamsValue().size();
int insertNum = recognizer.getInsertRows(getPkIndex().values()).size();
Map<String, ArrayList<Object>> imageParameterMap = buildImageParameters(recognizer);
String prefix = "SELECT * ";
StringBuilder suffix = new StringBuilder(" FROM ").append(getFromTableInSQL());
Expand Down
Expand Up @@ -105,10 +105,11 @@ public void TestBuildImageParameters(){
public void TestBuildImageParameters_contain_constant(){
mockImageParameterMap_contain_constant();
List<List<Object>> insertRows = new ArrayList<>();
insertRows.add(Arrays.asList("?,?,?,userStatus1"));
insertRows.add(Arrays.asList("?,?,?,userStatus2"));
insertRows.add(Arrays.asList("?","?","?","userStatus1"));
insertRows.add(Arrays.asList("?","?","?","userStatus2"));
when(sqlInsertRecognizer.getInsertRows(pkIndexMap.values())).thenReturn(insertRows);
mockInsertColumns();
doReturn(pkIndexMap).when(insertOrUpdateExecutor).getPkIndex();
Map<String, ArrayList<Object>> imageParameterMap = insertOrUpdateExecutor.buildImageParameters(sqlInsertRecognizer);
Assertions.assertEquals(imageParameterMap.toString(),mockImageParameterMap().toString());
}
Expand All @@ -119,11 +120,12 @@ public void testBuildImageSQL(){
String paramAppenderListStr = "[[userId1, 100], [userId2, 101]]";
mockImageParameterMap_contain_constant();
List<List<Object>> insertRows = new ArrayList<>();
insertRows.add(Arrays.asList("?,?,?,userStatus1"));
insertRows.add(Arrays.asList("?,?,?,userStatus2"));
insertRows.add(Arrays.asList("?","?","?","userStatus1"));
insertRows.add(Arrays.asList("?","?","?","userStatus2"));
when(sqlInsertRecognizer.getInsertRows(pkIndexMap.values())).thenReturn(insertRows);
mockInsertColumns();
mockAllIndexes();
doReturn(pkIndexMap).when(insertOrUpdateExecutor).getPkIndex();
String selectSQL = insertOrUpdateExecutor.buildImageSQL(tableMeta);
Assertions.assertEquals(selectSQLStr,selectSQL);
Assertions.assertEquals(paramAppenderListStr,insertOrUpdateExecutor.getParamAppenderList().toString());
Expand Down

0 comments on commit 19f5995

Please sign in to comment.