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 7f95993f4 feat: linkis-cs-common unit test add (#3777)
7f95993f4 is described below
commit 7f95993f4bf24b2988d218b474562ca5da4bfcbb
Author: ruY <[email protected]>
AuthorDate: Tue Nov 8 10:40:10 2022 +0800
feat: linkis-cs-common unit test add (#3777)
---
.../entity/enumeration/ContextScopeTest.java | 40 +++++
.../common/entity/enumeration/ContextTypeTest.java | 48 +++++
.../cs/common/entity/enumeration/DBTypeTest.java | 40 +++++
.../common/entity/enumeration/ExpireTypeTest.java | 38 ++++
.../cs/common/entity/enumeration/WorkTypeTest.java | 40 +++++
.../cs/common/protocol/ContextHistoryTypeTest.java | 36 ++++
.../cs/common/protocol/ContextIDTypeTest.java | 43 +++++
.../cs/common/protocol/ContextKeyTypeTest.java | 37 ++++
.../common/protocol/ContextKeyValueTypeTest.java | 37 ++++
.../cs/common/protocol/ContextValueTypeTest.java | 37 ++++
.../helper/ContextSerializationHelperTest.java | 199 +++++++++++++++++++++
.../CombinedNodeIDContextIDSerializerTest.java | 59 ++++++
.../context/CommonContextKeySerializerTest.java | 60 +++++++
.../value/LinkisBMLResourceSerializerTest.java | 63 +++++++
.../value/data/CSResultDataSerializerTest.java | 60 +++++++
.../value/data/LinkisJobDataSerializerTest.java | 61 +++++++
.../impl/value/metadata/CSTableSerializerTest.java | 65 +++++++
.../value/object/CSFlowInfosSerializerTest.java | 57 ++++++
.../linkis/cs/common/utils/CSCommonUtilsTest.java | 67 +++++++
.../cs/common/utils/CSHighAvailableUtilsTest.java | 64 +++++++
20 files changed, 1151 insertions(+)
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/ContextScopeTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/ContextScopeTest.java
new file mode 100644
index 000000000..abb4b4611
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/ContextScopeTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.cs.common.entity.enumeration;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class ContextScopeTest {
+
+ @Test
+ @DisplayName("enumTest")
+ public void enumTest() {
+
+ String publicStr = ContextScope.PUBLIC.toString();
+ String privateStr = ContextScope.PRIVATE.toString();
+ String projectedStr = ContextScope.PROTECTED.toString();
+ String friendlyStr = ContextScope.FRIENDLY.toString();
+
+ Assertions.assertEquals("PUBLIC", publicStr);
+ Assertions.assertEquals("PRIVATE", privateStr);
+ Assertions.assertEquals("PROTECTED", projectedStr);
+ Assertions.assertEquals("FRIENDLY", friendlyStr);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/ContextTypeTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/ContextTypeTest.java
new file mode 100644
index 000000000..da8e8a3b0
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/ContextTypeTest.java
@@ -0,0 +1,48 @@
+/*
+ * 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.cs.common.entity.enumeration;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class ContextTypeTest {
+
+ @Test
+ @DisplayName("enumTest")
+ public void enumTest() {
+
+ String metaData = ContextType.METADATA.toString();
+ String data = ContextType.DATA.toString();
+ String resource = ContextType.RESOURCE.toString();
+ String object = ContextType.OBJECT.toString();
+ String env = ContextType.ENV.toString();
+ String cost = ContextType.COST.toString();
+ String udf = ContextType.UDF.toString();
+ String variable = ContextType.Variable.toString();
+
+ Assertions.assertEquals("METADATA", metaData);
+ Assertions.assertEquals("DATA", data);
+ Assertions.assertEquals("RESOURCE", resource);
+ Assertions.assertEquals("OBJECT", object);
+ Assertions.assertEquals("ENV", env);
+ Assertions.assertEquals("COST", cost);
+ Assertions.assertEquals("UDF", udf);
+ Assertions.assertEquals("Variable", variable);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/DBTypeTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/DBTypeTest.java
new file mode 100644
index 000000000..6516f1c76
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/DBTypeTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.cs.common.entity.enumeration;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class DBTypeTest {
+
+ @Test
+ @DisplayName("enumTest")
+ public void enumTest() {
+
+ String cs = DBType.CS.toString();
+ String hive = DBType.HIVE.toString();
+ String mide = DBType.MIDE.toString();
+ String es = DBType.ES.toString();
+
+ Assertions.assertEquals("CS", cs);
+ Assertions.assertEquals("HIVE", hive);
+ Assertions.assertEquals("MIDE", mide);
+ Assertions.assertEquals("ES", es);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/ExpireTypeTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/ExpireTypeTest.java
new file mode 100644
index 000000000..22ab0a71c
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/ExpireTypeTest.java
@@ -0,0 +1,38 @@
+/*
+ * 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.cs.common.entity.enumeration;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class ExpireTypeTest {
+
+ @Test
+ @DisplayName("enumTest")
+ public void enumTest() {
+
+ Integer todayId = ExpireType.TODAY.getId();
+ Integer maxExistsTimeId = ExpireType.MAX_EXISTS_TIME.getId();
+ Integer neverId = ExpireType.NEVER.getId();
+
+ Assertions.assertTrue(0 == todayId.intValue());
+ Assertions.assertTrue(1 == maxExistsTimeId.intValue());
+ Assertions.assertTrue(2 == neverId.intValue());
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/WorkTypeTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/WorkTypeTest.java
new file mode 100644
index 000000000..e9e8bc379
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/entity/enumeration/WorkTypeTest.java
@@ -0,0 +1,40 @@
+/*
+ * 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.cs.common.entity.enumeration;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class WorkTypeTest {
+
+ @Test
+ @DisplayName("enumTest")
+ public void enumTest() {
+
+ String workSpace = WorkType.WORKSPACE.toString();
+ String project = WorkType.PROJECT.toString();
+ String flow = WorkType.FLOW.toString();
+ String node = WorkType.NODE.toString();
+
+ Assertions.assertEquals("WORKSPACE", workSpace);
+ Assertions.assertEquals("PROJECT", project);
+ Assertions.assertEquals("FLOW", flow);
+ Assertions.assertEquals("NODE", node);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextHistoryTypeTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextHistoryTypeTest.java
new file mode 100644
index 000000000..ce71de626
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextHistoryTypeTest.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.linkis.cs.common.protocol;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class ContextHistoryTypeTest {
+
+ @Test
+ @DisplayName("enumTest")
+ public void enumTest() {
+
+ int index = ContextHistoryType.COMMON_CONTEXT_HISTORY_TYPE.getIndex();
+ String typeName =
ContextHistoryType.COMMON_CONTEXT_HISTORY_TYPE.getTypeName();
+
+ Assertions.assertTrue(0 == index);
+
Assertions.assertEquals("org.apache.linkis.cs.common.entity.source.CommonContextID",
typeName);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextIDTypeTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextIDTypeTest.java
new file mode 100644
index 000000000..cdd5343dd
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextIDTypeTest.java
@@ -0,0 +1,43 @@
+/*
+ * 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.cs.common.protocol;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class ContextIDTypeTest {
+
+ @Test
+ @DisplayName("enumTest")
+ public void enumTest() {
+
+ int commonIndex = ContextIDType.COMMON_CONTEXT_ID_TYPE.getIndex();
+ String commonTypeName = ContextIDType.COMMON_CONTEXT_ID_TYPE.getTypeName();
+ int linkisIndex = ContextIDType.LINKIS_WORKFLOW_CONTEXT_ID_TYPE.getIndex();
+ String linkisTypeName =
ContextIDType.LINKIS_WORKFLOW_CONTEXT_ID_TYPE.getTypeName();
+
+ Assertions.assertTrue(0 == commonIndex);
+ Assertions.assertTrue(1 == linkisIndex);
+
+ Assertions.assertEquals(
+ "org.apache.linkis.cs.common.entity.source.CommonContextID",
commonTypeName);
+ Assertions.assertEquals(
+ "org.apache.linkis.cs.common.entity.source.LinkisWorkflowContextID",
linkisTypeName);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextKeyTypeTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextKeyTypeTest.java
new file mode 100644
index 000000000..cfe2da3ed
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextKeyTypeTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.cs.common.protocol;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class ContextKeyTypeTest {
+
+ @Test
+ @DisplayName("enumTest")
+ public void enumTest() {
+
+ int ymlIndex = ContextKeyType.YML_CONTEXT_KEY.getIndex();
+ String ymlTypeName = ContextKeyType.YML_CONTEXT_KEY.getTypeName();
+
+ Assertions.assertTrue(1 == ymlIndex);
+ Assertions.assertEquals(
+ "org.apache.linkis.cs.common.entity.source.CommonContextKey",
ymlTypeName);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextKeyValueTypeTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextKeyValueTypeTest.java
new file mode 100644
index 000000000..d9cd12c63
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextKeyValueTypeTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.cs.common.protocol;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class ContextKeyValueTypeTest {
+
+ @Test
+ @DisplayName("enumTest")
+ public void enumTest() {
+
+ int commonIndex = ContextKeyValueType.COMMON_CONTEXT_KV_TYPE.getIndex();
+ String commonTypeName =
ContextKeyValueType.COMMON_CONTEXT_KV_TYPE.getTypeName();
+
+ Assertions.assertTrue(0 == commonIndex);
+ Assertions.assertEquals(
+ "org.apache.linkis.cs.common.entity.source.CommonContextID",
commonTypeName);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextValueTypeTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextValueTypeTest.java
new file mode 100644
index 000000000..139766167
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/protocol/ContextValueTypeTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.cs.common.protocol;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class ContextValueTypeTest {
+
+ @Test
+ @DisplayName("enumTest")
+ public void enumTest() {
+
+ int commonIndex = ContextValueType.COMMON_CONTEXT_VALUE_TYPE.getIndex();
+ String commonTypeName =
ContextValueType.COMMON_CONTEXT_VALUE_TYPE.getTypeName();
+
+ Assertions.assertEquals(
+ "org.apache.linkis.cs.common.entity.source.CommonContextValue",
commonTypeName);
+ Assertions.assertTrue(1 == commonIndex);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/helper/ContextSerializationHelperTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/helper/ContextSerializationHelperTest.java
new file mode 100644
index 000000000..7eaf19d2c
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/helper/ContextSerializationHelperTest.java
@@ -0,0 +1,199 @@
+/*
+ * 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.cs.common.serialize.helper;
+
+import org.apache.linkis.cs.common.entity.enumeration.ContextScope;
+import org.apache.linkis.cs.common.entity.enumeration.ContextType;
+import org.apache.linkis.cs.common.entity.history.CommonResourceHistory;
+import
org.apache.linkis.cs.common.entity.history.metadata.CSTableLineageHistory;
+import
org.apache.linkis.cs.common.entity.history.metadata.CSTableMetadataContextHistory;
+import org.apache.linkis.cs.common.entity.history.metadata.TableOperationType;
+import org.apache.linkis.cs.common.entity.metadata.CSTable;
+import org.apache.linkis.cs.common.entity.metadata.Table;
+import org.apache.linkis.cs.common.entity.object.CSFlowInfos;
+import org.apache.linkis.cs.common.entity.resource.LinkisBMLResource;
+import org.apache.linkis.cs.common.entity.source.*;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class ContextSerializationHelperTest {
+
+ @Test
+ @DisplayName("initTest")
+ public void initTest() throws Exception {
+ ContextSerializationHelper contextSerializationHelper =
+ ContextSerializationHelper.getInstance();
+
+ CSTable csTable = new CSTable();
+ csTable.setCreator("hadoop");
+ csTable.setName("table1");
+
+ CSTable csTable1 = new CSTable();
+ csTable1.setCreator("hadoop");
+ csTable1.setName("table2");
+ CSTableMetadataContextHistory csTableMetadataContextHistory =
+ new CSTableMetadataContextHistory();
+ csTableMetadataContextHistory.setTable(csTable);
+ csTableMetadataContextHistory.setOperationType(TableOperationType.ACCESS);
+ csTableMetadataContextHistory.setSource("SparkEngine");
+ String serialize =
contextSerializationHelper.serialize(csTableMetadataContextHistory);
+ Object deserialize = contextSerializationHelper.deserialize(serialize);
+ Assertions.assertNotNull(deserialize);
+ }
+
+ @Test
+ @DisplayName("testLineageHistoryTest")
+ public void testLineageHistoryTest() throws Exception {
+ ContextSerializationHelper contextSerializationHelper =
+ ContextSerializationHelper.getInstance();
+ List<Table> tables = new ArrayList<>();
+ CSTable csTable = new CSTable();
+ csTable.setCreator("hadoop");
+ csTable.setName("table1");
+
+ CSTable csTable1 = new CSTable();
+ csTable1.setCreator("hadoop");
+ csTable1.setName("table2");
+ tables.add(csTable);
+ tables.add(csTable1);
+ CSTableLineageHistory history = new CSTableLineageHistory();
+ history.setSourceTables(tables);
+ history.setTable(csTable1);
+ history.setSource("test");
+ String serialize = contextSerializationHelper.serialize(history);
+ Object deserialize = contextSerializationHelper.deserialize(serialize);
+ CSTableLineageHistory deserialize1 = (CSTableLineageHistory) deserialize;
+ List<Table> sourceTables = deserialize1.getSourceTables();
+
+ Assertions.assertTrue(sourceTables.size() > 0);
+ Assertions.assertNotNull(serialize);
+ }
+
+ @Test
+ @DisplayName("testCommonResourceHistory")
+ public void testCommonResourceHistory() throws Exception {
+ ContextSerializationHelper contextSerializationHelper =
+ ContextSerializationHelper.getInstance();
+ LinkisBMLResource resource = new LinkisBMLResource();
+ resource.setResourceId("dfasdfsr2456wertg");
+ resource.setVersion("v000002");
+
+ resource.setResourceId("edtr44356-34563456");
+ resource.setVersion("v000004");
+
+ CommonResourceHistory history = new CommonResourceHistory();
+ history.setSource("history source");
+ history.setResource(resource);
+ String serialize = contextSerializationHelper.serialize(history);
+ Object deserialize = contextSerializationHelper.deserialize(serialize);
+
+ Assertions.assertNotNull(deserialize);
+ }
+
+ @Test
+ @DisplayName("testHAContextID")
+ public void testHAContextID() throws Exception {
+ ContextSerializationHelper contextSerializationHelper =
+ ContextSerializationHelper.getInstance();
+ LinkisHAWorkFlowContextID haWorkFlowContextID = new
LinkisHAWorkFlowContextID();
+ haWorkFlowContextID.setBackupInstance("test123");
+ haWorkFlowContextID.setInstance("test1234");
+ haWorkFlowContextID.setUser("hadoop");
+ haWorkFlowContextID.setContextId("hello");
+ haWorkFlowContextID.setFlow("hellof");
+ String json = contextSerializationHelper.serialize(haWorkFlowContextID);
+ String objstr =
+ "{\"type\": \"HAWorkFlowContextID\",\"value\": \"{\\n
\\\"instance\\\": null,\\n \\\"backupInstance\\\": null,\\n \\\"user\\\":
\\\"hadoop\\\",\\n \\\"workspaceID\\\": null,\\n \\\"project\\\":
\\\"test01_neiljianliu\\\",\\n \\\"flow\\\": \\\"dedede\\\",\\n
\\\"contextId\\\":
\\\"24-24--YmRwZHdzMTEwMDAxOjkxMTY\\\\u003dYmRwZHdzMTEwMDAxOjkxMTY\\\\u003d85197\\\",\\n
\\\"version\\\": \\\"v000001\\\",\\n \\\"env\\\": null\\n}\"}\n";
+ Object deserialize = contextSerializationHelper.deserialize(objstr);
+
+ Assertions.assertNotNull(json);
+ Assertions.assertNotNull(deserialize);
+ }
+
+ @Test
+ @DisplayName("testCSFlowInfos")
+ public void testCSFlowInfos() throws Exception {
+ ContextSerializationHelper contextSerializationHelper =
+ ContextSerializationHelper.getInstance();
+ CommonContextValue contextValue = new CommonContextValue();
+ contextValue.setKeywords("test.123.test");
+
+ Map<String, Object> infos = new HashMap<>();
+ List<Map<String, String>> edges = new ArrayList<>();
+ for (int i = 0; i < 10; i++) {
+ Map<String, String> edge = new HashMap<>();
+ edge.put("source", "job_export_tb1_crdtloan " + i);
+ edge.put("target", "job_export_tb1_crdtloan");
+ edge.put("sourceLocation", "top");
+ edge.put("targetLocation", "left");
+ edges.add(edge);
+ }
+ infos.put("edges", edges);
+ infos.put("parent", "flow2");
+ Map<String, String> idNodeName = new HashMap<>();
+ idNodeName.put("12345", "job_export_tb1_crdtloan");
+ infos.put("id_nodeName", idNodeName);
+ CSFlowInfos csFlowInfos = new CSFlowInfos();
+ csFlowInfos.setInfos(infos);
+ contextValue.setValue(csFlowInfos);
+ Object deserialize =
+
contextSerializationHelper.deserialize(contextSerializationHelper.serialize(contextValue));
+ ContextValue contextValue1 = (ContextValue) deserialize;
+ CSFlowInfos value1 = (CSFlowInfos) contextValue1.getValue();
+
+ Assertions.assertNotNull(value1);
+ }
+
+ @Test
+ @DisplayName("testSrialzer")
+ public void testSrialzer() throws Exception {
+ ContextSerializationHelper contextSerializationHelper =
+ ContextSerializationHelper.getInstance();
+
+ CommonContextKey contextKey = new CommonContextKey();
+ contextKey.setContextScope(ContextScope.FRIENDLY);
+ contextKey.setContextType(ContextType.OBJECT);
+ contextKey.setKey("test");
+
+ LinkisBMLResource linkisBMLResource = new LinkisBMLResource();
+ linkisBMLResource.setResourceId("12345");
+ linkisBMLResource.setVersion("v01");
+
+ CommonContextValue contextValue = new CommonContextValue();
+ contextValue.setKeywords("test.123.test");
+ contextValue.setValue(linkisBMLResource);
+
+ CommonContextKeyValue contextKeyValue = new CommonContextKeyValue();
+
+ contextKeyValue.setContextKey(contextKey);
+ contextKeyValue.setContextValue(contextValue);
+
+ String json = contextSerializationHelper.serialize(contextKeyValue);
+ Object obj = contextSerializationHelper.deserialize(json);
+
+ Assertions.assertNotNull(json);
+ Assertions.assertNotNull(obj);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/context/CombinedNodeIDContextIDSerializerTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/context/CombinedNodeIDContextIDSerializerTest.java
new file mode 100644
index 000000000..914b47da0
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/context/CombinedNodeIDContextIDSerializerTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.cs.common.serialize.impl.context;
+
+import org.apache.linkis.cs.common.entity.source.CombinedNodeIDContextID;
+import org.apache.linkis.cs.common.exception.CSErrorException;
+
+import com.google.gson.Gson;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class CombinedNodeIDContextIDSerializerTest {
+
+ @Test
+ @DisplayName("getTypeTest")
+ public void getTypeTest() {
+
+ CombinedNodeIDContextIDSerializer serializer = new
CombinedNodeIDContextIDSerializer();
+ String type = serializer.getType();
+ Assertions.assertNotNull(type);
+ }
+
+ @Test
+ @DisplayName("acceptsTest")
+ public void acceptsTest() {
+
+ CombinedNodeIDContextID contextID = new CombinedNodeIDContextID();
+ CombinedNodeIDContextIDSerializer serializer = new
CombinedNodeIDContextIDSerializer();
+ boolean accepts = serializer.accepts(contextID);
+ Assertions.assertTrue(accepts);
+ }
+
+ @Test
+ @DisplayName("fromJsonTest")
+ public void fromJsonTest() throws CSErrorException {
+
+ CombinedNodeIDContextID combinedNodeIDContextID = new
CombinedNodeIDContextID();
+ combinedNodeIDContextID.setNodeID("node123");
+ CombinedNodeIDContextIDSerializer serializer = new
CombinedNodeIDContextIDSerializer();
+ CombinedNodeIDContextID json = serializer.fromJson(new
Gson().toJson(combinedNodeIDContextID));
+ Assertions.assertNotNull(json);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/context/CommonContextKeySerializerTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/context/CommonContextKeySerializerTest.java
new file mode 100644
index 000000000..60b2acfe0
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/context/CommonContextKeySerializerTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.cs.common.serialize.impl.context;
+
+import org.apache.linkis.cs.common.entity.source.CommonContextKey;
+import org.apache.linkis.cs.common.exception.CSErrorException;
+
+import com.google.gson.Gson;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class CommonContextKeySerializerTest {
+
+ @Test
+ @DisplayName("getTypeTest")
+ public void getTypeTest() {
+
+ CommonContextKeySerializer commonContextKeySerializer = new
CommonContextKeySerializer();
+ String type = commonContextKeySerializer.getType();
+ Assertions.assertNotNull(type);
+ }
+
+ @Test
+ @DisplayName("acceptsTest")
+ public void acceptsTest() {
+
+ CommonContextKey commonContextKey = new CommonContextKey();
+ CommonContextKeySerializer commonContextKeySerializer = new
CommonContextKeySerializer();
+ boolean accepts = commonContextKeySerializer.accepts(commonContextKey);
+ Assertions.assertTrue(accepts);
+ }
+
+ @Test
+ @DisplayName("fromJsonTest")
+ public void fromJsonTest() throws CSErrorException {
+
+ CommonContextKey commonContextKey = new CommonContextKey();
+ commonContextKey.setKey("key");
+
+ CommonContextKeySerializer serializer = new CommonContextKeySerializer();
+ CommonContextKey json = serializer.fromJson(new
Gson().toJson(commonContextKey));
+ Assertions.assertNotNull(json);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/LinkisBMLResourceSerializerTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/LinkisBMLResourceSerializerTest.java
new file mode 100644
index 000000000..282f239b5
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/LinkisBMLResourceSerializerTest.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.linkis.cs.common.serialize.impl.value;
+
+import org.apache.linkis.cs.common.entity.resource.LinkisBMLResource;
+import org.apache.linkis.cs.common.exception.CSErrorException;
+
+import com.google.gson.Gson;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class LinkisBMLResourceSerializerTest {
+
+ @Test
+ @DisplayName("getTypeTest")
+ public void getTypeTest() {
+
+ LinkisBMLResourceSerializer bmlResourceSerializer = new
LinkisBMLResourceSerializer();
+ String type = bmlResourceSerializer.getType();
+ Assertions.assertNotNull(type);
+ }
+
+ @Test
+ @DisplayName("fromJsonTest")
+ public void fromJsonTest() throws CSErrorException {
+
+ LinkisBMLResource linkisBMLResource = new LinkisBMLResource();
+ linkisBMLResource.setUser("hadoop");
+ linkisBMLResource.setResourceId("12345678");
+
+ String json = new Gson().toJson(linkisBMLResource);
+
+ LinkisBMLResourceSerializer bmlResourceSerializer = new
LinkisBMLResourceSerializer();
+ LinkisBMLResource resource = bmlResourceSerializer.fromJson(json);
+
+ Assertions.assertNotNull(resource);
+ }
+
+ @Test
+ @DisplayName("acceptsTest")
+ public void acceptsTest() {
+ LinkisBMLResource linkisBMLResource = new LinkisBMLResource();
+ LinkisBMLResourceSerializer bmlResourceSerializer = new
LinkisBMLResourceSerializer();
+ boolean accepts = bmlResourceSerializer.accepts(linkisBMLResource);
+ Assertions.assertTrue(accepts);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/data/CSResultDataSerializerTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/data/CSResultDataSerializerTest.java
new file mode 100644
index 000000000..8a7b3a918
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/data/CSResultDataSerializerTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.cs.common.serialize.impl.value.data;
+
+import org.apache.linkis.cs.common.entity.data.CSResultData;
+import org.apache.linkis.cs.common.exception.CSErrorException;
+
+import com.google.gson.Gson;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class CSResultDataSerializerTest {
+
+ @Test
+ @DisplayName("getTypeTest")
+ public void getTypeTest() {
+
+ CSResultDataSerializer csResultDataSerializer = new
CSResultDataSerializer();
+ String type = csResultDataSerializer.getType();
+ Assertions.assertNotNull(type);
+ }
+
+ @Test
+ @DisplayName("fromJsonTest")
+ public void fromJsonTest() throws CSErrorException {
+
+ CSResultData csResultData = new CSResultData();
+ String json = new Gson().toJson(csResultData);
+ CSResultDataSerializer csResultDataSerializer = new
CSResultDataSerializer();
+ CSResultData resultData = csResultDataSerializer.fromJson(json);
+ Assertions.assertNotNull(resultData);
+ }
+
+ @Test
+ @DisplayName("acceptsTest")
+ public void acceptsTest() {
+
+ CSResultData csResultData = new CSResultData();
+ CSResultDataSerializer csResultDataSerializer = new
CSResultDataSerializer();
+ boolean accepts = csResultDataSerializer.accepts(csResultData);
+
+ Assertions.assertTrue(accepts);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/data/LinkisJobDataSerializerTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/data/LinkisJobDataSerializerTest.java
new file mode 100644
index 000000000..171d21e3d
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/data/LinkisJobDataSerializerTest.java
@@ -0,0 +1,61 @@
+/*
+ * 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.cs.common.serialize.impl.value.data;
+
+import org.apache.linkis.cs.common.entity.data.LinkisJobData;
+import org.apache.linkis.cs.common.exception.CSErrorException;
+
+import com.google.gson.Gson;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class LinkisJobDataSerializerTest {
+
+ @Test
+ @DisplayName("getTypeTest")
+ public void getTypeTest() {
+
+ LinkisJobDataSerializer serializer = new LinkisJobDataSerializer();
+ String type = serializer.getType();
+ Assertions.assertNotNull(type);
+ }
+
+ @Test
+ @DisplayName("fromJsonTest")
+ public void fromJsonTest() throws CSErrorException {
+
+ LinkisJobData linkisJobData = new LinkisJobData();
+ linkisJobData.setJobID(1L);
+
+ LinkisJobDataSerializer serializer = new LinkisJobDataSerializer();
+ LinkisJobData jobData = serializer.fromJson(new
Gson().toJson(linkisJobData));
+
+ Assertions.assertNotNull(jobData);
+ }
+
+ @Test
+ @DisplayName("acceptsTest")
+ public void acceptsTest() {
+
+ LinkisJobData linkisJobData = new LinkisJobData();
+ LinkisJobDataSerializer serializer = new LinkisJobDataSerializer();
+ boolean accepts = serializer.accepts(linkisJobData);
+ Assertions.assertTrue(accepts);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/metadata/CSTableSerializerTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/metadata/CSTableSerializerTest.java
new file mode 100644
index 000000000..fa717cc7f
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/metadata/CSTableSerializerTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.cs.common.serialize.impl.value.metadata;
+
+import org.apache.linkis.cs.common.entity.metadata.CSTable;
+import org.apache.linkis.cs.common.exception.CSErrorException;
+
+import com.google.gson.Gson;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class CSTableSerializerTest {
+
+ @Test
+ @DisplayName("getTypeTest")
+ public void getTypeTest() {
+
+ CSTableSerializer csTableSerializer = new CSTableSerializer();
+ String type = csTableSerializer.getType();
+ Assertions.assertNotNull(type);
+ }
+
+ @Test
+ @DisplayName("fromJsonTest")
+ public void fromJsonTest() throws CSErrorException {
+
+ CSTable csTable = new CSTable();
+ csTable.setName("flow1");
+ csTable.setAlias("flow1");
+ csTable.setAvailable(true);
+ csTable.setCreator("hadoop");
+
+ CSTableSerializer csTableSerializer = new CSTableSerializer();
+ CSTable json = csTableSerializer.fromJson(new Gson().toJson(csTable));
+
+ Assertions.assertNotNull(json);
+ }
+
+ @Test
+ @DisplayName("acceptsTest")
+ public void acceptsTest() {
+
+ CSTable csTable = new CSTable();
+ CSTableSerializer csTableSerializer = new CSTableSerializer();
+
+ boolean accepts = csTableSerializer.accepts(csTable);
+ Assertions.assertTrue(accepts);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/object/CSFlowInfosSerializerTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/object/CSFlowInfosSerializerTest.java
new file mode 100644
index 000000000..4c6e656de
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/serialize/impl/value/object/CSFlowInfosSerializerTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.cs.common.serialize.impl.value.object;
+
+import org.apache.linkis.cs.common.entity.object.CSFlowInfos;
+import org.apache.linkis.cs.common.exception.CSErrorException;
+
+import com.google.gson.Gson;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class CSFlowInfosSerializerTest {
+
+ @Test
+ @DisplayName("getTypeTest")
+ public void getTypeTest() {
+
+ CSFlowInfosSerializer csFlowInfosSerializer = new CSFlowInfosSerializer();
+ String type = csFlowInfosSerializer.getType();
+ Assertions.assertNotNull(type);
+ }
+
+ @Test
+ @DisplayName("fromJsonTest")
+ public void fromJsonTest() throws CSErrorException {
+
+ CSFlowInfos csFlowInfos = new CSFlowInfos();
+ CSFlowInfosSerializer csFlowInfosSerializer = new CSFlowInfosSerializer();
+ CSFlowInfos json = csFlowInfosSerializer.fromJson(new
Gson().toJson(csFlowInfos));
+ Assertions.assertNotNull(json);
+ }
+
+ @Test
+ @DisplayName("acceptsTest")
+ public void acceptsTest() {
+ CSFlowInfos csFlowInfos = new CSFlowInfos();
+ CSFlowInfosSerializer csFlowInfosSerializer = new CSFlowInfosSerializer();
+ boolean accepts = csFlowInfosSerializer.accepts(csFlowInfos);
+ Assertions.assertTrue(accepts);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/utils/CSCommonUtilsTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/utils/CSCommonUtilsTest.java
new file mode 100644
index 000000000..216664fb5
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/utils/CSCommonUtilsTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.cs.common.utils;
+
+import java.time.LocalDateTime;
+import java.util.Date;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class CSCommonUtilsTest {
+
+ @Test
+ @DisplayName("constTest")
+ public void constTest() {
+
+ String contextIdStr = CSCommonUtils.CONTEXT_ID_STR;
+ String nodeNameStr = CSCommonUtils.NODE_NAME_STR;
+ String nodeId = CSCommonUtils.NODE_ID;
+ String idNodeName = CSCommonUtils.ID_NODE_NAME;
+ String flowInfos = CSCommonUtils.FLOW_INFOS;
+ String contextEnvDev = CSCommonUtils.CONTEXT_ENV_DEV;
+ String contextEnvProd = CSCommonUtils.CONTEXT_ENV_PROD;
+
+ Assertions.assertEquals("contextID", contextIdStr);
+ Assertions.assertEquals("nodeName", nodeNameStr);
+ Assertions.assertEquals("nodeID", nodeId);
+ Assertions.assertEquals("id_nodeName", idNodeName);
+ Assertions.assertEquals("flow.infos", flowInfos);
+ Assertions.assertEquals("BDP_DEV", contextEnvDev);
+ Assertions.assertEquals("BDAP_PROD", contextEnvProd);
+ }
+
+ @Test
+ @DisplayName("getTableKeyTest")
+ public void getTableKeyTest() {
+
+ String tableKey = CSCommonUtils.getTableKey("node1", "table1");
+ Assertions.assertNotNull(tableKey);
+ }
+
+ @Test
+ @DisplayName("localDatetimeToDateTest")
+ public void localDatetimeToDateTest() {
+
+ LocalDateTime now = LocalDateTime.now();
+ Date date = CSCommonUtils.localDatetimeToDate(now);
+
+ Assertions.assertNotNull(date);
+ }
+}
diff --git
a/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/utils/CSHighAvailableUtilsTest.java
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/utils/CSHighAvailableUtilsTest.java
new file mode 100644
index 000000000..6af466835
--- /dev/null
+++
b/linkis-public-enhancements/linkis-context-service/linkis-cs-common/src/test/java/org/apache/linkis/cs/common/utils/CSHighAvailableUtilsTest.java
@@ -0,0 +1,64 @@
+/*
+ * 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.cs.common.utils;
+
+import org.apache.linkis.cs.common.exception.CSErrorException;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.google.gson.Gson;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.api.Test;
+
+public class CSHighAvailableUtilsTest {
+
+ @Test
+ @DisplayName("checkHAIDBasicFormatTest")
+ public void checkHAIDBasicFormatTest() {
+
+ String haid =
"24--24--YmRwaGRwMTFpZGUwMTo5MTE2YmRwaGRwMTFpZGUwMTo5MTE084835";
+ boolean checkHAIDBasicFormat =
CSHighAvailableUtils.checkHAIDBasicFormat(haid);
+ Assertions.assertFalse(checkHAIDBasicFormat);
+ }
+
+ @Test
+ @DisplayName("encodeHAIDKeyTest")
+ public void encodeHAIDKeyTest() throws CSErrorException {
+
+ String id = "8798";
+ String instance = "jslfjslfjlsdjfljsdf==+";
+ String backupInstance = "sjljsljflsdjflsjd";
+ List<String> list = new ArrayList<>();
+ list.add(backupInstance);
+ list.add(instance);
+ String haid2 = CSHighAvailableUtils.encodeHAIDKey(id, instance, list);
+ Assertions.assertNotNull(haid2);
+ }
+
+ @Test
+ @DisplayName("decodeHAIDTest")
+ public void decodeHAIDTest() throws CSErrorException {
+
+ String haid3 =
"24-24--YmRwaGRwMTFpZGUwMTo5MTE0YmRwaGRwMTFpZGUwMTo5MTE084855";
+ String haidStr = new Gson().toJson(CSHighAvailableUtils.decodeHAID(haid3));
+
+ Assertions.assertNotNull(haidStr);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]