Skip to content

Commit 61ad351

Browse files
committed
replace tests
1 parent 8c7796e commit 61ad351

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

spring-data-relational/src/test/java/org/springframework/data/relational/core/mapping/ColumnInfosUnitTests.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,41 @@
2626
import org.junit.jupiter.api.Test;
2727
import org.springframework.data.annotation.Id;
2828
import org.springframework.data.relational.core.sql.SqlIdentifier;
29+
import org.springframework.data.relational.core.sql.Table;
2930

3031
/**
3132
* Unit tests for the construction of {@link org.springframework.data.relational.core.mapping.AggregatePath.ColumnInfos}
32-
*
33+
*
3334
* @author Jens Schauder
3435
*/
3536
class ColumnInfosUnitTests {
3637

38+
static final Table TABLE = Table.create("dummy");
3739
static final SqlIdentifier ID = SqlIdentifier.quoted("ID");
3840
RelationalMappingContext context = new RelationalMappingContext();
3941

40-
@Test // GH-574
42+
@Test
43+
// GH-574
4144
void emptyColumnInfos() {
4245

4346
AggregatePath.ColumnInfos columnInfos = AggregatePath.ColumnInfos.empty(basePath(DummyEntity.class));
4447

4548
assertThat(columnInfos.isEmpty()).isTrue();
4649
assertThrows(NoSuchElementException.class, columnInfos::any);
4750
assertThrows(IllegalStateException.class, columnInfos::unique);
48-
assertThat(columnInfos.toList(ci -> {
49-
throw new IllegalStateException("This should never get called");
50-
})).isEmpty();
51+
assertThat(columnInfos.toColumnList(TABLE)).isEmpty();
5152
}
5253

53-
@Test // GH-574
54+
@Test
55+
// GH-574
5456
void singleElementColumnInfos() {
5557

5658
AggregatePath.ColumnInfos columnInfos = basePath(DummyEntity.class).getTableInfo().idColumnInfos();
5759

5860
assertThat(columnInfos.isEmpty()).isFalse();
5961
assertThat(columnInfos.any().name()).isEqualTo(ID);
6062
assertThat(columnInfos.unique().name()).isEqualTo(ID);
61-
assertThat(columnInfos.toList(ci -> ci.name())).containsExactly(ID);
63+
assertThat(columnInfos.toColumnList(TABLE)).containsExactly(TABLE.column(ID));
6264
}
6365

6466
@Test // GH-574
@@ -69,10 +71,10 @@ void multiElementColumnInfos() {
6971
assertThat(columnInfos.isEmpty()).isFalse();
7072
assertThat(columnInfos.any().name()).isEqualTo(SqlIdentifier.quoted("ONE"));
7173
assertThrows(IllegalStateException.class, columnInfos::unique);
72-
assertThat(columnInfos.toList(ci -> ci.name())) //
74+
assertThat(columnInfos.toColumnList(TABLE)) //
7375
.containsExactly( //
74-
SqlIdentifier.quoted("ONE"), //
75-
SqlIdentifier.quoted("TWO") //
76+
TABLE.column(SqlIdentifier.quoted("ONE")), //
77+
TABLE.column(SqlIdentifier.quoted("TWO")) //
7678
);
7779

7880
List<String> collector = new ArrayList<>();

spring-data-relational/src/test/java/org/springframework/data/relational/core/mapping/DefaultAggregatePathUnitTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@
3030
import org.springframework.data.annotation.Id;
3131
import org.springframework.data.annotation.ReadOnlyProperty;
3232
import org.springframework.data.mapping.PersistentPropertyPath;
33+
import org.springframework.data.relational.core.sql.Column;
3334
import org.springframework.data.relational.core.sql.SqlIdentifier;
35+
import org.springframework.data.relational.core.sql.Table;
3436

3537
/**
3638
* Tests for {@link AggregatePath}.
@@ -147,8 +149,8 @@ void reverseColumnName() {
147149
void reverseColumnNames() {
148150

149151
assertSoftly(softly -> {
150-
softly.assertThat(path(CompoundIdEntity.class, "second").getTableInfo().backReferenceColumnInfos().toList(x -> x))
151-
.extracting(AggregatePath.ColumnInfo::name)
152+
softly.assertThat(path(CompoundIdEntity.class, "second").getTableInfo().backReferenceColumnInfos().toColumnList(Table.create("dummy")))
153+
.extracting(Column::getName)
152154
.containsExactlyInAnyOrder(quoted("COMPOUND_ID_ENTITY_ONE"), quoted("COMPOUND_ID_ENTITY_TWO"));
153155

154156
});

0 commit comments

Comments
 (0)