github-actions[bot] commented on code in PR #65781: URL: https://github.com/apache/doris/pull/65781#discussion_r3607825797
########## fe/fe-core/src/test/java/org/apache/doris/mysql/privilege/CommonUserPropertiesTest.java: ########## @@ -0,0 +1,86 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +package org.apache.doris.mysql.privilege; + +import org.apache.doris.persist.gson.GsonUtils; +import org.apache.doris.resource.Tag; + +import org.junit.Assert; +import org.junit.Test; + +import java.util.Collections; + +public class CommonUserPropertiesTest { + private static final String RESOURCE_TAG_JSON = "[{\"type\":\"location\",\"value\":\"group_a\"}]"; + + @Test + public void testDeserializeResourceTagsFromAllFieldNames() { + for (String fieldName : new String[] {"rt", "resourceTag", "resourceTags"}) { + String json = String.format("{\"%s\":%s}", fieldName, RESOURCE_TAG_JSON); + CommonUserProperties properties = GsonUtils.GSON.fromJson(json, CommonUserProperties.class); + + Assert.assertEquals(Collections.singleton(Tag.createNotCheck(Tag.TYPE_LOCATION, "group_a")), + properties.getResourceTags()); + } + } + + @Test + public void testDeserializeSqlBlockRulesFromAllFieldNames() { + for (String fieldName : new String[] {"sbr", "sqlBlockRule", "sqlBlockRules"}) { + String json = String.format("{\"%s\":\"rule_a, rule_b\"}", fieldName); + CommonUserProperties properties = GsonUtils.GSON.fromJson(json, CommonUserProperties.class); + + Assert.assertEquals("rule_a, rule_b", properties.getSqlBlockRules()); + Assert.assertArrayEquals(new String[] {"rule_a", "rule_b"}, properties.getSqlBlockRulesSplit()); + } + } + + @Test + public void testDeserializeLegacyCommonUserProperties() { + String json = "{" + Review Comment: The added test currently fails the mandatory FE Checkstyle gate. The live Checkstyle job reports `OperatorWrap` for every trailing `+` in this fixture (13 violations across lines 55-67), so this PR cannot pass validation. Please move each `+` to the beginning of its continuation line (or otherwise reformat the JSON construction), then rerun Checkstyle and the unit test. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
