15
15
import com .linkedin .metadata .models .registry .EntityRegistry ;
16
16
import com .linkedin .metadata .search .elasticsearch .query .request .AggregationQueryBuilder ;
17
17
import com .linkedin .r2 .RemoteInvocationException ;
18
+ import io .datahubproject .test .metadata .context .TestOperationContexts ;
18
19
import java .net .URISyntaxException ;
19
20
import java .util .Collections ;
20
21
import java .util .List ;
@@ -67,7 +68,8 @@ public void testGetDefaultAggregationsHasFields() {
67
68
ImmutableMap .of (mock (EntitySpec .class ), ImmutableList .of (annotation )),
68
69
aspectRetriever );
69
70
70
- List <AggregationBuilder > aggs = builder .getAggregations ();
71
+ List <AggregationBuilder > aggs =
72
+ builder .getAggregations (TestOperationContexts .systemContextNoSearchAuthorization ());
71
73
72
74
Assert .assertTrue (aggs .stream ().anyMatch (agg -> agg .getName ().equals ("hasTest" )));
73
75
}
@@ -101,7 +103,8 @@ public void testGetDefaultAggregationsFields() {
101
103
ImmutableMap .of (mock (EntitySpec .class ), ImmutableList .of (annotation )),
102
104
aspectRetriever );
103
105
104
- List <AggregationBuilder > aggs = builder .getAggregations ();
106
+ List <AggregationBuilder > aggs =
107
+ builder .getAggregations (TestOperationContexts .systemContextNoSearchAuthorization ());
105
108
106
109
Assert .assertTrue (aggs .stream ().anyMatch (agg -> agg .getName ().equals ("test" )));
107
110
}
@@ -153,13 +156,18 @@ public void testGetSpecificAggregationsHasFields() {
153
156
154
157
// Case 1: Ask for fields that should exist.
155
158
List <AggregationBuilder > aggs =
156
- builder .getAggregations (ImmutableList .of ("test1" , "test2" , "hasTest1" ));
159
+ builder .getAggregations (
160
+ TestOperationContexts .systemContextNoSearchAuthorization (),
161
+ ImmutableList .of ("test1" , "test2" , "hasTest1" ));
157
162
Assert .assertEquals (aggs .size (), 3 );
158
163
Set <String > facets = aggs .stream ().map (AggregationBuilder ::getName ).collect (Collectors .toSet ());
159
164
Assert .assertEquals (ImmutableSet .of ("test1" , "test2" , "hasTest1" ), facets );
160
165
161
166
// Case 2: Ask for fields that should NOT exist.
162
- aggs = builder .getAggregations (ImmutableList .of ("hasTest2" ));
167
+ aggs =
168
+ builder .getAggregations (
169
+ TestOperationContexts .systemContextNoSearchAuthorization (),
170
+ ImmutableList .of ("hasTest2" ));
163
171
Assert .assertEquals (aggs .size (), 0 );
164
172
}
165
173
@@ -173,7 +181,9 @@ public void testAggregateOverStructuredProperty() {
173
181
config , ImmutableMap .of (mock (EntitySpec .class ), ImmutableList .of ()), aspectRetriever );
174
182
175
183
List <AggregationBuilder > aggs =
176
- builder .getAggregations (List .of ("structuredProperties.ab.fgh.ten" ));
184
+ builder .getAggregations (
185
+ TestOperationContexts .systemContextNoSearchAuthorization (),
186
+ List .of ("structuredProperties.ab.fgh.ten" ));
177
187
Assert .assertEquals (aggs .size (), 1 );
178
188
AggregationBuilder aggBuilder = aggs .get (0 );
179
189
Assert .assertTrue (aggBuilder instanceof TermsAggregationBuilder );
@@ -184,6 +194,7 @@ public void testAggregateOverStructuredProperty() {
184
194
// Two structured properties
185
195
aggs =
186
196
builder .getAggregations (
197
+ TestOperationContexts .systemContextNoSearchAuthorization (),
187
198
List .of ("structuredProperties.ab.fgh.ten" , "structuredProperties.hello" ));
188
199
Assert .assertEquals (aggs .size (), 2 );
189
200
Assert .assertEquals (
@@ -241,6 +252,7 @@ public void testAggregateOverFieldsAndStructProp() {
241
252
// Aggregate over fields and structured properties
242
253
List <AggregationBuilder > aggs =
243
254
builder .getAggregations (
255
+ TestOperationContexts .systemContextNoSearchAuthorization (),
244
256
ImmutableList .of (
245
257
"test1" ,
246
258
"test2" ,
@@ -291,7 +303,8 @@ public void testMissingAggregation() {
291
303
ImmutableMap .of (mock (EntitySpec .class ), ImmutableList .of (annotation )),
292
304
aspectRetriever );
293
305
294
- List <AggregationBuilder > aggs = builder .getAggregations ();
306
+ List <AggregationBuilder > aggs =
307
+ builder .getAggregations (TestOperationContexts .systemContextNoSearchAuthorization ());
295
308
296
309
Assert .assertTrue (aggs .stream ().anyMatch (agg -> agg .getName ().equals ("hasTest" )));
297
310
Assert .assertTrue (
0 commit comments