|
23 | 23 | import io.r2dbc.spi.test.MockRow;
|
24 | 24 | import io.r2dbc.spi.test.MockRowMetadata;
|
25 | 25 | import lombok.AllArgsConstructor;
|
| 26 | +import lombok.Getter; |
26 | 27 | import lombok.RequiredArgsConstructor;
|
| 28 | +import lombok.Setter; |
27 | 29 |
|
28 | 30 | import java.time.Instant;
|
29 | 31 | import java.time.LocalDateTime;
|
@@ -182,9 +184,24 @@ public void shouldWriteTopLevelEntity() {
|
182 | 184 | .containsEntry(SqlIdentifier.unquoted("entity"), Parameter.from("nested_entity"));
|
183 | 185 | }
|
184 | 186 |
|
185 |
| - @Test // gh-59 |
| 187 | + @Test // gh-530 |
186 | 188 | public void shouldReadTopLevelEntity() {
|
187 | 189 |
|
| 190 | + mappingContext.setForceQuote(true); |
| 191 | + |
| 192 | + Row rowMock = mock(Row.class); |
| 193 | + when(rowMock.get("firstname")).thenReturn("Walter"); |
| 194 | + when(rowMock.get("lastname")).thenReturn("White"); |
| 195 | + |
| 196 | + ConstructorAndPropertyPopulation result = converter.read(ConstructorAndPropertyPopulation.class, rowMock); |
| 197 | + |
| 198 | + assertThat(result.firstname).isEqualTo("Walter"); |
| 199 | + assertThat(result.lastname).isEqualTo("White"); |
| 200 | + } |
| 201 | + |
| 202 | + @Test // gh-59 |
| 203 | + public void shouldReadTopLevelEntityWithConverter() { |
| 204 | + |
188 | 205 | Row rowMock = mock(Row.class);
|
189 | 206 | when(rowMock.get("foo_column", String.class)).thenReturn("bar");
|
190 | 207 | when(rowMock.get("nested_entity")).thenReturn("map");
|
@@ -236,6 +253,14 @@ static class Person {
|
236 | 253 | LocalDateTime localDateTime;
|
237 | 254 | }
|
238 | 255 |
|
| 256 | + @Getter |
| 257 | + @Setter |
| 258 | + @RequiredArgsConstructor |
| 259 | + static class ConstructorAndPropertyPopulation { |
| 260 | + final String firstname; |
| 261 | + String lastname; |
| 262 | + } |
| 263 | + |
239 | 264 | @AllArgsConstructor
|
240 | 265 | static class WithEnum {
|
241 | 266 | @Id String id;
|
|
0 commit comments