33
33
import org .eclipse .edc .spi .message .RemoteMessageDispatcherRegistry ;
34
34
import org .eclipse .edc .spi .response .StatusResult ;
35
35
import org .eclipse .edc .transform .spi .TypeTransformerRegistry ;
36
- import org .junit .jupiter .api .BeforeEach ;
37
36
import org .junit .jupiter .api .DisplayName ;
38
37
import org .junit .jupiter .api .Test ;
39
38
import org .junit .jupiter .api .extension .RegisterExtension ;
@@ -98,18 +97,13 @@ public class CatalogRuntimeComponentTest {
98
97
)));
99
98
private final DspHttpRemoteMessageDispatcher dispatcher = mock ();
100
99
101
- @ BeforeEach
102
- void setup () {
103
- when (dispatcher .protocol ()).thenReturn (DATASPACE_PROTOCOL );
104
- }
105
-
106
100
@ Test
107
101
@ DisplayName ("Crawl a single target, yields no results" )
108
102
void crawlSingle_noResults (RemoteMessageDispatcherRegistry reg , TypeTransformerRegistry ttr , TargetNodeDirectory directory ) {
109
103
// prepare node directory
110
104
insertSingle (directory );
111
105
// intercept request egress
112
- reg .register (dispatcher );
106
+ reg .register (DATASPACE_PROTOCOL , dispatcher );
113
107
when (dispatcher .dispatch (eq (byte [].class ), isA (CatalogRequestMessage .class )))
114
108
.thenReturn (emptyCatalog (catalog -> toBytes (ttr , catalog )));
115
109
@@ -128,7 +122,7 @@ void crawlSingle_withResults(RemoteMessageDispatcherRegistry reg, TypeTransforme
128
122
// prepare node directory
129
123
insertSingle (directory );
130
124
// intercept request egress
131
- reg .register (dispatcher );
125
+ reg .register (DATASPACE_PROTOCOL , dispatcher );
132
126
when (dispatcher .dispatch (eq (byte [].class ), isA (CatalogRequestMessage .class )))
133
127
.thenReturn (randomCatalog (catalog -> toBytes (ttr , catalog ), TEST_CATALOG_ID , 5 ))
134
128
.thenReturn (emptyCatalog (catalog -> toBytes (ttr , catalog ))); // this is important, otherwise there is an endless loop!
@@ -147,7 +141,7 @@ void crawlSingle_withCatalogOfCatalogs(RemoteMessageDispatcherRegistry reg, Type
147
141
// prepare node directory
148
142
insertSingle (directory );
149
143
// intercept request egress
150
- reg .register (dispatcher );
144
+ reg .register (DATASPACE_PROTOCOL , dispatcher );
151
145
when (dispatcher .dispatch (eq (byte [].class ), isA (CatalogRequestMessage .class )))
152
146
.thenReturn (randomCatalog (catalog -> StatusResult .success (TestUtils .getResourceFileContentAsString ("catalog_of_catalogs.json" ).getBytes ()), "root-catalog-id" , 5 ))
153
147
.thenReturn (randomCatalog (catalog -> StatusResult .success (TestUtils .getResourceFileContentAsString ("catalog.json" ).getBytes ()), "sub-catalog-id" , 5 ));
@@ -170,7 +164,7 @@ void crawlSingle_withPagedResults(RemoteMessageDispatcherRegistry reg, TypeTrans
170
164
insertSingle (directory );
171
165
172
166
// intercept request egress
173
- reg .register (dispatcher );
167
+ reg .register (DATASPACE_PROTOCOL , dispatcher );
174
168
when (dispatcher .dispatch (eq (byte [].class ), isA (CatalogRequestMessage .class )))
175
169
.thenReturn (randomCatalog (catalog -> toBytes (ttr , catalog ), TEST_CATALOG_ID , 100 ))
176
170
.thenReturn (randomCatalog (catalog -> toBytes (ttr , catalog ), TEST_CATALOG_ID , 100 ))
@@ -194,7 +188,7 @@ void crawlSingle_withDeletions_shouldRemove(RemoteMessageDispatcherRegistry reg,
194
188
insertSingle (directory );
195
189
196
190
// intercept request egress
197
- reg .register (dispatcher );
191
+ reg .register (DATASPACE_PROTOCOL , dispatcher );
198
192
when (dispatcher .dispatch (eq (byte [].class ), isA (CatalogRequestMessage .class )))
199
193
.thenReturn (completedFuture (toBytes (ttr , catalogBuilder ().id (TEST_CATALOG_ID ).datasets (new ArrayList <>(List .of (
200
194
createDataset ("offer1" ), createDataset ("offer2" ), createDataset ("offer3" )
@@ -223,7 +217,7 @@ void crawlSingle_withUpdates_shouldReplace(RemoteMessageDispatcherRegistry reg,
223
217
insertSingle (directory );
224
218
225
219
// intercept request egress
226
- reg .register (dispatcher );
220
+ reg .register (DATASPACE_PROTOCOL , dispatcher );
227
221
when (dispatcher .dispatch (eq (byte [].class ), isA (CatalogRequestMessage .class )))
228
222
.thenReturn (completedFuture (toBytes (ttr , catalogBuilder ().id (TEST_CATALOG_ID ).datasets (new ArrayList <>(List .of (
229
223
createDataset ("offer1" ), createDataset ("offer2" ), createDataset ("offer3" )
@@ -251,7 +245,7 @@ void crawlSingle_withAdditions_shouldAdd(RemoteMessageDispatcherRegistry reg, Ty
251
245
insertSingle (directory );
252
246
253
247
// intercept request egress
254
- reg .register (dispatcher );
248
+ reg .register (DATASPACE_PROTOCOL , dispatcher );
255
249
when (dispatcher .dispatch (eq (byte [].class ), isA (CatalogRequestMessage .class )))
256
250
.thenAnswer (a -> completedFuture (toBytes (ttr , catalogBuilder ().id ("test-cat" )
257
251
.datasets (List .of (createDataset ("dataset1" ), createDataset ("dataset2" ))).build ())))
@@ -279,7 +273,7 @@ void crawlSingle_verifyCorrectOriginator(RemoteMessageDispatcherRegistry reg, Ty
279
273
// prepare node directory
280
274
insertSingle (directory );
281
275
// intercept request egress
282
- reg .register (dispatcher );
276
+ reg .register (DATASPACE_PROTOCOL , dispatcher );
283
277
when (dispatcher .dispatch (eq (byte [].class ), isA (CatalogRequestMessage .class )))
284
278
.thenReturn (randomCatalog (catalog -> toBytes (ttr , catalog ), TEST_CATALOG_ID , 5 ))
285
279
.thenReturn (emptyCatalog (catalog -> toBytes (ttr , catalog ))); // this is important, otherwise there is an endless loop!
@@ -302,7 +296,7 @@ void crawlMany_shouldCollectAll(RemoteMessageDispatcherRegistry reg, TypeTransfo
302
296
var rnd = new SecureRandom ();
303
297
304
298
// create 1000 crawl targets, setup dispatcher mocks for them
305
- reg .register (dispatcher );
299
+ reg .register (DATASPACE_PROTOCOL , dispatcher );
306
300
var numTargets = 50 ;
307
301
range (0 , numTargets )
308
302
.forEach (i -> {
@@ -335,7 +329,7 @@ void crawlMultiple_whenConflictingAssetIds_shouldOverwrite(RemoteMessageDispatch
335
329
336
330
directory .insert (node1 );
337
331
directory .insert (node2 );
338
- reg .register (dispatcher );
332
+ reg .register (DATASPACE_PROTOCOL , dispatcher );
339
333
340
334
when (dispatcher .dispatch (eq (byte [].class ), argThat (sentTo (node1 .id (), node1 .targetUrl ()))))
341
335
.thenReturn (catalogOf (catalog -> toBytes (ttr , catalog ), "catalog-" + node1 .targetUrl (), createDataset ("offer1" ), createDataset ("offer2" ), createDataset ("offer3" )))
0 commit comments