This is an automated email from the ASF dual-hosted git repository.
zhonghongsheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new 76201c6 Add unit test for PipelineTableMetaData (#15803)
76201c6 is described below
commit 76201c6c8135eaf3b0b671e804e809aa33441210
Author: Pankaj Khushalani <[email protected]>
AuthorDate: Sun Mar 6 13:53:08 2022 +0530
Add unit test for PipelineTableMetaData (#15803)
---
.../metadata/model/PipelineTableMetaDataTest.java | 65 ++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git
a/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/model/PipelineTableMetaDataTest.java
b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/model/PipelineTableMetaDataTest.java
new file mode 100644
index 0000000..23049f6
--- /dev/null
+++
b/shardingsphere-test/shardingsphere-pipeline-test/src/test/java/org/apache/shardingsphere/data/pipeline/core/metadata/model/PipelineTableMetaDataTest.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.shardingsphere.data.pipeline.core.metadata.model;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+
+import java.sql.Types;
+import java.util.Collections;
+
+public final class PipelineTableMetaDataTest {
+
+ private PipelineTableMetaData pipelineTableMetaData;
+
+ @Before
+ public void setUp() {
+ pipelineTableMetaData = new PipelineTableMetaData("test_data",
Collections.singletonMap("test", new PipelineColumnMetaData(1, "test",
Types.INTEGER, "INTEGER", true)));
+ }
+
+ @Test
+ public void assertGetColumnMetaDataGivenColumnIndex() {
+ PipelineColumnMetaData actual =
pipelineTableMetaData.getColumnMetaData(0);
+ assertThat(actual.getOrdinalPosition(), is(1));
+ assertThat(actual.getName(), is("test"));
+ assertThat(actual.getDataType(), is(Types.INTEGER));
+ assertTrue(actual.isPrimaryKey());
+ }
+
+ @Test
+ public void assertGetColumnMetaDataGivenColumnName() {
+ PipelineColumnMetaData actual =
pipelineTableMetaData.getColumnMetaData("test");
+ assertNull(pipelineTableMetaData.getColumnMetaData("non_exist"));
+ assertThat(actual.getOrdinalPosition(), is(1));
+ assertThat(actual.getName(), is("test"));
+ assertThat(actual.getDataType(), is(Types.INTEGER));
+ assertTrue(actual.isPrimaryKey());
+ }
+
+ @Test
+ public void assertIsPrimaryKey() {
+ assertTrue(pipelineTableMetaData.isPrimaryKey(0));
+ assertFalse(pipelineTableMetaData.isPrimaryKey(1));
+ }
+}