26
26
import org .junit .jupiter .api .Test ;
27
27
import org .springframework .data .annotation .Id ;
28
28
import org .springframework .data .relational .core .sql .SqlIdentifier ;
29
+ import org .springframework .data .relational .core .sql .Table ;
29
30
30
31
/**
31
32
* Unit tests for the construction of {@link org.springframework.data.relational.core.mapping.AggregatePath.ColumnInfos}
32
- *
33
+ *
33
34
* @author Jens Schauder
34
35
*/
35
36
class ColumnInfosUnitTests {
36
37
38
+ static final Table TABLE = Table .create ("dummy" );
37
39
static final SqlIdentifier ID = SqlIdentifier .quoted ("ID" );
38
40
RelationalMappingContext context = new RelationalMappingContext ();
39
41
40
- @ Test // GH-574
42
+ @ Test
43
+ // GH-574
41
44
void emptyColumnInfos () {
42
45
43
46
AggregatePath .ColumnInfos columnInfos = AggregatePath .ColumnInfos .empty (basePath (DummyEntity .class ));
44
47
45
48
assertThat (columnInfos .isEmpty ()).isTrue ();
46
49
assertThrows (NoSuchElementException .class , columnInfos ::any );
47
50
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 ();
51
52
}
52
53
53
- @ Test // GH-574
54
+ @ Test
55
+ // GH-574
54
56
void singleElementColumnInfos () {
55
57
56
58
AggregatePath .ColumnInfos columnInfos = basePath (DummyEntity .class ).getTableInfo ().idColumnInfos ();
57
59
58
60
assertThat (columnInfos .isEmpty ()).isFalse ();
59
61
assertThat (columnInfos .any ().name ()).isEqualTo (ID );
60
62
assertThat (columnInfos .unique ().name ()).isEqualTo (ID );
61
- assertThat (columnInfos .toList ( ci -> ci . name ())) .containsExactly (ID );
63
+ assertThat (columnInfos .toColumnList ( TABLE )) .containsExactly (TABLE . column ( ID ) );
62
64
}
63
65
64
66
@ Test // GH-574
@@ -69,10 +71,10 @@ void multiElementColumnInfos() {
69
71
assertThat (columnInfos .isEmpty ()).isFalse ();
70
72
assertThat (columnInfos .any ().name ()).isEqualTo (SqlIdentifier .quoted ("ONE" ));
71
73
assertThrows (IllegalStateException .class , columnInfos ::unique );
72
- assertThat (columnInfos .toList ( ci -> ci . name () )) //
74
+ assertThat (columnInfos .toColumnList ( TABLE )) //
73
75
.containsExactly ( //
74
- SqlIdentifier .quoted ("ONE" ), //
75
- SqlIdentifier .quoted ("TWO" ) //
76
+ TABLE . column ( SqlIdentifier .quoted ("ONE" ) ), //
77
+ TABLE . column ( SqlIdentifier .quoted ("TWO" ) ) //
76
78
);
77
79
78
80
List <String > collector = new ArrayList <>();
0 commit comments