This is an automated email from the ASF dual-hosted git repository.
zhangliang 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 d7389cf7dc5 Add more test cases on DecoratorMergedResult (#33180)
d7389cf7dc5 is described below
commit d7389cf7dc5d587c7158c8c3e362e37717acec1a
Author: Liang Zhang <[email protected]>
AuthorDate: Wed Oct 9 12:31:52 2024 +0800
Add more test cases on DecoratorMergedResult (#33180)
---
.../impl/decorator/DecoratorMergedResultTest.java | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git
a/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/result/impl/decorator/DecoratorMergedResultTest.java
b/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/result/impl/decorator/DecoratorMergedResultTest.java
index 8fd189a46ab..50559ef9fa9 100644
---
a/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/result/impl/decorator/DecoratorMergedResultTest.java
+++
b/infra/merge/src/test/java/org/apache/shardingsphere/infra/merge/result/impl/decorator/DecoratorMergedResultTest.java
@@ -25,14 +25,16 @@ import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
+import java.io.InputStream;
+import java.io.Reader;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ExtendWith(MockitoExtension.class)
@@ -49,21 +51,30 @@ class DecoratorMergedResultTest {
}
@Test
- void assertGetValueWithColumnIndex() throws SQLException {
+ void assertGetValue() throws SQLException {
when(mergedResult.getValue(1, Object.class)).thenReturn("1");
assertThat(decoratorMergedResult.getValue(1, Object.class).toString(),
is("1"));
}
@Test
- void assertGetCalenderValueWithColumnIndex() throws SQLException {
+ void assertGetCalenderValue() throws SQLException {
Calendar calendar = Calendar.getInstance();
when(mergedResult.getCalendarValue(1, Date.class,
calendar)).thenReturn(new Date(0L));
assertThat(decoratorMergedResult.getCalendarValue(1, Date.class,
calendar), is(new Date(0L)));
}
@Test
- void assertGetInputStreamWithColumnIndex() throws SQLException {
- assertNull(decoratorMergedResult.getInputStream(1, "ascii"));
+ void assertGetInputStream() throws SQLException {
+ InputStream inputStream = mock(InputStream.class);
+ when(mergedResult.getInputStream(1, "ascii")).thenReturn(inputStream);
+ assertThat(decoratorMergedResult.getInputStream(1, "ascii"),
is(inputStream));
+ }
+
+ @Test
+ void assertGetCharacterStream() throws SQLException {
+ Reader reader = mock(Reader.class);
+ when(mergedResult.getCharacterStream(1)).thenReturn(reader);
+ assertThat(decoratorMergedResult.getCharacterStream(1), is(reader));
}
@Test