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 736d082ba [linkis-label-common] unit test (#3731)
736d082ba is described below
commit 736d082ba57a4500142fe7b8f7d1397d8e45d472
Author: 成彬彬 <[email protected]>
AuthorDate: Tue Nov 22 10:11:47 2022 +0800
[linkis-label-common] unit test (#3731)
* unit test
* delete ElasticConnectionTest.java
* Remove unnecessary unit tests
---
.../label/builder/CombinedLabelBuilderTest.java | 53 +++++++++++++++
.../factory/StdLabelBuilderFactoryTest.java | 76 ++++++++++++++++++++++
.../label/utils/EngineTypeLabelCreatorTest.java | 38 +++++++++++
.../linkis/manager/label/utils/LabelUtilsTest.java | 58 +++++++++++++++++
4 files changed, 225 insertions(+)
diff --git
a/linkis-computation-governance/linkis-manager/linkis-label-common/src/test/java/org/apache/linkis/manager/label/builder/CombinedLabelBuilderTest.java
b/linkis-computation-governance/linkis-manager/linkis-label-common/src/test/java/org/apache/linkis/manager/label/builder/CombinedLabelBuilderTest.java
new file mode 100644
index 000000000..9c81f6640
--- /dev/null
+++
b/linkis-computation-governance/linkis-manager/linkis-label-common/src/test/java/org/apache/linkis/manager/label/builder/CombinedLabelBuilderTest.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.manager.label.builder;
+
+import org.apache.linkis.manager.label.constant.LabelKeyConstant;
+import org.apache.linkis.manager.label.entity.Label;
+import org.apache.linkis.manager.label.entity.engine.UserCreatorLabel;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.*;
+
+/** CombinedLabelBuilder Tester */
+@SpringBootTest(classes = {CombinedLabelBuilder.class})
+public class CombinedLabelBuilderTest {
+
+ @Autowired CombinedLabelBuilder combinedLabelBuilder;
+
+ @Test
+ public void testCanBuild() throws Exception {
+ boolean flag =
combinedLabelBuilder.canBuild(LabelKeyConstant.COMBINED_LABEL_KEY_PREFIX);
+ Assertions.assertTrue(flag);
+ }
+
+ @Test
+ public void testBuild() throws Exception {
+ UserCreatorLabel userCreatorLabel1 = new UserCreatorLabel();
+ userCreatorLabel1.setLabelKey("testLabelKey1");
+ List<Label<?>> labels1 = new ArrayList<>();
+ labels1.add(userCreatorLabel1);
+ Label<?> label = combinedLabelBuilder.build("testLabelKey", labels1);
+
Assertions.assertTrue(label.getLabelKey().equals("combined_testLabelKey1"));
+ }
+}
diff --git
a/linkis-computation-governance/linkis-manager/linkis-label-common/src/test/java/org/apache/linkis/manager/label/builder/factory/StdLabelBuilderFactoryTest.java
b/linkis-computation-governance/linkis-manager/linkis-label-common/src/test/java/org/apache/linkis/manager/label/builder/factory/StdLabelBuilderFactoryTest.java
new file mode 100644
index 000000000..8d0b1e4de
--- /dev/null
+++
b/linkis-computation-governance/linkis-manager/linkis-label-common/src/test/java/org/apache/linkis/manager/label/builder/factory/StdLabelBuilderFactoryTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.manager.label.builder.factory;
+
+import org.apache.linkis.manager.label.builder.CombinedLabelBuilder;
+import org.apache.linkis.manager.label.builder.LabelBuilder;
+import org.apache.linkis.manager.label.entity.em.EMInstanceLabel;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import org.junit.jupiter.api.*;
+
+/** StdLabelBuilderFactory Tester */
+@SpringBootTest(classes = {StdLabelBuilderFactory.class})
+public class StdLabelBuilderFactoryTest {
+
+ @Autowired StdLabelBuilderFactory stdLabelBuilderFactory;
+
+ @Test
+ public void testRegisterLabelBuilder() throws Exception {
+ LabelBuilder labelBuilder = new CombinedLabelBuilder();
+ stdLabelBuilderFactory.registerLabelBuilder(labelBuilder);
+ }
+
+ @Test
+ public void testCreateLabelOutLabelClass() throws Exception {
+ EMInstanceLabel emInstanceLabel = new EMInstanceLabel();
+ emInstanceLabel.setLabelKey("testLabelKey");
+ EMInstanceLabel emInstanceLabel1 =
stdLabelBuilderFactory.createLabel(EMInstanceLabel.class);
+ Assertions.assertTrue(emInstanceLabel1.getLabelKey().equals("emInstance"));
+ }
+
+ @Test
+ public void testCreateLabelForOutLabelClassOutValueTypes() throws Exception {
+ EMInstanceLabel emInstanceLabel = new EMInstanceLabel();
+ emInstanceLabel.setLabelKey("testLabelKey");
+ EMInstanceLabel emInstanceLabel1 =
+ stdLabelBuilderFactory.createLabel(EMInstanceLabel.class, null);
+ Assertions.assertTrue(emInstanceLabel1.getLabelKey().equals("emInstance"));
+ }
+
+ @Test
+ public void testCreateLabelForInLabelKeyInValueObjOutLabelClass() throws
Exception {
+ EMInstanceLabel emInstanceLabel = new EMInstanceLabel();
+ emInstanceLabel.setLabelKey("testLabelKey");
+ EMInstanceLabel emInstanceLabel1 =
+ stdLabelBuilderFactory.createLabel("testLabelKey", emInstanceLabel,
EMInstanceLabel.class);
+ Assertions.assertTrue(emInstanceLabel1.getLabelKey().equals("emInstance"));
+ }
+
+ @Test
+ public void
testCreateLabelForInLabelKeyInValueStreamOutLabelClassOutValueTypes()
+ throws Exception {
+ EMInstanceLabel emInstanceLabel = new EMInstanceLabel();
+ emInstanceLabel.setLabelKey("testLabelKey");
+ EMInstanceLabel emInstanceLabel1 =
+ stdLabelBuilderFactory.createLabel("testLabelKey", null,
EMInstanceLabel.class, null);
+ Assertions.assertTrue(emInstanceLabel1.getLabelKey().equals("emInstance"));
+ }
+}
diff --git
a/linkis-computation-governance/linkis-manager/linkis-label-common/src/test/java/org/apache/linkis/manager/label/utils/EngineTypeLabelCreatorTest.java
b/linkis-computation-governance/linkis-manager/linkis-label-common/src/test/java/org/apache/linkis/manager/label/utils/EngineTypeLabelCreatorTest.java
new file mode 100644
index 000000000..b3bde5c40
--- /dev/null
+++
b/linkis-computation-governance/linkis-manager/linkis-label-common/src/test/java/org/apache/linkis/manager/label/utils/EngineTypeLabelCreatorTest.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.manager.label.utils;
+
+import org.apache.linkis.manager.label.entity.engine.EngineTypeLabel;
+
+import org.springframework.beans.factory.annotation.Autowired;
+
+import org.junit.jupiter.api.*;
+
+/** EngineTypeLabelCreator Tester */
+public class EngineTypeLabelCreatorTest {
+
+ @Autowired private EngineTypeLabelCreator engineTypeLabelCreator;
+
+ @Test
+ public void testCreateEngineTypeLabel() throws Exception {
+ EngineTypeLabelCreator.registerVersion("testType", "1.1.1");
+ String type = "testType";
+ EngineTypeLabel engineTypeLabel =
EngineTypeLabelCreator.createEngineTypeLabel(type);
+ Assertions.assertTrue(engineTypeLabel.getEngineType().equals(type));
+ }
+}
diff --git
a/linkis-computation-governance/linkis-manager/linkis-label-common/src/test/java/org/apache/linkis/manager/label/utils/LabelUtilsTest.java
b/linkis-computation-governance/linkis-manager/linkis-label-common/src/test/java/org/apache/linkis/manager/label/utils/LabelUtilsTest.java
new file mode 100644
index 000000000..b0619aee0
--- /dev/null
+++
b/linkis-computation-governance/linkis-manager/linkis-label-common/src/test/java/org/apache/linkis/manager/label/utils/LabelUtilsTest.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.manager.label.utils;
+
+import org.apache.linkis.manager.label.entity.Label;
+import org.apache.linkis.manager.label.entity.engine.UserCreatorLabel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.jupiter.api.*;
+
+/** LabelUtils Tester */
+public class LabelUtilsTest {
+
+ @Test
+ public void testIsBasicType() throws Exception {
+ boolean flag = LabelUtils.isBasicType(String.class);
+ Assertions.assertTrue(flag);
+ }
+
+ @Test
+ public void testGetOrderedValueNameInLabelClass() throws Exception {
+ String[] VALUE_METHOD_PREFIX = new String[] {"is", "get", "set"};
+ List<String> list =
+ LabelUtils.getOrderedValueNameInLabelClass(this.getClass(),
VALUE_METHOD_PREFIX);
+ Assertions.assertTrue(list.isEmpty());
+ }
+
+ @Test
+ public void testDistinctLabel() throws Exception {
+ UserCreatorLabel userCreatorLabel1 = new UserCreatorLabel();
+ userCreatorLabel1.setLabelKey("testLabelKey1");
+ UserCreatorLabel userCreatorLabel2 = new UserCreatorLabel();
+ userCreatorLabel2.setLabelKey("testLabelKey1");
+ List<Label<?>> labels1 = new ArrayList<>();
+ labels1.add(userCreatorLabel1);
+ List<Label<?>> labels2 = new ArrayList<>();
+ labels2.add(userCreatorLabel2);
+ List<Label<?>> labels3 = LabelUtils.distinctLabel(labels1, labels2);
+ Assertions.assertTrue(labels3.size() == 1);
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]