You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by GitBox <gi...@apache.org> on 2022/07/07 01:10:40 UTC

[GitHub] [dolphinscheduler] SbloodyS commented on a diff in pull request #10817: [API-Test] [Improvement] update api test demo

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


##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/base/IPageAPI.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.base;
+
+import io.restassured.response.Response;
+import io.restassured.specification.RequestSpecification;
+import org.apache.dolphinscheduler.api.test.core.common.FormParam;
+import org.apache.dolphinscheduler.api.test.core.common.RequestMethod;
+import org.apache.dolphinscheduler.api.test.utils.RestResponse;
+import org.apache.dolphinscheduler.api.test.utils.Result;
+
+import java.util.Map;
+
+import static io.restassured.RestAssured.given;
+
+public interface IPageAPI {
+
+    default RestResponse<Result> toResponse(Response response) {
+        return new RestResponse<>(Result.class, response);
+    }
+
+    default Response RestRequestByRequestMap(RequestSpecification request, String sessionId,

Review Comment:
   We should use  lower camel case here.



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/pages/security/tenant/entity/TenantRequestEntity.java:
##########
@@ -0,0 +1,26 @@
+/*
+ * 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 TenantRequestEntity extends TenantBaseEntity {
+    private int id;
+    public void setId(int id) {
+        this.id = id;
+    }
+}

Review Comment:
   What is the purpose of this? 



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/pages/security/tenant/entity/TenantBaseEntity.java:
##########
@@ -0,0 +1,55 @@
+/*
+ * 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 TenantBaseEntity extends AbstractBaseEntity {
+
+    private String tenantCode;
+
+    private String description;
+
+    private int queueId = 1;

Review Comment:
   We should not hardcode this. All test related variables should be initialized in the test case.



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/pages/security/tenant/entity/TenantResponseEntity.java:
##########
@@ -0,0 +1,93 @@
+/*
+ * 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 java.util.Objects;
+
+public class TenantResponseEntity extends TenantBaseEntity {
+
+    /**
+     * id
+     */
+    private int id;
+
+    /**
+     * queue name
+     */
+    private String queueName;
+
+    /**
+     * queue
+     */
+    private String queue;
+
+    /**
+     * create time
+     */
+    public String createTime;
+    /**
+     * update time
+     */
+    public String updateTime;
+
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+
+    public String getQueueName() {
+        return queueName;
+    }
+
+    public void setQueueName(String queueName) {
+        this.queueName = queueName;
+    }
+
+    public String getQueue() {
+        return queue;
+    }
+
+    public void setQueue(String queue) {
+        this.queue = queue;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        TenantResponseEntity tenant = (TenantResponseEntity) o;
+
+        return id == tenant.id;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id);
+    }

Review Comment:
   What is the purpose of this?



##########
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:
   Why did you want to add unused methods?



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-case/src/test/java/org/apache/dolphinscheduler/api.test/utils/Result.java:
##########
@@ -0,0 +1,156 @@
+/*
+ * 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 java.text.MessageFormat;
+
+public class Result<T> {

Review Comment:
   I think this file is useless. We are doing API refactoring in #10257. One of which is this problem.



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-core/src/main/java/org/apache/dolphinscheduler/api/test/core/common/PageFormParam.java:
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.common;
+
+public enum PageFormParam {
+    PAGE_SIZE("pageSize"),

Review Comment:
   Same as `FormParam.java`.



##########
dolphinscheduler-api-test/dolphinscheduler-api-test-core/src/main/java/org/apache/dolphinscheduler/api/test/core/common/FormParam.java:
##########
@@ -0,0 +1,39 @@
+/*
+ * 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.common;
+
+public enum FormParam {
+    SESSION_ID("sessionId"),

Review Comment:
   I think we should use entity instead of enum since this is not an enumeration.



##########
.github/workflows/api-test.yml:
##########
@@ -86,8 +86,12 @@ jobs:
     strategy:
       matrix:
         case:
+          - name: Login
+            class: org.apache.dolphinscheduler.api.test.cases.LoginAPITest
           - name: Tenant
             class: org.apache.dolphinscheduler.api.test.cases.TenantAPITest
+          - name: TenantNew
+            class: org.apache.dolphinscheduler.api.test.cases.TenantAPITestNew

Review Comment:
   We should refactor the old `TenantAPITest` instead of creating a new one.



-- 
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: commits-unsubscribe@dolphinscheduler.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org