@@ -320,41 +320,40 @@ public void invalidArnWithoutAccountId_ThrowsIllegalArgumentException() {
320320
321321 private static Stream <Arguments > validArnTestCases () {
322322 return Stream .of (
323- // Test case name, ARN string
324- Arguments .of ("Basic Resource" , "arn:aws:s3:us-east-1:12345678910:myresource" ),
325- Arguments .of ("Minimal Requirements" , "arn:aws:foobar:::myresource" ),
326- Arguments .of ("Qualified Resource" , "arn:aws:s3:us-east-1:12345678910:myresource:foobar:1" ),
327- Arguments .of ("Minimal Resources" , "arn:aws:s3:::bucket" ),
328- Arguments .of ("Without Region" , "arn:aws:iam::123456789012:root" ),
329- Arguments .of ("Resource Type And Resource" , "arn:aws:s3:us-east-1:12345678910:bucket:foobar" ),
330- Arguments .of ("Resource Type And Resource And Qualifier" , "arn:aws:s3:us-east-1:12345678910:bucket:foobar:1" ),
331- Arguments .of ("Resource Type And Resource With Slash" , "arn:aws:s3:us-east-1:12345678910:bucket/foobar" ),
332- Arguments .of ("Resource Type And Resource And Qualifier With Slash" , "arn:aws:s3:us-east-1:12345678910:bucket/foobar/1" ),
333- Arguments .of ("Without Region" , "arn:aws:s3::123456789012:myresource" ),
334- Arguments .of ("Without AccountId" , "arn:aws:s3:us-east-1::myresource" ),
335- Arguments .of ("Resource Containing Dots" , "arn:aws:s3:us-east-1:12345678910:myresource:foobar.1" )
323+ Arguments .of ("Basic resource" , "arn:aws:s3:us-east-1:12345678910:myresource" ),
324+ Arguments .of ("Minimal requirements" , "arn:aws:foobar:::myresource" ),
325+ Arguments .of ("Qualified resource" , "arn:aws:s3:us-east-1:12345678910:myresource:foobar:1" ),
326+ Arguments .of ("Minimal resources" , "arn:aws:s3:::bucket" ),
327+ Arguments .of ("Without region" , "arn:aws:iam::123456789012:root" ),
328+ Arguments .of ("Resource type and resource" , "arn:aws:s3:us-east-1:12345678910:bucket:foobar" ),
329+ Arguments .of ("Resource type And resource and qualifier" ,
330+ "arn:aws:s3:us-east-1:12345678910:bucket:foobar:1" ),
331+ Arguments .of ("Resource type And resource with slash" , "arn:aws:s3:us-east-1:12345678910:bucket/foobar" ),
332+ Arguments .of ("Resource type and resource and qualifier slash" ,
333+ "arn:aws:s3:us-east-1:12345678910:bucket/foobar/1" ),
334+ Arguments .of ("Without region" , "arn:aws:s3::123456789012:myresource" ),
335+ Arguments .of ("Without accountId" , "arn:aws:s3:us-east-1::myresource" ),
336+ Arguments .of ("Resource with dots" , "arn:aws:s3:us-east-1:12345678910:myresource:foobar.1" )
336337 );
337338 }
338339
339340 private static Stream <Arguments > invalidArnTestCases () {
340341 return Stream .of (
341- // Test case name, ARN string
342- Arguments .of ("Without Partition" , "arn::s3:us-east-1:12345678910:myresource" ),
343- Arguments .of ("Without Service" , "arn:aws::us-east-1:12345678910:myresource" ),
344- Arguments .of ("Without Resource" , "arn:aws:s3:us-east-1:12345678910:" ),
345- Arguments .of ("Invalid ARN" , "arn:aws:" ),
346- Arguments .of ("Doesn't Start With ARN" , "fakearn:aws:" ),
347- Arguments .of ("Invalid Without Partition" , "arn:" ),
348- Arguments .of ("Invalid Without Service" , "arn:aws:" ),
349- Arguments .of ("Invalid Without Region" , "arn:aws:s3:" ),
350- Arguments .of ("Invalid Without AccountId" , "arn:aws:s3:us-east-1:" )
342+ Arguments .of ("Without resource" , "arn:aws:s3:us-east-1:12345678910:" ),
343+ Arguments .of ("Invalid arn" , "arn:aws:" ),
344+ Arguments .of ("Doesn't start with arn" , "fakearn:aws:" ),
345+ Arguments .of ("Invalid without partition" , "arn:" ),
346+ Arguments .of ("Invalid without service" , "arn:aws:" ),
347+ Arguments .of ("Invalid without region" , "arn:aws:s3:" ),
348+ Arguments .of ("Invalid without accountId" , "arn:aws:s3:us-east-1:" ),
349+ Arguments .of ("Null Arn" , null )
351350 );
352351 }
353352
354353 private static Stream <Arguments > exceptionThrowingArnTestCases () {
355354 return Stream .of (
356- Arguments .of ("Without Partition " , "arn::s3:us-east-1:12345678910:myresource" ),
357- Arguments .of ("Without Service " , "arn:aws::us-east-1:12345678910:myresource" )
355+ Arguments .of ("Valid without partition " , "arn::s3:us-east-1:12345678910:myresource" ),
356+ Arguments .of ("Valid without service " , "arn:aws::us-east-1:12345678910:myresource" )
358357 );
359358 }
360359
@@ -365,7 +364,6 @@ public void optionalArnFromString_ValidArns_ReturnsPopulatedOptional(String test
365364
366365 assertThat (optionalArn ).isPresent ();
367366
368- // Compare with the original fromString implementation
369367 Arn expectedArn = Arn .fromString (arnString );
370368 Arn actualArn = optionalArn .get ();
371369
@@ -375,7 +373,6 @@ public void optionalArnFromString_ValidArns_ReturnsPopulatedOptional(String test
375373 assertThat (actualArn .accountId ()).isEqualTo (expectedArn .accountId ());
376374 assertThat (actualArn .resourceAsString ()).isEqualTo (expectedArn .resourceAsString ());
377375
378- // Verify the ARN string representation matches
379376 assertThat (actualArn .toString ()).isEqualTo (arnString );
380377 }
381378
@@ -394,31 +391,4 @@ public void tryFromString_InvalidArns_ShouldThrowExceptions(String testName, Str
394391 });
395392 }
396393
397- @ Test
398- public void optionalArnFromString_NullInput_ReturnsEmptyOptional () {
399- Optional <Arn > optionalArn = Arn .tryFromString (null );
400- assertThat (optionalArn ).isEmpty ();
401- }
402-
403- @ ParameterizedTest (name = "Resource parsing: {0}" )
404- @ MethodSource ("validArnTestCases" )
405- public void tryFromString_ResourceParsing_MatchesOriginalImplementation (String testName , String arnString ) {
406- // Skip test cases that would throw exceptions in the resource parsing
407- if (arnString .contains ("bucket:" ) || arnString .contains ("bucket/" )) {
408- Optional <Arn > optionalArn = Arn .tryFromString (arnString );
409- assertThat (optionalArn ).isPresent ();
410-
411- Arn expectedArn = Arn .fromString (arnString );
412- Arn actualArn = optionalArn .get ();
413-
414- // Verify resource parsing
415- ArnResource expectedResource = expectedArn .resource ();
416- ArnResource actualResource = actualArn .resource ();
417-
418- assertThat (actualResource .resourceType ()).isEqualTo (expectedResource .resourceType ());
419- assertThat (actualResource .resource ()).isEqualTo (expectedResource .resource ());
420- assertThat (actualResource .qualifier ()).isEqualTo (expectedResource .qualifier ());
421- }
422- }
423-
424394}
0 commit comments