@@ -33,36 +33,33 @@ public void testCreateOptionsBuilderMinimal() {
3333 }
3434
3535 @ Test
36- public void testCreateOptionsBuilderWithPath () {
37- CreateOptions options = CreateOptions .builder ()
36+ public void testCreateOptionsBuilderIndividualFields () {
37+ // Test path only
38+ CreateOptions pathOptions = CreateOptions .builder ()
3839 .path ("/application/backend/" )
3940 .build ();
4041
41- assertEquals ("/application/backend/" , options .getPath ());
42- assertNull (options .getMaxSessionDuration ());
43- assertNull (options .getPermissionBoundary ());
44- }
42+ assertEquals ("/application/backend/" , pathOptions .getPath ());
43+ assertNull (pathOptions .getMaxSessionDuration ());
44+ assertNull (pathOptions .getPermissionBoundary ());
4545
46- @ Test
47- public void testCreateOptionsBuilderWithMaxSessionDuration () {
48- CreateOptions options = CreateOptions .builder ()
46+ // Test maxSessionDuration only
47+ CreateOptions durationOptions = CreateOptions .builder ()
4948 .maxSessionDuration (7200 )
5049 .build ();
5150
52- assertNull (options .getPath ());
53- assertEquals (Integer .valueOf (7200 ), options .getMaxSessionDuration ());
54- assertNull (options .getPermissionBoundary ());
55- }
51+ assertNull (durationOptions .getPath ());
52+ assertEquals (Integer .valueOf (7200 ), durationOptions .getMaxSessionDuration ());
53+ assertNull (durationOptions .getPermissionBoundary ());
5654
57- @ Test
58- public void testCreateOptionsBuilderWithPermissionBoundary () {
59- CreateOptions options = CreateOptions .builder ()
55+ // Test permissionBoundary only
56+ CreateOptions boundaryOptions = CreateOptions .builder ()
6057 .permissionBoundary ("arn:aws:iam::123456789012:policy/DeveloperBoundary" )
6158 .build ();
6259
63- assertNull (options .getPath ());
64- assertNull (options .getMaxSessionDuration ());
65- assertEquals ("arn:aws:iam::123456789012:policy/DeveloperBoundary" , options .getPermissionBoundary ());
60+ assertNull (boundaryOptions .getPath ());
61+ assertNull (boundaryOptions .getMaxSessionDuration ());
62+ assertEquals ("arn:aws:iam::123456789012:policy/DeveloperBoundary" , boundaryOptions .getPermissionBoundary ());
6663 }
6764
6865 @ Test
@@ -86,41 +83,6 @@ public void testCreateOptionsBuilderWithCustomSessionDurations() {
8683 assertEquals (Integer .valueOf (7200 ), commonOptions .getMaxSessionDuration ());
8784 }
8885
89- @ Test
90- public void testCreateOptionsBuilderWithDifferentPaths () {
91- // Test root path
92- CreateOptions rootOptions = CreateOptions .builder ()
93- .path ("/" )
94- .build ();
95- assertEquals ("/" , rootOptions .getPath ());
96-
97- // Test nested path
98- CreateOptions nestedOptions = CreateOptions .builder ()
99- .path ("/division/team/service/" )
100- .build ();
101- assertEquals ("/division/team/service/" , nestedOptions .getPath ());
102-
103- // Test simple path
104- CreateOptions simpleOptions = CreateOptions .builder ()
105- .path ("/service-roles/" )
106- .build ();
107- assertEquals ("/service-roles/" , simpleOptions .getPath ());
108- }
109-
110- @ Test
111- public void testCreateOptionsBuilderWithDifferentPermissionBoundaries () {
112- // Test AWS IAM policy ARN
113- CreateOptions awsOptions = CreateOptions .builder ()
114- .permissionBoundary ("arn:aws:iam::123456789012:policy/PowerUserBoundary" )
115- .build ();
116- assertEquals ("arn:aws:iam::123456789012:policy/PowerUserBoundary" , awsOptions .getPermissionBoundary ());
117-
118- // Test different policy name
119- CreateOptions devOptions = CreateOptions .builder ()
120- .permissionBoundary ("arn:aws:iam::987654321098:policy/DeveloperBoundary" )
121- .build ();
122- assertEquals ("arn:aws:iam::987654321098:policy/DeveloperBoundary" , devOptions .getPermissionBoundary ());
123- }
12486
12587 @ Test
12688 public void testCreateOptionsBuilderComplexScenario () {
@@ -136,7 +98,7 @@ public void testCreateOptionsBuilderComplexScenario() {
13698 }
13799
138100 @ Test
139- public void testCreateOptionsEquality () {
101+ public void testCreateOptionsEqualsAndHashCode () {
140102 CreateOptions options1 = CreateOptions .builder ()
141103 .path ("/test/" )
142104 .maxSessionDuration (3600 )
@@ -149,29 +111,69 @@ public void testCreateOptionsEquality() {
149111 .permissionBoundary ("arn:aws:iam::123456789012:policy/TestBoundary" )
150112 .build ();
151113
152- CreateOptions options3 = CreateOptions .builder ()
114+ CreateOptions differentPath = CreateOptions .builder ()
153115 .path ("/different/" )
154116 .maxSessionDuration (3600 )
155117 .permissionBoundary ("arn:aws:iam::123456789012:policy/TestBoundary" )
156118 .build ();
157119
120+ CreateOptions differentDuration = CreateOptions .builder ()
121+ .path ("/test/" )
122+ .maxSessionDuration (7200 )
123+ .permissionBoundary ("arn:aws:iam::123456789012:policy/TestBoundary" )
124+ .build ();
125+
126+ CreateOptions nullOptions = CreateOptions .builder ().build ();
127+ CreateOptions anotherNullOptions = CreateOptions .builder ().build ();
128+
129+ // Test equals
158130 assertEquals (options1 , options2 );
159- assertNotEquals (options1 , options3 );
131+ assertEquals (options1 , options1 ); // same object
132+ assertNotEquals (options1 , differentPath );
133+ assertNotEquals (options1 , differentDuration );
134+ assertNotEquals (options1 , null );
135+ assertNotEquals (options1 , "not create options" );
136+ assertEquals (nullOptions , anotherNullOptions );
137+
138+ // Test hashCode
160139 assertEquals (options1 .hashCode (), options2 .hashCode ());
140+ assertNotEquals (options1 .hashCode (), differentPath .hashCode ());
141+ assertEquals (nullOptions .hashCode (), anotherNullOptions .hashCode ());
161142 }
162143
163144 @ Test
164145 public void testCreateOptionsToString () {
146+ // Test with all fields populated
165147 CreateOptions options = CreateOptions .builder ()
166148 .path ("/test/" )
167149 .maxSessionDuration (7200 )
168150 .permissionBoundary ("arn:aws:iam::123456789012:policy/TestBoundary" )
169151 .build ();
170152
171- String toString = options .toString ();
172- assertTrue (toString .contains ("path='/test/'" ));
173- assertTrue (toString .contains ("maxSessionDuration=7200" ));
174- assertTrue (toString .contains ("permissionBoundary='arn:aws:iam::123456789012:policy/TestBoundary'" ));
153+ String result = options .toString ();
154+ assertTrue (result .contains ("path='/test/'" ));
155+ assertTrue (result .contains ("maxSessionDuration=7200" ));
156+ assertTrue (result .contains ("permissionBoundary='arn:aws:iam::123456789012:policy/TestBoundary'" ));
157+
158+ // Test with null values
159+ CreateOptions nullOptions = CreateOptions .builder ().build ();
160+ String nullResult = nullOptions .toString ();
161+ assertTrue (nullResult .contains ("CreateOptions" ));
162+ assertTrue (nullResult .contains ("path='null'" ));
163+ assertTrue (nullResult .contains ("maxSessionDuration=null" ));
164+ assertTrue (nullResult .contains ("permissionBoundary='null'" ));
165+
166+ // Test with partial values
167+ CreateOptions partialOptions = CreateOptions .builder ()
168+ .path ("/test/" )
169+ .maxSessionDuration (null )
170+ .permissionBoundary ("arn:aws:iam::123456789012:policy/TestBoundary" )
171+ .build ();
172+
173+ String partialResult = partialOptions .toString ();
174+ assertTrue (partialResult .contains ("path='/test/'" ));
175+ assertTrue (partialResult .contains ("maxSessionDuration=null" ));
176+ assertTrue (partialResult .contains ("permissionBoundary='arn:aws:iam::123456789012:policy/TestBoundary'" ));
175177 }
176178
177179 @ Test
@@ -196,4 +198,21 @@ public void testCreateOptionsBuilderNullValues() {
196198 assertNull (options .getMaxSessionDuration ());
197199 assertNull (options .getPermissionBoundary ());
198200 }
201+
202+
203+ @ Test
204+ public void testCreateOptionsBuilderOverwriteValues () {
205+ CreateOptions options = CreateOptions .builder ()
206+ .path ("/first/" )
207+ .path ("/second/" ) // This should overwrite the first value
208+ .maxSessionDuration (3600 )
209+ .maxSessionDuration (7200 ) // This should overwrite the first value
210+ .permissionBoundary ("arn:aws:iam::123456789012:policy/FirstBoundary" )
211+ .permissionBoundary ("arn:aws:iam::123456789012:policy/SecondBoundary" ) // This should overwrite
212+ .build ();
213+
214+ assertEquals ("/second/" , options .getPath ());
215+ assertEquals (Integer .valueOf (7200 ), options .getMaxSessionDuration ());
216+ assertEquals ("arn:aws:iam::123456789012:policy/SecondBoundary" , options .getPermissionBoundary ());
217+ }
199218}
0 commit comments