Skip to content

Commit

Permalink
Fix unit test error. (#12533)
Browse files Browse the repository at this point in the history
* Fix unit test error.

* Fix unit test error.
  • Loading branch information
KomachiSion authored Aug 22, 2024
1 parent 195f5c4 commit c8cee80
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ParamExtractorTest {
void testBlurFilter() throws Exception {
MockedStatic<EnvUtil> mockedStatic = Mockito.mockStatic(EnvUtil.class);
final Method check = ConfigController.class.getMethod("fuzzySearchConfig", String.class, String.class, String.class, String.class,
String.class, int.class, int.class);
String.class, String.class, int.class, int.class);
ExtractorManager.Extractor annotation = check.getAnnotation(ExtractorManager.Extractor.class);
AbstractHttpParamExtractor httpExtractor = Mockito.spy(ExtractorManager.getHttpExtractor(annotation));

Expand Down
2 changes: 1 addition & 1 deletion config/src/test/resources/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
log4j.rootLogger=DEBUG, ServerDailyRollingFile,stdout
log4j.rootLogger=INFO, ServerDailyRollingFile,stdout
log4j.appender.ServerDailyRollingFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.ServerDailyRollingFile.DatePattern='.'yyyy-MM-dd_HH
log4j.appender.ServerDailyRollingFile.File=${webapp.root}/WEB-INF/logs/nacos-server.log
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,15 +263,15 @@ void testFindConfigInfoBaseByGroupFetchRows() {
@Test
void testFindConfigInfoLike4PageCountRows() {
MapperResult mapperResult = configInfoMapperByDerby.findConfigInfoLike4PageCountRows(context);
assertEquals("SELECT count(*) FROM config_info WHERE tenant_id LIKE ? AND app_name = ? ", mapperResult.getSql());
assertEquals("SELECT count(*) FROM config_info WHERE tenant_id LIKE ? AND app_name = ? ", mapperResult.getSql());
assertArrayEquals(new Object[] {tenantId, appName}, mapperResult.getParamList().toArray());
}

@Test
void testFindConfigInfoLike4PageFetchRows() {
MapperResult mapperResult = configInfoMapperByDerby.findConfigInfoLike4PageFetchRows(context);
assertEquals(mapperResult.getSql(), "SELECT id,data_id,group_id,tenant_id,app_name,content,encrypted_data_key FROM config_info "
+ "WHERE tenant_id LIKE ? AND app_name = ? OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY");
assertEquals(mapperResult.getSql(), "SELECT id,data_id,group_id,tenant_id,app_name,content,encrypted_data_key,type FROM config_info "
+ "WHERE tenant_id LIKE ? AND app_name = ? OFFSET " + startRow + " ROWS FETCH NEXT " + pageSize + " ROWS ONLY");
assertArrayEquals(new Object[] {tenantId, appName}, mapperResult.getParamList().toArray());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void setUp() throws Exception {
@Test
void testFindConfigInfo4PageCountRows() {
MapperResult mapperResult = configInfoTagsRelationMapperByDerby.findConfigInfoLike4PageCountRows(context);
assertEquals(mapperResult.getSql(), "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id WHERE "
assertEquals(mapperResult.getSql(), "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id WHERE "
+ "a.tenant_id LIKE ? AND b.tag_name IN (?, ?, ?, ?, ?) ");
List<Object> list = CollectionUtils.list(tenantId);
list.addAll(Arrays.asList(tagArr));
Expand All @@ -78,8 +78,8 @@ void testFindConfigInfo4PageFetchRows() {
@Test
void testFindConfigInfoLike4PageCountRows() {
MapperResult mapperResult = configInfoTagsRelationMapperByDerby.findConfigInfoLike4PageCountRows(context);
assertEquals(mapperResult.getSql(), "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id "
+ "WHERE a.tenant_id LIKE ? AND b.tag_name IN (?, ?, ?, ?, ?) ");
assertEquals(mapperResult.getSql(), "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id "
+ "WHERE a.tenant_id LIKE ? AND b.tag_name IN (?, ?, ?, ?, ?) ");
List<Object> list = CollectionUtils.list(tenantId);
list.addAll(Arrays.asList(tagArr));
assertArrayEquals(mapperResult.getParamList().toArray(), list.toArray());
Expand All @@ -88,8 +88,8 @@ void testFindConfigInfoLike4PageCountRows() {
@Test
void tsetFindConfigInfoLike4PageFetchRows() {
MapperResult mapperResult = configInfoTagsRelationMapperByDerby.findConfigInfoLike4PageFetchRows(context);
assertEquals(mapperResult.getSql(), "SELECT a.ID,a.data_id,a.group_id,a.tenant_id,a.app_name,a.content FROM config_info a "
+ "LEFT JOIN config_tags_relation b ON a.id=b.id WHERE a.tenant_id LIKE ? AND b.tag_name "
assertEquals(mapperResult.getSql(), "SELECT a.ID,a.data_id,a.group_id,a.tenant_id,a.app_name,a.content,a.type FROM config_info a "
+ "LEFT JOIN config_tags_relation b ON a.id=b.id WHERE a.tenant_id LIKE ? AND b.tag_name "
+ "IN (?, ?, ?, ?, ?) OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY");
List<Object> list = CollectionUtils.list(tenantId);
list.addAll(Arrays.asList(tagArr));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,15 @@ void testFindConfigInfoBaseByGroupFetchRows() {
@Test
void testFindConfigInfoLike4PageCountRows() {
MapperResult mapperResult = configInfoMapperByMySql.findConfigInfoLike4PageCountRows(context);
assertEquals("SELECT count(*) FROM config_info WHERE tenant_id LIKE ? AND app_name = ? ", mapperResult.getSql());
assertEquals("SELECT count(*) FROM config_info WHERE tenant_id LIKE ? AND app_name = ? ", mapperResult.getSql());
assertArrayEquals(new Object[] {tenantId, appName}, mapperResult.getParamList().toArray());
}

@Test
void testFindConfigInfoLike4PageFetchRows() {
MapperResult mapperResult = configInfoMapperByMySql.findConfigInfoLike4PageFetchRows(context);
assertEquals(mapperResult.getSql(), "SELECT id,data_id,group_id,tenant_id,app_name,content,encrypted_data_key FROM config_info "
+ "WHERE tenant_id LIKE ? AND app_name = ? LIMIT " + startRow + "," + pageSize);
assertEquals(mapperResult.getSql(), "SELECT id,data_id,group_id,tenant_id,app_name,content,encrypted_data_key,type FROM config_info "
+ "WHERE tenant_id LIKE ? AND app_name = ? LIMIT " + startRow + "," + pageSize);
assertArrayEquals(new Object[] {tenantId, appName}, mapperResult.getParamList().toArray());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void setUp() throws Exception {
@Test
void testFindConfigInfoLike4PageCountRows() {
MapperResult mapperResult = configTagsRelationMapperByMySql.findConfigInfoLike4PageCountRows(context);
assertEquals(mapperResult.getSql(), "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id WHERE "
assertEquals(mapperResult.getSql(), "SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id WHERE "
+ "a.tenant_id LIKE ? AND b.tag_name IN (?, ?, ?, ?, ?) ");
List<Object> list = CollectionUtils.list(tenantId);
list.addAll(Arrays.asList(tagArr));
Expand Down Expand Up @@ -101,8 +101,8 @@ void testFindConfigInfoLike4PageCountRowss() {
context.putWhereParameter(FieldConstant.APP_NAME, "AppName1");
context.putWhereParameter(FieldConstant.CONTENT, "Content1");
MapperResult mapperResult = configTagsRelationMapperByMySql.findConfigInfoLike4PageCountRows(context);
assertEquals("SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id "
+ "WHERE a.tenant_id LIKE ? AND a.data_id LIKE ? AND a.group_id LIKE ? AND a.app_name = ? "
assertEquals("SELECT count(*) FROM config_info a LEFT JOIN config_tags_relation b ON a.id=b.id "
+ "WHERE a.tenant_id LIKE ? AND a.data_id LIKE ? AND a.group_id LIKE ? AND a.app_name = ? "
+ "AND a.content LIKE ? AND b.tag_name IN (?, ?, ?, ?, ?) ", mapperResult.getSql());
List<Object> list = CollectionUtils.list(tenantId);
list.add("dataID1");
Expand All @@ -120,8 +120,8 @@ void tsetFindConfigInfoLike4PageFetchRows() {
context.putWhereParameter(FieldConstant.APP_NAME, "AppName1");
context.putWhereParameter(FieldConstant.CONTENT, "Content1");
MapperResult mapperResult = configTagsRelationMapperByMySql.findConfigInfoLike4PageFetchRows(context);
assertEquals(mapperResult.getSql(), "SELECT a.id,a.data_id,a.group_id,a.tenant_id,a.app_name,a.content FROM config_info a LEFT JOIN"
+ " config_tags_relation b ON a.id=b.id WHERE a.tenant_id LIKE ? AND a.data_id LIKE ? "
assertEquals(mapperResult.getSql(), "SELECT a.id,a.data_id,a.group_id,a.tenant_id,a.app_name,a.content,a.type FROM config_info a LEFT JOIN"
+ " config_tags_relation b ON a.id=b.id WHERE a.tenant_id LIKE ? AND a.data_id LIKE ? "
+ "AND a.group_id LIKE ? AND a.app_name = ? AND a.content LIKE ? AND b.tag_name IN (?, ?, ?, ?, ?) LIMIT " + startRow
+ "," + pageSize);
List<Object> list = CollectionUtils.list(tenantId);
Expand Down

0 comments on commit c8cee80

Please sign in to comment.