@@ -80,9 +80,7 @@ void testSettingsRoundTrip() {
8080 UtilIT .setSetting (harmlessSetting , harmlessL10nValue , language );
8181
8282 // Step 1: Get current settings state
83- Response getResponse = given ()
84- .when ()
85- .get ("/api/admin/settings" );
83+ Response getResponse = UtilIT .getSettings ();
8684
8785 getResponse .then ()
8886 .assertThat ()
@@ -111,12 +109,7 @@ void testSettingsRoundTrip() {
111109 .body ("data.message" , equalTo (harmlessValue ));
112110
113111 // Step 4: Put back the original settings (this is what we're testing)
114- Response putResponse = given ()
115- //.header("X-Dataverse-key", "")
116- .header ("Content-Type" , "application/json" )
117- .body (originalSettings .toString ())
118- .when ()
119- .put ("/api/admin/settings" );
112+ Response putResponse = UtilIT .setSettings (originalSettings .toString ());
120113
121114 putResponse .then ()
122115 .assertThat ()
@@ -125,20 +118,14 @@ void testSettingsRoundTrip() {
125118 .body ("message.message" , containsString ("successfully updated" ));
126119
127120 // Step 5: Verify the harmless setting is gone (restored to original state)
128- Response verifyRestoredResponse = given ()
129- //.header("X-Dataverse-key", "")
130- .when ()
131- .get ("/api/admin/settings" + harmlessSetting .toString ());
121+ Response verifyRestoredResponse = UtilIT .getSetting (harmlessSetting );
132122
133123 verifyRestoredResponse .then ()
134124 .assertThat ()
135125 .statusCode (NOT_FOUND .getStatusCode ()); // Should not exist anymore
136126
137127 // Step 6: Verify overall settings state matches original
138- Response finalGetResponse = given ()
139- //.header("X-Dataverse-key", "")
140- .when ()
141- .get ("/api/admin/settings" );
128+ Response finalGetResponse = UtilIT .getSettings ();
142129
143130 finalGetResponse .then ()
144131 .assertThat ()
@@ -165,9 +152,7 @@ void testGetAllSettingsWithLocalization() {
165152 UtilIT .setSetting (harmlessSetting , harmlessL10nValue , language );
166153
167154 // When
168- Response getResponse = given ()
169- .when ()
170- .get ("/api/admin/settings" );
155+ Response getResponse = UtilIT .getSettings ();
171156
172157 // Then
173158 getResponse .then ()
@@ -184,11 +169,7 @@ void testGetAllSettingsWithLocalization() {
184169 @ Test
185170 void testPutAllSettingsWithEmptyJson () {
186171 // Test error handling for empty JSON
187- Response response = given ()
188- .header ("Content-Type" , "application/json" )
189- .body ("{}" )
190- .when ()
191- .put ("/api/admin/settings" );
172+ Response response = UtilIT .setSettings ("{}" );
192173
193174 response .then ()
194175 .assertThat ()
@@ -199,11 +180,7 @@ void testPutAllSettingsWithEmptyJson() {
199180 @ Test
200181 void testPutAllSettingsWithInvalidSetting () {
201182 // Test error handling for empty JSON
202- Response response = given ()
203- .header ("Content-Type" , "application/json" )
204- .body ("{\" :Test1\" : \" Foobar\" , \" :Test2\" : \" Foobar\" }" )
205- .when ()
206- .put ("/api/admin/settings" );
183+ Response response = UtilIT .setSettings ("{\" :Test1\" : \" Foobar\" , \" :Test2\" : \" Foobar\" }" );
207184
208185 response .then ()
209186 .assertThat ()
@@ -242,7 +219,7 @@ public void testListAuthenticatedUsers() throws Exception {
242219
243220 Response deleteSuperuser = UtilIT .deleteUser (superuserUsername );
244221 assertEquals (200 , deleteSuperuser .getStatusCode ());
245- }
222+ }
246223
247224 @ Test
248225 public void testFilterAuthenticatedUsersForbidden () throws Exception {
0 commit comments