66import org .junit .jupiter .api .Assertions ;
77import org .junit .jupiter .api .Test ;
88
9+ import java .lang .reflect .Method ;
910import java .util .List ;
1011
1112class CxConfigTest extends BaseTest {
1213
1314 @ Test
14- void testApiKeyAuthentication () {
15+ void testApiKeyAuthentication () throws Exception {
1516 CxConfig config = CxConfig .builder ()
1617 .apiKey ("test-api-key" )
1718 .build ();
1819
19- List <String > arguments = config .toArguments ();
20+ Method toArgumentsMethod = CxConfig .class .getDeclaredMethod ("toArguments" );
21+ toArgumentsMethod .setAccessible (true );
22+ List <String > arguments = (List <String >) toArgumentsMethod .invoke (config );
23+
2024 Assertions .assertTrue (arguments .contains (CxConstants .API_KEY ));
2125 Assertions .assertTrue (arguments .contains ("test-api-key" ));
2226 }
2327
2428 @ Test
25- void testClientIdSecretAuthentication () {
29+ void testClientIdSecretAuthentication () throws Exception {
2630 CxConfig config = CxConfig .builder ()
2731 .clientId ("test-client-id" )
2832 .clientSecret ("test-client-secret" )
2933 .build ();
3034
31- List <String > arguments = config .toArguments ();
35+ Method toArgumentsMethod = CxConfig .class .getDeclaredMethod ("toArguments" );
36+ toArgumentsMethod .setAccessible (true );
37+ List <String > arguments = (List <String >) toArgumentsMethod .invoke (config );
38+
3239 Assertions .assertTrue (arguments .contains (CxConstants .CLIENT_ID ));
3340 Assertions .assertTrue (arguments .contains ("test-client-id" ));
3441 Assertions .assertTrue (arguments .contains (CxConstants .CLIENT_SECRET ));
3542 Assertions .assertTrue (arguments .contains ("test-client-secret" ));
3643 }
3744
3845 @ Test
39- void testTenantAndBaseUris () {
46+ void testTenantAndBaseUris () throws Exception {
4047 CxConfig config = CxConfig .builder ()
4148 .tenant ("test-tenant" )
4249 .baseUri ("https://example.com" )
4350 .baseAuthUri ("https://auth.example.com" )
4451 .build ();
4552
46- List <String > arguments = config .toArguments ();
53+ Method toArgumentsMethod = CxConfig .class .getDeclaredMethod ("toArguments" );
54+ toArgumentsMethod .setAccessible (true );
55+ List <String > arguments = (List <String >) toArgumentsMethod .invoke (config );
56+
4757 Assertions .assertTrue (arguments .contains (CxConstants .TENANT ));
4858 Assertions .assertTrue (arguments .contains ("test-tenant" ));
4959 Assertions .assertTrue (arguments .contains (CxConstants .BASE_URI ));
@@ -53,35 +63,14 @@ void testTenantAndBaseUris() {
5363 }
5464
5565 @ Test
56- void testEmptyConfig () {
66+ void testEmptyConfig () throws Exception {
5767 CxConfig config = CxConfig .builder ().build ();
5868
59- List <String > arguments = config .toArguments ();
60- Assertions .assertTrue (arguments .isEmpty ());
61- }
62-
63- @ Test
64- void testAdditionalParametersParsing () {
65- CxConfig config = CxConfig .builder ()
66- .additionalParameters ("--debug --verbose \" multi word value\" " )
67- .build ();
68-
69- List <String > arguments = config .getAdditionalParameters ();
70- Assertions .assertEquals (3 , arguments .size ());
71- Assertions .assertTrue (arguments .contains ("--debug" ));
72- Assertions .assertTrue (arguments .contains ("--verbose" ));
73- Assertions .assertTrue (arguments .contains ("multi word value" ));
74- }
75-
76- @ Test
77- void testSpecialCharactersInAdditionalParameters () {
78- CxConfig config = CxConfig .builder ()
79- .additionalParameters ("--path \" C:\\ Program Files\\ Tool\" " )
80- .build ();
69+ Method toArgumentsMethod = CxConfig .class .getDeclaredMethod ("toArguments" );
70+ toArgumentsMethod .setAccessible (true );
71+ List <String > arguments = (List <String >) toArgumentsMethod .invoke (config );
8172
82- List <String > arguments = config .getAdditionalParameters ();
83- Assertions .assertEquals (1 , arguments .size ());
84- Assertions .assertTrue (arguments .contains ("C:\\ Program Files\\ Tool" ));
73+ Assertions .assertTrue (arguments .isEmpty ());
8574 }
8675
8776 @ Test
0 commit comments