This is an automated email from the ASF dual-hosted git repository.
duanzhengqiang 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 abba635 Add unit test for GeneratedKeyAssignmentToken#toString
(#16169)
abba635 is described below
commit abba6352c3e0d30af7fec1b1203829e550213154
Author: 龙台 Long Tai <[email protected]>
AuthorDate: Fri Mar 18 18:46:41 2022 +0800
Add unit test for GeneratedKeyAssignmentToken#toString (#16169)
* Add read-write splitting to obtain write data source unit test (#15801)
* Modify the unit test method name of read-write splitting to obtain write
data source (#16140)
* Fix cursor position (#15801)
* Add unit test for GeneratedKeyAssignmentToken#toString (#16095)
* Add one more test case for parameter-marker (#16095)
---
.../pojo/GeneratedKeyAssignmentTokenTest.java | 61 ++++++++++++++++++++++
1 file changed, 61 insertions(+)
diff --git
a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/GeneratedKeyAssignmentTokenTest.java
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/GeneratedKeyAssignmentTokenTest.java
new file mode 100644
index 0000000..cf08849
--- /dev/null
+++
b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/test/java/org/apache/shardingsphere/sharding/rewrite/token/pojo/GeneratedKeyAssignmentTokenTest.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.shardingsphere.sharding.rewrite.token.pojo;
+
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public final class GeneratedKeyAssignmentTokenTest {
+
+ private GeneratedKeyAssignmentToken generatedKeyAssignmentToken;
+
+ @Test
+ public void assertCustomGeneratedKeyAssignmentTokenToString() {
+ generatedKeyAssignmentToken = new GeneratedKeyAssignmentToken(0, "id")
{
+ @Override
+ protected String getRightValue() {
+ return "0";
+ }
+ };
+ String resultGeneratedKeyAssignmentTokenToString =
generatedKeyAssignmentToken.toString();
+ assertThat(resultGeneratedKeyAssignmentTokenToString, is(", id = 0"));
+ }
+
+ @Test
+ public void assertLiteralGeneratedKeyAssignmentTokenToString() {
+ generatedKeyAssignmentToken = new
LiteralGeneratedKeyAssignmentToken(0, "id", "0");
+ String resultLiteralGeneratedKeyAssignmentTokenToString =
generatedKeyAssignmentToken.toString();
+ assertThat(resultLiteralGeneratedKeyAssignmentTokenToString, is(", id
= '0'"));
+ }
+
+ @Test
+ public void assertLiteralGeneratedKeyAssignmentTokenByIntToString() {
+ generatedKeyAssignmentToken = new
LiteralGeneratedKeyAssignmentToken(0, "id", 0);
+ String resultLiteralGeneratedKeyAssignmentTokenToString =
generatedKeyAssignmentToken.toString();
+ assertThat(resultLiteralGeneratedKeyAssignmentTokenToString, is(", id
= 0"));
+ }
+
+ @Test
+ public void assertParameterMarkerGeneratedKeyAssignmentTokenToString() {
+ generatedKeyAssignmentToken = new
ParameterMarkerGeneratedKeyAssignmentToken(0, "id");
+ String resultParameterMarkerGeneratedKeyAssignmentTokenToString =
generatedKeyAssignmentToken.toString();
+ assertThat(resultParameterMarkerGeneratedKeyAssignmentTokenToString,
is(", id = ?"));
+ }
+}