kezhenxu94 commented on code in PR #10817:
URL: https://github.com/apache/dolphinscheduler/pull/10817#discussion_r915664479


##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/pages/login/entity/LoginResponseEntity.java:
##########
@@ -0,0 +1,31 @@
+/*
+ * 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.dolphinscheduler.api.test.pages.login.entity;
+
+public class LoginResponseEntity {

Review Comment:
   Use lombok annotation



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/pages/login/form/LoginFormData.java:
##########
@@ -0,0 +1,41 @@
+/*
+ * 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.dolphinscheduler.api.test.pages.login.form;
+
+public enum LoginFormData {
+    USR_NAME("userName", "admin"),
+    USER_PASSWD("userPassword", "dolphinscheduler123");
+
+    LoginFormData(String param, String data) {
+        this.data = data;
+        this.param = param;
+
+    }
+
+    private final String param;
+    private final String data;
+
+    public String getParam() {
+        return param;
+    }
+
+    public String getData() {
+        return data;
+    }

Review Comment:
   Use lombok annotation to replace setter/getter and constructor method



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-core/src/main/java/org/apache/dolphinscheduler/api/test/core/extensions/RandomParametersExtension.java:
##########
@@ -0,0 +1,53 @@
+/*
+ * 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.dolphinscheduler.api.test.core.extensions;
+
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
+import org.junit.jupiter.api.extension.ParameterContext;
+import org.junit.jupiter.api.extension.ParameterResolutionException;
+import org.junit.jupiter.api.extension.ParameterResolver;
+
+import java.lang.reflect.Parameter;
+
+public class RandomParametersExtension implements ParameterResolver {

Review Comment:
   What's the relationshipt between this class and 
https://github.com/junit-team/junit5-samples/blob/main/junit5-jupiter-extensions/src/main/java/com/example/random/RandomParametersExtension.java
 ? 



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/utils/RestResponse.java:
##########
@@ -0,0 +1,94 @@
+/*
+ * 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.dolphinscheduler.api.test.utils;
+
+import io.restassured.response.Response;
+import io.restassured.response.ValidatableResponse;
+import org.apache.dolphinscheduler.api.test.base.IRestResponse;
+import org.apache.dolphinscheduler.api.test.core.common.Constants;
+
+import java.util.Objects;
+
+import static org.hamcrest.Matchers.equalTo;
+
+public class RestResponse<T> implements IRestResponse<T> {
+    private T data;
+    private Response response;
+    private Exception e;
+
+    public RestResponse(Class<T> t, Response response) {
+        this.response = response;
+        try {
+            this.data = t.getDeclaredConstructor().newInstance();
+        } catch (Exception e) {
+            throw new RuntimeException("There should be a default constructor 
in the Response POJO");
+        }
+    }
+
+    public String getContent() {
+        return response.getBody().asString();
+    }
+
+    public int getStatusCode() {
+        return response.getStatusCode();
+    }
+
+    public boolean isSuccessful() {
+        int code = response.getStatusCode();
+        return code == 200 || code == 201 || code == 202 || code == 203 || 
code == 204 || code == 205;

Review Comment:
   I think `return code >= 200 && code < 300;` can be considered as successful



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/utils/JSONUtils.java:
##########
@@ -381,4 +383,27 @@ public String deserialize(JsonParser p, 
DeserializationContext ctxt) throws IOEx
     public static <T> T convertValue(Object value, Class<T> targetType) {
         return objectMapper.convertValue(value, targetType);
     }
+
+    /**
+     * jsonToObject
+     *
+     * @param json
+     * @param path       json object access path
+     * @param objectType
+     * @param <T>
+     * @return
+     */
+    public static <T> T jsonToObject(String json, String path, Class<T> 
objectType) {
+        return JsonPath.from(json).getObject(path, objectType);
+    }
+
+
+    public static <T> List<T> jsonToObjectList(String json, String path, 
Class<T> objectType) {
+        return JsonPath.from(json).getList(path, objectType);
+    }
+
+
+    public static Map<String, Object> jsonToMap(String json, String path) {
+        return JsonPath.from(json).getObject(path, new TypeRef<Map<String, 
Object>>() {});
+    }

Review Comment:
   Please add them only when you need to use them, this is friendly for 
reviewers, reviewing unused codes we cannot know whether they will be used 
correctly.



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/pages/login/entity/LoginRequestEntity.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.dolphinscheduler.api.test.pages.login.entity;
+
+import org.apache.dolphinscheduler.api.test.base.AbstractBaseEntity;
+
+public class LoginRequestEntity extends AbstractBaseEntity {

Review Comment:
   Try using lombok annotation `@Data` to eliminate boilerplate `getter/setter`



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-core/src/main/java/org/apache/dolphinscheduler/api/test/core/extensions/TimingExtension.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * 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.dolphinscheduler.api.test.core.extensions;
+
+import java.lang.reflect.Method;
+import java.util.logging.Logger;
+
+import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
+import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
+import org.junit.jupiter.api.extension.ExtensionContext.Store;
+
+public class TimingExtension implements BeforeTestExecutionCallback, 
AfterTestExecutionCallback {

Review Comment:
   What's the relationshipt between this class and 
https://github.com/junit-team/junit5/blob/main/documentation/src/test/java/example/timing/TimingExtension.java
 ?



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/pages/security/tenant/entity/TenantResponseEntity.java:
##########
@@ -0,0 +1,73 @@
+/*
+ * 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.dolphinscheduler.api.test.pages.security.tenant.entity;
+
+
+public class TenantResponseEntity extends TenantRequestEntity {

Review Comment:
   Use Lombok annotations



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/pages/security/tenant/entity/TenantRequestEntity.java:
##########
@@ -0,0 +1,63 @@
+/*
+ * 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.dolphinscheduler.api.test.pages.security.tenant.entity;
+
+import org.apache.dolphinscheduler.api.test.base.AbstractBaseEntity;
+
+public class TenantRequestEntity extends AbstractBaseEntity {

Review Comment:
   Use Lombok annotations



-- 
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]

Reply via email to