Skip to content

Commit 1067c26

Browse files
schaudermp911de
andauthored
Update src/test/java/org/springframework/data/r2dbc/function/convert/EntityRowMapperUnitTests.java
Co-Authored-By: mp911de <[email protected]>
1 parent 8396895 commit 1067c26

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/test/java/org/springframework/data/r2dbc/function/convert/EntityRowMapperUnitTests.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,35 @@ public void shouldConvertArrayToCollection() {
6969
assertThat(result.ids).contains("foo", "bar");
7070
}
7171

72+
@Test // gh-30
73+
public void shouldConvertArrayToSet() {
74+
75+
EntityRowMapper<EntityWithCollection> mapper = getRowMapper(EntityWithCollection.class);
76+
when(rowMock.get("integerSet")).thenReturn((new int[] { 3, 14 }));
77+
78+
EntityWithCollection result = mapper.apply(rowMock, metadata);
79+
assertThat(result.integerSet).contains(3, 14);
80+
}
81+
82+
@Test // gh-30
83+
public void shouldConvertArrayMembers() {
84+
85+
EntityRowMapper<EntityWithCollection> mapper = getRowMapper(EntityWithCollection.class);
86+
when(rowMock.get("primitiveIntegers")).thenReturn((new long[] { 3L, 14L }));
87+
88+
EntityWithCollection result = mapper.apply(rowMock, metadata);
89+
assertThat(result.primitiveIntegers).contains(3, 14);
90+
}
91+
92+
@Test // gh-30
93+
public void shouldConvertArrayToBoxedArray() {
94+
95+
EntityRowMapper<EntityWithCollection> mapper = getRowMapper(EntityWithCollection.class);
96+
when(rowMock.get("boxedIntegers")).thenReturn((new int[] { 3, 11 }));
97+
98+
EntityWithCollection result = mapper.apply(rowMock, metadata);
99+
assertThat(result.boxedIntegers).contains(3, 11);
100+
}
72101
@SuppressWarnings("unchecked")
73102
private <T> EntityRowMapper<T> getRowMapper(Class<T> type) {
74103
RelationalPersistentEntity<T> entity = (RelationalPersistentEntity<T>) strategy.getMappingContext()

0 commit comments

Comments
 (0)