@@ -368,21 +368,9 @@ <T extends SolidClientException> void testExceptionalResources(
368368
369369 private static Stream <Arguments > testExceptionalResources () {
370370 return Stream .of (
371- arguments (
372- URI .create (config .get ("solid_resource_uri" ) + "/unauthorized" ),
373- 401 ,
374- UnauthorizedException .class
375- ),
376- arguments (
377- URI .create (config .get ("solid_resource_uri" ) + "/forbidden" ),
378- 403 ,
379- ForbiddenException .class
380- ),
381- arguments (
382- URI .create (config .get ("solid_resource_uri" ) + "/missing" ),
383- 404 ,
384- NotFoundException .class
385- )
371+ arguments (URI .create (config .get ("solid_resource_uri" ) + "/unauthorized" ), 401 , UnauthorizedException .class ),
372+ arguments (URI .create (config .get ("solid_resource_uri" ) + "/forbidden" ), 403 , ForbiddenException .class ),
373+ arguments (URI .create (config .get ("solid_resource_uri" ) + "/missing" ), 404 , NotFoundException .class )
386374 );
387375 }
388376
@@ -504,138 +492,77 @@ public int statusCode() {
504492 assertEquals (problemDetails .getInstance (), exception .getProblemDetails ().getInstance ());
505493 }
506494
495+ private static ProblemDetails mockProblemDetails (final String title , final String details , final int status ) {
496+ return new ProblemDetails (
497+ URI .create ("https://example.org/type" ),
498+ title ,
499+ details ,
500+ status ,
501+ URI .create ("https://example.org/instance" )
502+ );
503+ }
504+
507505 private static Stream <Arguments > testRfc9457Exceptions () {
508506 return Stream .of (
509507 arguments (
510508 BadRequestException .class ,
511- new ProblemDetails (
512- URI .create ("https://example.org/type" ),
513- "Bad Request" ,
514- "Some details" ,
515- 400 ,
516- URI .create ("https://example.org/instance" )
517- )
518- ), arguments (
509+ mockProblemDetails ("Bad Request" , "Some details" , 400 )
510+ ),
511+ arguments (
519512 UnauthorizedException .class ,
520- new ProblemDetails (
521- URI .create ("https://example.org/type" ),
522- "Unauthorized" ,
523- "Some details" ,
524- 401 ,
525- URI .create ("https://example.org/instance" )
526- )
527- ), arguments (
513+ mockProblemDetails ("Unauthorized" , "Some details" , 401 )
514+ ),
515+ arguments (
528516 ForbiddenException .class ,
529- new ProblemDetails (
530- URI .create ("https://example.org/type" ),
531- "Forbidden" ,
532- "Some details" ,
533- 403 ,
534- URI .create ("https://example.org/instance" )
535- )
536- ), arguments (
517+ mockProblemDetails ("Forbidden" , "Some details" , 403 )
518+ ),
519+ arguments (
537520 NotFoundException .class ,
538- new ProblemDetails (
539- URI .create ("https://example.org/type" ),
540- "Not Found" ,
541- "Some details" ,
542- 404 ,
543- URI .create ("https://example.org/instance" )
544- )
545- ), arguments (
521+ mockProblemDetails ("Not Found" , "Some details" , 404 )
522+ ),
523+ arguments (
546524 MethodNotAllowedException .class ,
547- new ProblemDetails (
548- URI .create ("https://example.org/type" ),
549- "Method Not Allowed" ,
550- "Some details" ,
551- 405 ,
552- URI .create ("https://example.org/instance" )
553- )
554- ), arguments (
525+ mockProblemDetails ("Method Not Allowed" , "Some details" , 405 )
526+ ),
527+ arguments (
555528 NotAcceptableException .class ,
556- new ProblemDetails (
557- URI .create ("https://example.org/type" ),
558- "Not Acceptable" ,
559- "Some details" ,
560- 406 ,
561- URI .create ("https://example.org/instance" )
562- )
563- ), arguments (
529+ mockProblemDetails ("Not Acceptable" , "Some details" , 406 )
530+ ),
531+ arguments (
564532 ConflictException .class ,
565- new ProblemDetails (
566- URI .create ("https://example.org/type" ),
567- "Conflict" ,
568- "Some details" ,
569- 409 ,
570- URI .create ("https://example.org/instance" )
571- )
572- ), arguments (
533+ mockProblemDetails ("Conflict" , "Some details" , 409 )
534+ ),
535+ arguments (
573536 GoneException .class ,
574- new ProblemDetails (
575- URI .create ("https://example.org/type" ),
576- "Gone" ,
577- "Some details" ,
578- 410 ,
579- URI .create ("https://example.org/instance" )
580- )
581- ), arguments (
537+ mockProblemDetails ("Gone" , "Some details" , 410 )
538+ ),
539+ arguments (
582540 PreconditionFailedException .class ,
583- new ProblemDetails (
584- URI .create ("https://example.org/type" ),
585- "Precondition Failed" ,
586- "Some details" ,
587- 412 ,
588- URI .create ("https://example.org/instance" )
589- )
590- ), arguments (
541+ mockProblemDetails ("Precondition Failed" , "Some details" , 412 )
542+ ),
543+ arguments (
591544 UnsupportedMediaTypeException .class ,
592- new ProblemDetails (
593- URI .create ("https://example.org/type" ),
594- "Unsupported Media Type" ,
595- "Some details" ,
596- 415 ,
597- URI .create ("https://example.org/instance" )
598- )
599- ), arguments (
545+ mockProblemDetails ("Unsupported Media Type" , "Some details" , 415 )
546+ ),
547+ arguments (
600548 TooManyRequestsException .class ,
601- new ProblemDetails (
602- URI .create ("https://example.org/type" ),
603- "Too Many Requests" ,
604- "Some details" ,
605- 429 ,
606- URI .create ("https://example.org/instance" )
607- )
608- ), arguments (
549+ mockProblemDetails ("Too Many Requests" , "Some details" , 429 )
550+ ),
551+ arguments (
609552 InternalServerErrorException .class ,
610- new ProblemDetails (
611- URI .create ("https://example.org/type" ),
612- "Internal Server Error" ,
613- "Some details" ,
614- 500 ,
615- URI .create ("https://example.org/instance" )
616- )
617- ), arguments (
553+ mockProblemDetails ("Internal Server Error" , "Some details" , 500 )
554+ ),
555+ arguments (
618556 // Custom errors that do not map to a predefined Exception class
619557 // default to the generic SolidClientException
620558 SolidClientException .class ,
621- new ProblemDetails (
622- URI .create ("https://example.org/type" ),
623- "I'm a Teapot" ,
624- "Some details" ,
625- 418 ,
626- URI .create ("https://example.org/instance" )
627- )
628- ), arguments (
559+ mockProblemDetails ("I'm a Teapot" , "Some details" , 418 )
560+ ),
561+ arguments (
629562 // Custom errors that do not map to a predefined Exception class
630563 // default to the generic SolidClientException.
631564 SolidClientException .class ,
632- new ProblemDetails (
633- URI .create ("https://example.org/type" ),
634- "Custom server error" ,
635- "Some details" ,
636- 599 ,
637- URI .create ("https://example.org/instance" )
638- )
565+ mockProblemDetails ("Custom server error" , "Some details" , 599 )
639566 )
640567 );
641568 }
0 commit comments