|
25 | 25 | import java.util.Arrays;
|
26 | 26 | import java.util.Collections;
|
27 | 27 | import java.util.List;
|
| 28 | +import java.util.NoSuchElementException; |
28 | 29 |
|
29 | 30 | import static io.r2dbc.postgresql.message.Format.FORMAT_BINARY;
|
30 | 31 | import static io.r2dbc.postgresql.message.Format.FORMAT_TEXT;
|
31 | 32 | import static io.r2dbc.postgresql.util.TestByteBufAllocator.TEST;
|
32 | 33 | import static org.assertj.core.api.Assertions.assertThat;
|
| 34 | +import static org.assertj.core.api.Assertions.assertThatExceptionOfType; |
33 | 35 | import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
|
34 | 36 | import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
|
35 | 37 | import static org.mockito.Mockito.mock;
|
@@ -98,15 +100,17 @@ void getIndex() {
|
98 | 100 |
|
99 | 101 | @Test
|
100 | 102 | void getInvalidIndex() {
|
101 |
| - assertThatIllegalArgumentException().isThrownBy(() -> new PostgresqlRow(MockContext.empty(), new PostgresqlRowMetadata(Collections.emptyList()), this.columns, new ByteBuf[0]).get(3, |
102 |
| - Object.class)) |
| 103 | + assertThatExceptionOfType(IndexOutOfBoundsException.class).isThrownBy(() -> new PostgresqlRow(MockContext.empty(), new PostgresqlRowMetadata(Collections.emptyList()), this.columns, |
| 104 | + new ByteBuf[0]).get(3, |
| 105 | + Object.class)) |
103 | 106 | .withMessage("Column index 3 is larger than the number of columns 3");
|
104 | 107 | }
|
105 | 108 |
|
106 | 109 | @Test
|
107 | 110 | void getInvalidName() {
|
108 |
| - assertThatIllegalArgumentException().isThrownBy(() -> new PostgresqlRow(MockContext.empty(), new PostgresqlRowMetadata(Collections.emptyList()), this.columns, new ByteBuf[0]).get("test-name" + |
109 |
| - "-4", Object.class)) |
| 111 | + assertThatExceptionOfType(NoSuchElementException.class).isThrownBy(() -> new PostgresqlRow(MockContext.empty(), new PostgresqlRowMetadata(Collections.emptyList()), this.columns, |
| 112 | + new ByteBuf[0]).get("test-name" + |
| 113 | + "-4", Object.class)) |
110 | 114 | .withMessageMatching("Column name 'test-name-4' does not exist in column names \\[test-name-[\\d], test-name-[\\d], test-name-[\\d]\\]");
|
111 | 115 | }
|
112 | 116 |
|
|
0 commit comments