This is an automated email from the ASF dual-hosted git repository.
casion pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
new cd2b97c7d feat: linkis-protocol unit test add
new d8356d66b Merge pull request #3789 from
ruY9527/dev-1.3.1-linkis-protocol-unit-test
cd2b97c7d is described below
commit cd2b97c7d454b8be378ef834e22599718da09143
Author: ruY9527 <[email protected]>
AuthorDate: Sat Nov 5 11:51:06 2022 +0800
feat: linkis-protocol unit test add
---
.../protocol/constants/TaskConstantTest.java | 74 ++++++++++++++++++++++
.../linkis/protocol/engine/EngineStateTest.java | 53 ++++++++++++++++
.../linkis/protocol/util/ImmutablePairTest.java | 58 +++++++++++++++++
.../protocol/engine/RequestEngineStatusTest.scala | 44 +++++++++++++
.../engine/ResponseUserEngineKillTest.scala | 35 ++++++++++
.../linkis/protocol/utils/ProtocolUtilsTest.scala | 45 +++++++++++++
6 files changed, 309 insertions(+)
diff --git
a/linkis-commons/linkis-protocol/src/test/java/org/apache/linkis/protocol/constants/TaskConstantTest.java
b/linkis-commons/linkis-protocol/src/test/java/org/apache/linkis/protocol/constants/TaskConstantTest.java
new file mode 100644
index 000000000..2a81080be
--- /dev/null
+++
b/linkis-commons/linkis-protocol/src/test/java/org/apache/linkis/protocol/constants/TaskConstantTest.java
@@ -0,0 +1,74 @@
+/*
+ * 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.linkis.protocol.constants;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class TaskConstantTest {
+
+ @Test
+ @DisplayName("constTest")
+ public void constTest() {
+
+ String umuser = TaskConstant.UMUSER;
+ String submitUser = TaskConstant.SUBMIT_USER;
+ String executeUser = TaskConstant.EXECUTE_USER;
+ String tasktype = TaskConstant.TASKTYPE;
+ String executioncode = TaskConstant.EXECUTIONCODE;
+ String jobContent = TaskConstant.JOB_CONTENT;
+ String task = TaskConstant.TASK;
+ String tasks = TaskConstant.TASKS;
+ String params = TaskConstant.PARAMS;
+ String formatcode = TaskConstant.FORMATCODE;
+ String executeapplicationname = TaskConstant.EXECUTEAPPLICATIONNAME;
+ String requestapplicationname = TaskConstant.REQUESTAPPLICATIONNAME;
+ String scriptpath = TaskConstant.SCRIPTPATH;
+ String source = TaskConstant.SOURCE;
+ String runtype = TaskConstant.RUNTYPE;
+ String cache = TaskConstant.CACHE;
+ String paramsVariable = TaskConstant.PARAMS_VARIABLE;
+ String paramsConfiguration = TaskConstant.PARAMS_CONFIGURATION;
+ String paramsConfigurationStartup =
TaskConstant.PARAMS_CONFIGURATION_STARTUP;
+ String paramsConfigurationRuntime =
TaskConstant.PARAMS_CONFIGURATION_RUNTIME;
+ String paramsConfigurationSpecial =
TaskConstant.PARAMS_CONFIGURATION_SPECIAL;
+
+ Assertions.assertEquals("umUser", umuser);
+ Assertions.assertEquals("submitUser", submitUser);
+ Assertions.assertEquals("executeUser", executeUser);
+ Assertions.assertEquals("taskType", tasktype);
+ Assertions.assertEquals("executionCode", executioncode);
+ Assertions.assertEquals("jobContent", jobContent);
+ Assertions.assertEquals("task", task);
+ Assertions.assertEquals("tasks", tasks);
+ Assertions.assertEquals("params", params);
+ Assertions.assertEquals("formatCode", formatcode);
+ Assertions.assertEquals("executeApplicationName", executeapplicationname);
+ Assertions.assertEquals("requestApplicationName", requestapplicationname);
+ Assertions.assertEquals("scriptPath", scriptpath);
+ Assertions.assertEquals("source", source);
+ Assertions.assertEquals("runType", runtype);
+ Assertions.assertEquals("cache", cache);
+ Assertions.assertEquals("variable", paramsVariable);
+ Assertions.assertEquals("configuration", paramsConfiguration);
+ Assertions.assertEquals("startup", paramsConfigurationStartup);
+ Assertions.assertEquals("runtime", paramsConfigurationRuntime);
+ Assertions.assertEquals("special", paramsConfigurationSpecial);
+ }
+}
diff --git
a/linkis-commons/linkis-protocol/src/test/java/org/apache/linkis/protocol/engine/EngineStateTest.java
b/linkis-commons/linkis-protocol/src/test/java/org/apache/linkis/protocol/engine/EngineStateTest.java
new file mode 100644
index 000000000..197115cd2
--- /dev/null
+++
b/linkis-commons/linkis-protocol/src/test/java/org/apache/linkis/protocol/engine/EngineStateTest.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.linkis.protocol.engine;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class EngineStateTest {
+
+ @Test
+ @DisplayName("isCompletedTest")
+ public void isCompletedTest() {
+
+ boolean successCompleted = EngineState.isCompleted(EngineState.Success);
+ boolean errorCompleted = EngineState.isCompleted(EngineState.Error);
+ boolean deadCompleted = EngineState.isCompleted(EngineState.Dead);
+ boolean idleCompleted = EngineState.isCompleted(EngineState.Idle);
+
+ Assertions.assertTrue(successCompleted);
+ Assertions.assertTrue(errorCompleted);
+ Assertions.assertTrue(deadCompleted);
+ Assertions.assertFalse(idleCompleted);
+ }
+
+ @Test
+ @DisplayName("isAvailableTest")
+ public void isAvailableTest() {
+
+ boolean idleAvailable = EngineState.isAvailable(EngineState.Idle);
+ boolean busyAvailable = EngineState.isAvailable(EngineState.Busy);
+ boolean deadAvailable = EngineState.isAvailable(EngineState.Dead);
+
+ Assertions.assertTrue(idleAvailable);
+ Assertions.assertTrue(busyAvailable);
+ Assertions.assertFalse(deadAvailable);
+ }
+}
diff --git
a/linkis-commons/linkis-protocol/src/test/java/org/apache/linkis/protocol/util/ImmutablePairTest.java
b/linkis-commons/linkis-protocol/src/test/java/org/apache/linkis/protocol/util/ImmutablePairTest.java
new file mode 100644
index 000000000..37f650253
--- /dev/null
+++
b/linkis-commons/linkis-protocol/src/test/java/org/apache/linkis/protocol/util/ImmutablePairTest.java
@@ -0,0 +1,58 @@
+/*
+ * 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.linkis.protocol.util;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class ImmutablePairTest {
+
+ @Test
+ @DisplayName("getKeyTest")
+ public void getKeyTest() {
+
+ ImmutablePair<String, String> immutablePair =
+ new ImmutablePair<String, String>("hadoop", "hadoop");
+ String key = immutablePair.getKey();
+ Assertions.assertEquals("hadoop", key);
+ }
+
+ @Test
+ @DisplayName("getValueTest")
+ public void getValueTest() {
+
+ ImmutablePair<String, String> immutablePair =
+ new ImmutablePair<String, String>("hadoop", "hadoop");
+ String pairValue = immutablePair.getValue();
+ Assertions.assertEquals("hadoop", pairValue);
+ }
+
+ @Test
+ @DisplayName("equalsTest")
+ public void equalsTest() {
+
+ ImmutablePair<String, String> immutablePair1 =
+ new ImmutablePair<String, String>("hadoop", "hadoop");
+ ImmutablePair<String, String> immutablePair2 =
+ new ImmutablePair<String, String>("hadoop", "hadoop");
+
+ boolean equals = immutablePair1.equals(immutablePair2);
+ Assertions.assertTrue(equals);
+ }
+}
diff --git
a/linkis-commons/linkis-protocol/src/test/scala/org/apache/linkis/protocol/engine/RequestEngineStatusTest.scala
b/linkis-commons/linkis-protocol/src/test/scala/org/apache/linkis/protocol/engine/RequestEngineStatusTest.scala
new file mode 100644
index 000000000..d9fc07b6c
--- /dev/null
+++
b/linkis-commons/linkis-protocol/src/test/scala/org/apache/linkis/protocol/engine/RequestEngineStatusTest.scala
@@ -0,0 +1,44 @@
+/*
+ * 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.linkis.protocol.engine
+
+import org.junit.jupiter.api.{Assertions, DisplayName, Test}
+
+class RequestEngineStatusTest {
+
+ @Test
+ @DisplayName("constTest")
+ def constTest(): Unit = {
+
+ val statusOnly = RequestEngineStatus.Status_Only
+ val statusOverload = RequestEngineStatus.Status_Overload
+ val statusConcurrent = RequestEngineStatus.Status_Concurrent
+ val statusOverloadConcurrent =
RequestEngineStatus.Status_Overload_Concurrent
+ val statusBasicInfo = RequestEngineStatus.Status_BasicInfo
+ val all = RequestEngineStatus.ALL
+
+ Assertions.assertTrue(1 == statusOnly)
+ Assertions.assertTrue(2 == statusOverload)
+ Assertions.assertTrue(3 == statusConcurrent)
+ Assertions.assertTrue(4 == statusOverloadConcurrent)
+ Assertions.assertTrue(5 == statusBasicInfo)
+ Assertions.assertTrue(6 == all)
+
+ }
+
+}
diff --git
a/linkis-commons/linkis-protocol/src/test/scala/org/apache/linkis/protocol/engine/ResponseUserEngineKillTest.scala
b/linkis-commons/linkis-protocol/src/test/scala/org/apache/linkis/protocol/engine/ResponseUserEngineKillTest.scala
new file mode 100644
index 000000000..dbf3f5e3b
--- /dev/null
+++
b/linkis-commons/linkis-protocol/src/test/scala/org/apache/linkis/protocol/engine/ResponseUserEngineKillTest.scala
@@ -0,0 +1,35 @@
+/*
+ * 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.linkis.protocol.engine
+
+import org.junit.jupiter.api.{Assertions, DisplayName, Test}
+
+class ResponseUserEngineKillTest {
+
+ @Test
+ @DisplayName("constTest")
+ def constTest(): Unit = {
+
+ val success = ResponseUserEngineKill.Success
+ val error = ResponseUserEngineKill.Error
+
+ Assertions.assertEquals("Success", success)
+ Assertions.assertEquals("Error", error)
+ }
+
+}
diff --git
a/linkis-commons/linkis-protocol/src/test/scala/org/apache/linkis/protocol/utils/ProtocolUtilsTest.scala
b/linkis-commons/linkis-protocol/src/test/scala/org/apache/linkis/protocol/utils/ProtocolUtilsTest.scala
new file mode 100644
index 000000000..2435f5149
--- /dev/null
+++
b/linkis-commons/linkis-protocol/src/test/scala/org/apache/linkis/protocol/utils/ProtocolUtilsTest.scala
@@ -0,0 +1,45 @@
+/*
+ * 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.linkis.protocol.utils
+
+import org.junit.jupiter.api.{Assertions, DisplayName, Test}
+
+class ProtocolUtilsTest {
+
+ @Test
+ @DisplayName("constTest")
+ def constTest(): Unit = {
+
+ val serviceSuffix = ProtocolUtils.SERVICE_SUFFIX.getValue
+ val suffixs = ProtocolUtils.suffixs
+
+ Assertions.assertNotNull(serviceSuffix)
+ Assertions.assertTrue(suffixs.length == 3)
+ }
+
+ @Test
+ @DisplayName("getAppNameTest")
+ def getAppNameTest(): Unit = {
+
+ val modeleName = "engineManager"
+ val appNameOption = ProtocolUtils.getAppName(modeleName)
+ Assertions.assertNotNull(appNameOption.get)
+
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]