Skip to content

Commit

Permalink
testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyiyue1102 committed Dec 16, 2024
1 parent 09dfb28 commit 63e0eb7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ default MapperResult findConfigHistoryCountByTime(MapperContext context) {
default MapperResult findDeletedConfig(MapperContext context) {
return new MapperResult(
"SELECT id, nid, data_id, group_id, app_name, content, md5, gmt_create, gmt_modified, src_user, src_ip, op_type, tenant_id, "
+ "publish_type, ext_info, encrypted_data_key FROM his_config_info WHERE op_type = 'D' AND "
+ "publish_type, gray_name, ext_info, encrypted_data_key FROM his_config_info WHERE op_type = 'D' AND "
+ "publish_type = ? and gmt_modified >= ? and nid > ? order by nid limit ? ",
CollectionUtils.list(context.getWhereParameter(FieldConstant.PUBLISH_TYPE),
context.getWhereParameter(FieldConstant.START_TIME),
Expand All @@ -80,7 +80,8 @@ default MapperResult findDeletedConfig(MapperContext context) {
*/
default MapperResult findConfigHistoryFetchRows(MapperContext context) {
return new MapperResult(
"SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,op_type,gmt_create,gmt_modified FROM his_config_info "
"SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,publish_type,gray_name,op_type,"
+ "gmt_create,gmt_modified FROM his_config_info "
+ "WHERE data_id = ? AND group_id = ? AND tenant_id = ? ORDER BY nid DESC",
CollectionUtils.list(context.getWhereParameter(FieldConstant.DATA_ID),
context.getWhereParameter(FieldConstant.GROUP_ID),
Expand All @@ -107,7 +108,7 @@ default MapperResult findConfigHistoryFetchRows(MapperContext context) {
*/
default MapperResult detailPreviousConfigHistory(MapperContext context) {
return new MapperResult(
"SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,publish_type,ext_info,gmt_create"
"SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,publish_type,gray_name,ext_info,gmt_create"
+ ",gmt_modified,encrypted_data_key FROM his_config_info WHERE nid = (SELECT max(nid) FROM his_config_info WHERE id = ?)",
Collections.singletonList(context.getWhereParameter(FieldConstant.ID)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ void testFindConfigHistoryCountByTime() {
@Test
void testFindDeletedConfig() {
MapperResult mapperResult = historyConfigInfoMapperByDerby.findDeletedConfig(context);
assertEquals( "SELECT id, nid, data_id, group_id, app_name, content, md5, gmt_create, gmt_modified, src_user, src_ip,"
+ " op_type, tenant_id, publish_type,gray_name, ext_info, encrypted_data_key FROM his_config_info WHERE op_type = 'D' AND "
+ "publish_type = ? and gmt_modified >= ? and nid > ? order by nid OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY",mapperResult.getSql());
assertArrayEquals(new Object[] {publishType, startTime, lastMaxId, pageSize}, mapperResult.getParamList().toArray());
assertEquals(
"SELECT id, nid, data_id, group_id, app_name, content, md5, gmt_create, gmt_modified, src_user, src_ip,"
+ " op_type, tenant_id, publish_type,gray_name, ext_info, encrypted_data_key FROM his_config_info WHERE op_type = 'D' AND "
+ "publish_type = ? and gmt_modified >= ? and nid > ? order by nid OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY",
mapperResult.getSql());
assertArrayEquals(new Object[] {publishType, startTime, lastMaxId, pageSize},
mapperResult.getParamList().toArray());
}

@Test
Expand All @@ -99,7 +102,8 @@ void testFindConfigHistoryFetchRows() {
context.putWhereParameter(FieldConstant.DATA_ID, dataId);
MapperResult mapperResult = historyConfigInfoMapperByDerby.findConfigHistoryFetchRows(context);
assertEquals(mapperResult.getSql(),
"SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,op_type,gmt_create,gmt_modified FROM his_config_info "
"SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,publish_type,gray_name,"
+ "op_type,gmt_create,gmt_modified FROM his_config_info "
+ "WHERE data_id = ? AND group_id = ? AND tenant_id = ? ORDER BY nid DESC");
assertArrayEquals(new Object[] {dataId, groupId, tenantId}, mapperResult.getParamList().toArray());
}
Expand All @@ -109,9 +113,10 @@ void testDetailPreviousConfigHistory() {
Object id = "1";
context.putWhereParameter(FieldConstant.ID, id);
MapperResult mapperResult = historyConfigInfoMapperByDerby.detailPreviousConfigHistory(context);
assertEquals(mapperResult.getSql(), "SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,publish_type"
+ ",ext_info,gmt_create,gmt_modified,encrypted_data_key "
+ "FROM his_config_info WHERE nid = (SELECT max(nid) FROM his_config_info WHERE id = ?)");
assertEquals(mapperResult.getSql(),
"SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,publish_type"
+ ",gray_name,ext_info,gmt_create,gmt_modified,encrypted_data_key "
+ "FROM his_config_info WHERE nid = (SELECT max(nid) FROM his_config_info WHERE id = ?)");
assertArrayEquals(new Object[] {id}, mapperResult.getParamList().toArray());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,14 @@ void testFindConfigHistoryCountByTime() {
@Test
void testFindDeletedConfig() {
MapperResult mapperResult = historyConfigInfoMapperByMySql.findDeletedConfig(context);
assertEquals(mapperResult.getSql(), "SELECT id, nid, data_id, group_id, app_name, content, md5, gmt_create, gmt_modified, src_user, src_ip,"
+ " op_type, tenant_id, publish_type, ext_info, encrypted_data_key FROM his_config_info WHERE op_type = 'D' AND "
+ "publish_type = ? and gmt_modified >= ? and nid > ? order by nid limit ? ");
assertEquals(
"SELECT id, nid, data_id, group_id, app_name, content, md5, gmt_create, gmt_modified, src_user, src_ip,"
+ " op_type, tenant_id, publish_type, gray_name, ext_info, encrypted_data_key FROM his_config_info WHERE op_type = 'D' AND "
+ "publish_type = ? and gmt_modified >= ? and nid > ? order by nid limit ? ",
mapperResult.getSql());

assertArrayEquals(new Object[] {publishType, startTime, lastMaxId, pageSize}, mapperResult.getParamList().toArray());
assertArrayEquals(new Object[] {publishType, startTime, lastMaxId, pageSize},
mapperResult.getParamList().toArray());
}

@Test
Expand All @@ -97,7 +100,8 @@ void testFindConfigHistoryFetchRows() {
context.putWhereParameter(FieldConstant.DATA_ID, dataId);
MapperResult mapperResult = historyConfigInfoMapperByMySql.findConfigHistoryFetchRows(context);
assertEquals(mapperResult.getSql(),
"SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,op_type,gmt_create,gmt_modified FROM his_config_info "
"SELECT nid,data_id,group_id,tenant_id,app_name,src_ip,src_user,publish_type,gray_name,"
+ "op_type,gmt_create,gmt_modified FROM his_config_info "
+ "WHERE data_id = ? AND group_id = ? AND tenant_id = ? ORDER BY nid DESC");
assertArrayEquals(new Object[] {dataId, groupId, tenantId}, mapperResult.getParamList().toArray());
}
Expand All @@ -107,9 +111,10 @@ void testDetailPreviousConfigHistory() {
Object id = "1";
context.putWhereParameter(FieldConstant.ID, id);
MapperResult mapperResult = historyConfigInfoMapperByMySql.detailPreviousConfigHistory(context);
assertEquals(mapperResult.getSql(), "SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,publish_type"
+ ",ext_info,gmt_create,gmt_modified,encrypted_data_key "
+ "FROM his_config_info WHERE nid = (SELECT max(nid) FROM his_config_info WHERE id = ?)");
assertEquals(mapperResult.getSql(),
"SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,publish_type"
+ ",gray_name,ext_info,gmt_create,gmt_modified,encrypted_data_key "
+ "FROM his_config_info WHERE nid = (SELECT max(nid) FROM his_config_info WHERE id = ?)");
assertArrayEquals(new Object[] {id}, mapperResult.getParamList().toArray());
}

Expand Down

0 comments on commit 63e0eb7

Please sign in to comment.