9
9
import java .util .Collections ;
10
10
import java .util .List ;
11
11
import java .util .UUID ;
12
- import java .util .concurrent .ExecutionException ;
13
- import java .util .concurrent .TimeUnit ;
14
- import java .util .concurrent .TimeoutException ;
15
12
import java .util .stream .Collectors ;
16
13
17
14
import com .microsoft .kiota .ApiException ;
18
15
import com .microsoft .kiota .RequestAdapter ;
19
- import com .microsoft .kiota .authentication .AnonymousAuthenticationProvider ;
20
- import com .microsoft .kiota .http .OkHttpRequestAdapter ;
16
+
21
17
import io .apicurio .registry .rest .client .models .ArtifactMetaData ;
22
18
import io .apicurio .registry .rest .v3 .beans .ArtifactReference ;
23
19
import io .apicurio .rest .client .auth .exception .NotAuthorizedException ;
20
+ import io .kiota .http .vertx .VertXRequestAdapter ;
21
+ import io .apicurio .registry .client .auth .VertXAuthFactory ;
24
22
import org .junit .jupiter .api .AfterAll ;
25
23
import org .junit .jupiter .api .Assertions ;
26
24
import org .junit .jupiter .api .BeforeAll ;
@@ -78,7 +76,7 @@ protected RestService buildConfluentClient() {
78
76
return new RestService ("http://localhost:" + testPort + "/apis/ccompat/v7" );
79
77
}
80
78
81
- protected final RequestAdapter anonymousAdapter = new OkHttpRequestAdapter ( new AnonymousAuthenticationProvider () );
79
+ protected final RequestAdapter anonymousAdapter = new VertXRequestAdapter ( VertXAuthFactory . defaultVertx );
82
80
83
81
protected RegistryClient createRestClientV3 () {
84
82
anonymousAdapter .setBaseUrl (registryV3ApiUrl );
@@ -101,11 +99,11 @@ protected void deleteGlobalRules(int expectedDefaultRulesCount) throws Exception
101
99
// Delete all global rules
102
100
TestUtils .retry (() -> {
103
101
try {
104
- clientV3 .admin ().rules ().delete (). get ( 3 , TimeUnit . SECONDS ) ;
102
+ clientV3 .admin ().rules ().delete ();
105
103
} catch (Exception err ) {
106
104
// ignore
107
105
}
108
- Assertions .assertEquals (expectedDefaultRulesCount , clientV3 .admin ().rules ().get ().get ( 3 , TimeUnit . SECONDS ). size ());
106
+ Assertions .assertEquals (expectedDefaultRulesCount , clientV3 .admin ().rules ().get ().size ());
109
107
});
110
108
}
111
109
@@ -125,7 +123,7 @@ protected Long createArtifact(String groupId, String artifactId, String artifact
125
123
config .headers .add ("X-Registry-ArtifactId" , artifactId );
126
124
config .headers .add ("X-Registry-ArtifactType" , artifactType );
127
125
})
128
- . get ( 3 , TimeUnit . SECONDS ) ;
126
+ ;
129
127
130
128
assert ( result .getId ().equals (artifactId ) );
131
129
assert ( result .getType ().equals (artifactType ) );
@@ -181,7 +179,7 @@ protected ArtifactMetaData createArtifactExtendedRaw(String groupId, String arti
181
179
config .headers .add ("X-Registry-ArtifactType" , artifactType );
182
180
}
183
181
})
184
- . get ( 3 , TimeUnit . SECONDS ) ;
182
+ ;
185
183
}
186
184
187
185
protected ArtifactMetaData updateArtifactExtendedRaw (String groupId , String artifactId , String artifactType , String artifactContent , List <ArtifactReference > artifactReferences ) throws Exception {
@@ -207,7 +205,7 @@ protected ArtifactMetaData updateArtifactExtendedRaw(String groupId, String arti
207
205
config .headers .add ("X-Registry-ArtifactId" , artifactId );
208
206
config .headers .add ("X-Registry-ArtifactType" , artifactType );
209
207
})
210
- . get ( 3 , TimeUnit . SECONDS ) ;
208
+ ;
211
209
}
212
210
213
211
protected Long createArtifactVersion (String artifactId , String artifactType , String artifactContent ) throws Exception {
@@ -225,15 +223,15 @@ protected Long createArtifactVersion(String groupId, String artifactId, String a
225
223
.byArtifactId (artifactId )
226
224
.versions ()
227
225
.post (content , config -> {config .headers .add ("X-Registry-ArtifactType" , artifactType ); })
228
- . get ( 3 , TimeUnit . SECONDS ) ;
226
+ ;
229
227
230
228
assert ( version .getId ().equals (artifactId ) );
231
229
assert ( version .getType ().equals (artifactType ) );
232
230
233
231
return version .getGlobalId ();
234
232
}
235
233
236
- protected void createArtifactRule (String groupId , String artifactId , RuleType ruleType , String ruleConfig ) throws ExecutionException , InterruptedException , TimeoutException {
234
+ protected void createArtifactRule (String groupId , String artifactId , RuleType ruleType , String ruleConfig ) {
237
235
var rule = new io .apicurio .registry .rest .client .models .Rule ();
238
236
rule .setConfig (ruleConfig );
239
237
rule .setType (io .apicurio .registry .rest .client .models .RuleType .forValue (ruleType .value ()));
@@ -244,28 +242,25 @@ protected void createArtifactRule(String groupId, String artifactId, RuleType ru
244
242
.artifacts ()
245
243
.byArtifactId (artifactId )
246
244
.rules ()
247
- .post (rule )
248
- .get (3 , TimeUnit .SECONDS );
245
+ .post (rule );
249
246
}
250
247
251
248
@ SuppressWarnings ("deprecation" )
252
- protected io .apicurio .registry .rest .client .models .Rule createGlobalRule (RuleType ruleType , String ruleConfig ) throws ExecutionException , InterruptedException , TimeoutException {
249
+ protected io .apicurio .registry .rest .client .models .Rule createGlobalRule (RuleType ruleType , String ruleConfig ) {
253
250
var rule = new io .apicurio .registry .rest .client .models .Rule ();
254
251
rule .setConfig (ruleConfig );
255
252
rule .setType (io .apicurio .registry .rest .client .models .RuleType .forValue (ruleType .value ()));
256
253
257
254
clientV3
258
255
.admin ()
259
256
.rules ()
260
- .post (rule )
261
- .get (3 , TimeUnit .SECONDS );
257
+ .post (rule );
262
258
// TODO: verify this get
263
259
return clientV3
264
260
.admin ()
265
261
.rules ()
266
262
.byRule (ruleType .value ())
267
- .get ()
268
- .get (3 , TimeUnit .SECONDS );
263
+ .get ();
269
264
}
270
265
271
266
/**
@@ -312,21 +307,19 @@ protected List<ArtifactReferenceDto> toReferenceDtos(List<ArtifactReference> ref
312
307
.collect (Collectors .toList ());
313
308
}
314
309
315
- protected void assertForbidden (ExecutionException executionException ) {
316
- Assertions .assertNotNull (executionException .getCause ());
317
- Assertions .assertEquals (ApiException .class , executionException .getCause ().getClass ());
318
- Assertions .assertEquals (403 , ((ApiException )executionException .getCause ()).getResponseStatusCode ());
310
+ protected void assertForbidden (Exception exception ) {
311
+ Assertions .assertEquals (ApiException .class , exception .getClass ());
312
+ Assertions .assertEquals (403 , ((ApiException )exception ).getResponseStatusCode ());
319
313
}
320
314
321
- protected void assertNotAuthorized (ExecutionException executionException ) {
322
- Assertions .assertNotNull (executionException .getCause ());
323
-
324
- if (executionException .getCause () instanceof NotAuthorizedException ) {
315
+ protected void assertNotAuthorized (Exception exception ) {
316
+ if (exception instanceof NotAuthorizedException ) {
325
317
// thrown by the token provider adapter
326
318
} else {
327
319
// mapped by Kiota
328
- Assertions .assertEquals (ApiException .class , executionException . getCause () .getClass ());
329
- Assertions .assertEquals (401 , ((ApiException ) executionException . getCause () ).getResponseStatusCode ());
320
+ Assertions .assertEquals (ApiException .class , exception .getClass ());
321
+ Assertions .assertEquals (401 , ((ApiException ) exception ).getResponseStatusCode ());
330
322
}
331
323
}
324
+
332
325
}
0 commit comments