@@ -48,157 +48,135 @@ void sourcesCompiledWithoutParametersFlag() {
48
48
49
49
@ Test
50
50
void implicitInnerMapping () {
51
- @ ProjectionConstructor
52
- class MyProjection {
53
- private final String someText ;
54
- private final Integer someInteger ;
55
- private final InnerProjection someContained ;
56
-
57
- MyProjection (String someText , Integer someInteger , InnerProjection someContained ) {
58
- this .someText = someText ;
59
- this .someInteger = someInteger ;
60
- this .someContained = someContained ;
61
- }
62
-
63
- @ ProjectionConstructor
64
- static class InnerProjection {
65
- private final String someText2 ;
66
- private final Integer someInteger2 ;
67
-
68
- InnerProjection (String someText2 , Integer someInteger2 ) {
69
- this .someText2 = someText2 ;
70
- this .someInteger2 = someInteger2 ;
71
- }
72
- }
73
- }
74
51
assertThatThrownBy ( () -> setupHelper .start ()
75
- .withAnnotatedTypes ( MyProjection .class , MyProjection .InnerProjection .class )
52
+ .withAnnotatedTypes ( ImplicitInnerMappingMyProjection .class ,
53
+ ImplicitInnerMappingMyProjection .InnerProjection .class )
76
54
.setup ( IndexedEntity .class ) )
77
55
.isInstanceOf ( SearchException .class )
78
56
.satisfies ( FailureReportUtils .hasFailureReport ()
79
- .typeContext ( MyProjection .class .getName () )
80
- .constructorContext ( ProjectionConstructorClassNoParametersCompilerFlagIT . class , String .class ,
57
+ .typeContext ( ImplicitInnerMappingMyProjection .class .getName () )
58
+ .constructorContext ( String .class ,
81
59
Integer .class ,
82
- MyProjection .InnerProjection .class )
83
- .methodParameterContext ( 1 )
60
+ ImplicitInnerMappingMyProjection .InnerProjection .class )
61
+ .methodParameterContext ( 0 )
84
62
.failure ( "Missing parameter names in Java metadata for projection constructor" ,
85
63
"When inferring inner projections from constructor parameters,"
86
64
+ " constructor parameter names must be known" ,
87
65
"Either make sure this class was compiled with the '-parameters' compiler flag" ,
88
66
"or set the path explicitly with '@FieldProjection(path = ...)'" )
89
- .methodParameterContext ( 2 )
67
+ .methodParameterContext ( 1 )
90
68
.failure ( "Missing parameter names in Java metadata for projection constructor" ,
91
69
"When inferring inner projections from constructor parameters,"
92
70
+ " constructor parameter names must be known" ,
93
71
"Either make sure this class was compiled with the '-parameters' compiler flag" ,
94
72
"or set the path explicitly with '@FieldProjection(path = ...)' or '@ObjectProjection(path = ...)'" )
95
- .methodParameterContext ( 3 )
73
+ .methodParameterContext ( 2 )
96
74
.failure ( "Missing parameter names in Java metadata for projection constructor" ,
97
75
"When inferring inner projections from constructor parameters,"
98
76
+ " constructor parameter names must be known" ,
99
77
"Either make sure this class was compiled with the '-parameters' compiler flag" ,
100
78
"or set the path explicitly with '@FieldProjection(path = ...)' or '@ObjectProjection(path = ...)'" ) );
101
79
}
102
80
103
- @ Test
104
- void explicitInnerMapping_implicitPath () {
105
- @ ProjectionConstructor
106
- class MyProjection {
107
- private final String someText ;
108
- private final Integer someInteger ;
109
- private final InnerProjection someContained ;
110
-
111
- MyProjection (@ FieldProjection String someText ,
112
- @ FieldProjection Integer someInteger ,
113
- @ ObjectProjection InnerProjection someContained ) {
114
- this .someText = someText ;
115
- this .someInteger = someInteger ;
116
- this .someContained = someContained ;
117
- }
81
+ @ ProjectionConstructor
82
+ static class ImplicitInnerMappingMyProjection {
83
+ private final String someText ;
84
+ private final Integer someInteger ;
85
+ private final InnerProjection someContained ;
118
86
119
- @ ProjectionConstructor
120
- static class InnerProjection {
121
- private final String someText2 ;
122
- private final Integer someInteger2 ;
87
+ ImplicitInnerMappingMyProjection (String someText , Integer someInteger , InnerProjection someContained ) {
88
+ this .someText = someText ;
89
+ this .someInteger = someInteger ;
90
+ this .someContained = someContained ;
91
+ }
92
+
93
+ @ ProjectionConstructor
94
+ static class InnerProjection {
95
+ private final String someText2 ;
96
+ private final Integer someInteger2 ;
123
97
124
- InnerProjection (@ FieldProjection String someText2 ,
125
- @ FieldProjection Integer someInteger2 ) {
126
- this .someText2 = someText2 ;
127
- this .someInteger2 = someInteger2 ;
128
- }
98
+ InnerProjection (String someText2 , Integer someInteger2 ) {
99
+ this .someText2 = someText2 ;
100
+ this .someInteger2 = someInteger2 ;
129
101
}
130
102
}
103
+ }
104
+
105
+ @ Test
106
+ void explicitInnerMapping_implicitPath () {
131
107
assertThatThrownBy ( () -> setupHelper .start ()
132
- .withAnnotatedTypes ( MyProjection .class , MyProjection .InnerProjection .class )
108
+ .withAnnotatedTypes ( ExplicitInnerMapping_implicitPathMyProjection .class ,
109
+ ExplicitInnerMapping_implicitPathMyProjection .InnerProjection .class )
133
110
.setup ( IndexedEntity .class ) )
134
111
.isInstanceOf ( SearchException .class )
135
112
.satisfies ( FailureReportUtils .hasFailureReport ()
136
- .typeContext ( MyProjection .class .getName () )
137
- .constructorContext ( ProjectionConstructorClassNoParametersCompilerFlagIT . class , String .class ,
113
+ .typeContext ( ExplicitInnerMapping_implicitPathMyProjection .class .getName () )
114
+ .constructorContext ( String .class ,
138
115
Integer .class ,
139
- MyProjection .InnerProjection .class )
140
- .methodParameterContext ( 1 )
116
+ ExplicitInnerMapping_implicitPathMyProjection .InnerProjection .class )
117
+ .methodParameterContext ( 0 )
141
118
.failure ( "Missing parameter names in Java metadata for projection constructor" ,
142
119
"When mapping a projection constructor parameter to a field projection without providing a field path,"
143
120
+ " constructor parameter names must be known" ,
144
121
"Either make sure this class was compiled with the '-parameters' compiler flag" ,
145
122
"or set the path explicitly with '@FieldProjection(path = ...)'" )
146
- .methodParameterContext ( 2 )
123
+ .methodParameterContext ( 1 )
147
124
.failure ( "Missing parameter names in Java metadata for projection constructor" ,
148
125
"When mapping a projection constructor parameter to a field projection without providing a field path,"
149
126
+ " constructor parameter names must be known" ,
150
127
"Either make sure this class was compiled with the '-parameters' compiler flag" ,
151
128
"or set the path explicitly with '@FieldProjection(path = ...)'" )
152
- .methodParameterContext ( 3 )
129
+ .methodParameterContext ( 2 )
153
130
.failure ( "Missing parameter names in Java metadata for projection constructor" ,
154
131
"When mapping a projection constructor parameter to an object projection without providing a field path,"
155
132
+ " constructor parameter names must be known" ,
156
133
"Either make sure this class was compiled with the '-parameters' compiler flag" ,
157
134
"or set the path explicitly with '@ObjectProjection(path = ...)'" ) );
158
135
}
159
136
160
- @ Test
161
- void explicitInnerMapping_explicitPath () {
162
- @ ProjectionConstructor
163
- class MyProjection {
164
- private final String someText ;
165
- private final Integer someInteger ;
166
- private final InnerProjection someContained ;
167
-
168
- MyProjection (@ FieldProjection (path = "text" ) String someText ,
169
- @ FieldProjection (path = "integer" ) Integer someInteger ,
170
- @ ObjectProjection (path = "contained" ) InnerProjection someContained ) {
171
- this .someText = someText ;
172
- this .someInteger = someInteger ;
173
- this .someContained = someContained ;
174
- }
175
-
176
- @ ProjectionConstructor
177
- static class InnerProjection {
178
- private final String someText2 ;
179
- private final Integer someInteger2 ;
137
+ @ ProjectionConstructor
138
+ static class ExplicitInnerMapping_implicitPathMyProjection {
139
+ private final String someText ;
140
+ private final Integer someInteger ;
141
+ private final InnerProjection someContained ;
142
+
143
+ ExplicitInnerMapping_implicitPathMyProjection (@ FieldProjection String someText ,
144
+ @ FieldProjection Integer someInteger ,
145
+ @ ObjectProjection InnerProjection someContained ) {
146
+ this .someText = someText ;
147
+ this .someInteger = someInteger ;
148
+ this .someContained = someContained ;
149
+ }
180
150
181
- InnerProjection (@ FieldProjection (path = "text2" ) String someText2 ,
182
- @ FieldProjection (path = "integer2" ) Integer someInteger2 ) {
183
- this .someText2 = someText2 ;
184
- this .someInteger2 = someInteger2 ;
185
- }
151
+ @ ProjectionConstructor
152
+ static class InnerProjection {
153
+ private final String someText2 ;
154
+ private final Integer someInteger2 ;
155
+
156
+ InnerProjection (@ FieldProjection String someText2 ,
157
+ @ FieldProjection Integer someInteger2 ) {
158
+ this .someText2 = someText2 ;
159
+ this .someInteger2 = someInteger2 ;
186
160
}
187
161
}
162
+ }
163
+
164
+ @ Test
165
+ void explicitInnerMapping_explicitPath () {
188
166
backendMock .expectAnySchema ( INDEX_NAME );
189
167
SearchMapping mapping = setupHelper .start ()
190
- .withAnnotatedTypes ( MyProjection .class , MyProjection .InnerProjection .class )
168
+ .withAnnotatedTypes ( ExplicitInnerMapping_explicitPathMyProjection .class ,
169
+ ExplicitInnerMapping_explicitPathMyProjection .InnerProjection .class )
191
170
.setup ( IndexedEntity .class , ContainedEntity .class );
192
171
testSuccessfulRootProjection (
193
- mapping , IndexedEntity .class , MyProjection .class ,
172
+ mapping , IndexedEntity .class , ExplicitInnerMapping_explicitPathMyProjection .class ,
194
173
Arrays .asList (
195
174
Arrays .asList ( "result1" , 1 , Arrays .asList ( "result1_1" , 11 ) ),
196
175
Arrays .asList ( "result2" , 2 , Arrays .asList ( "result2_1" , 21 ) ),
197
176
Arrays .asList ( "result3" , 3 , Arrays .asList ( "result3_1" , 31 ) )
198
177
),
199
178
f -> f .composite ()
200
179
.from (
201
- dummyProjectionForEnclosingClassInstance ( f ),
202
180
f .field ( "text" , String .class ),
203
181
f .field ( "integer" , Integer .class ),
204
182
f .object ( "contained" )
@@ -210,16 +188,43 @@ static class InnerProjection {
210
188
)
211
189
.asList (),
212
190
Arrays .asList (
213
- new MyProjection ( "result1" , 1 ,
214
- new MyProjection .InnerProjection ( "result1_1" , 11 ) ),
215
- new MyProjection ( "result2" , 2 ,
216
- new MyProjection .InnerProjection ( "result2_1" , 21 ) ),
217
- new MyProjection ( "result3" , 3 ,
218
- new MyProjection .InnerProjection ( "result3_1" , 31 ) )
191
+ new ExplicitInnerMapping_explicitPathMyProjection ( "result1" , 1 ,
192
+ new ExplicitInnerMapping_explicitPathMyProjection .InnerProjection ( "result1_1" , 11 ) ),
193
+ new ExplicitInnerMapping_explicitPathMyProjection ( "result2" , 2 ,
194
+ new ExplicitInnerMapping_explicitPathMyProjection .InnerProjection ( "result2_1" , 21 ) ),
195
+ new ExplicitInnerMapping_explicitPathMyProjection ( "result3" , 3 ,
196
+ new ExplicitInnerMapping_explicitPathMyProjection .InnerProjection ( "result3_1" , 31 ) )
219
197
)
220
198
);
221
199
}
222
200
201
+ @ ProjectionConstructor
202
+ static class ExplicitInnerMapping_explicitPathMyProjection {
203
+ private final String someText ;
204
+ private final Integer someInteger ;
205
+ private final InnerProjection someContained ;
206
+
207
+ ExplicitInnerMapping_explicitPathMyProjection (@ FieldProjection (path = "text" ) String someText ,
208
+ @ FieldProjection (path = "integer" ) Integer someInteger ,
209
+ @ ObjectProjection (path = "contained" ) InnerProjection someContained ) {
210
+ this .someText = someText ;
211
+ this .someInteger = someInteger ;
212
+ this .someContained = someContained ;
213
+ }
214
+
215
+ @ ProjectionConstructor
216
+ static class InnerProjection {
217
+ private final String someText2 ;
218
+ private final Integer someInteger2 ;
219
+
220
+ InnerProjection (@ FieldProjection (path = "text2" ) String someText2 ,
221
+ @ FieldProjection (path = "integer2" ) Integer someInteger2 ) {
222
+ this .someText2 = someText2 ;
223
+ this .someInteger2 = someInteger2 ;
224
+ }
225
+ }
226
+ }
227
+
223
228
@ Indexed (index = INDEX_NAME )
224
229
static class IndexedEntity {
225
230
@ DocumentId
0 commit comments