@ahmttyydn/java-integration 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +762 -0
  2. package/README.md +37 -0
  3. package/package.json +46 -0
  4. package/pom.xml +242 -0
  5. package/scalar-core/pom.xml +92 -0
  6. package/scalar-core/src/main/java/com/scalar/maven/core/ScalarConstants.java +26 -0
  7. package/scalar-core/src/main/java/com/scalar/maven/core/ScalarHtmlRenderer.java +135 -0
  8. package/scalar-core/src/main/java/com/scalar/maven/core/ScalarProperties.java +596 -0
  9. package/scalar-core/src/main/java/com/scalar/maven/core/authentication/ScalarAuthenticationOptions.java +235 -0
  10. package/scalar-core/src/main/java/com/scalar/maven/core/authentication/flows/AuthorizationCodeFlow.java +160 -0
  11. package/scalar-core/src/main/java/com/scalar/maven/core/authentication/flows/ClientCredentialsFlow.java +88 -0
  12. package/scalar-core/src/main/java/com/scalar/maven/core/authentication/flows/ImplicitFlow.java +64 -0
  13. package/scalar-core/src/main/java/com/scalar/maven/core/authentication/flows/OAuthFlow.java +185 -0
  14. package/scalar-core/src/main/java/com/scalar/maven/core/authentication/flows/PasswordFlow.java +134 -0
  15. package/scalar-core/src/main/java/com/scalar/maven/core/authentication/flows/ScalarFlows.java +113 -0
  16. package/scalar-core/src/main/java/com/scalar/maven/core/authentication/schemes/ScalarApiKeySecurityScheme.java +77 -0
  17. package/scalar-core/src/main/java/com/scalar/maven/core/authentication/schemes/ScalarHttpSecurityScheme.java +115 -0
  18. package/scalar-core/src/main/java/com/scalar/maven/core/authentication/schemes/ScalarOAuth2SecurityScheme.java +75 -0
  19. package/scalar-core/src/main/java/com/scalar/maven/core/authentication/schemes/ScalarSecurityScheme.java +45 -0
  20. package/scalar-core/src/main/java/com/scalar/maven/core/config/DefaultHttpClient.java +77 -0
  21. package/scalar-core/src/main/java/com/scalar/maven/core/config/ScalarAgentOptions.java +68 -0
  22. package/scalar-core/src/main/java/com/scalar/maven/core/config/ScalarServer.java +197 -0
  23. package/scalar-core/src/main/java/com/scalar/maven/core/config/ScalarSource.java +151 -0
  24. package/scalar-core/src/main/java/com/scalar/maven/core/enums/CredentialsLocation.java +52 -0
  25. package/scalar-core/src/main/java/com/scalar/maven/core/enums/DeveloperToolsVisibility.java +58 -0
  26. package/scalar-core/src/main/java/com/scalar/maven/core/enums/DocumentDownloadType.java +67 -0
  27. package/scalar-core/src/main/java/com/scalar/maven/core/enums/OperationSorter.java +52 -0
  28. package/scalar-core/src/main/java/com/scalar/maven/core/enums/OperationTitleSource.java +52 -0
  29. package/scalar-core/src/main/java/com/scalar/maven/core/enums/Pkce.java +57 -0
  30. package/scalar-core/src/main/java/com/scalar/maven/core/enums/PropertyOrder.java +53 -0
  31. package/scalar-core/src/main/java/com/scalar/maven/core/enums/ScalarClient.java +208 -0
  32. package/scalar-core/src/main/java/com/scalar/maven/core/enums/ScalarLayout.java +52 -0
  33. package/scalar-core/src/main/java/com/scalar/maven/core/enums/ScalarTarget.java +158 -0
  34. package/scalar-core/src/main/java/com/scalar/maven/core/enums/ScalarTheme.java +102 -0
  35. package/scalar-core/src/main/java/com/scalar/maven/core/enums/TagSorter.java +47 -0
  36. package/scalar-core/src/main/java/com/scalar/maven/core/enums/ThemeMode.java +52 -0
  37. package/scalar-core/src/main/java/com/scalar/maven/core/internal/ScalarConfiguration.java +425 -0
  38. package/scalar-core/src/main/java/com/scalar/maven/core/internal/ScalarConfigurationMapper.java +69 -0
  39. package/scalar-core/src/main/resources/META-INF/resources/webjars/scalar/index.html +22 -0
  40. package/scalar-core/src/test/java/com/scalar/maven/core/ScalarConfigurationTest.java +144 -0
  41. package/scalar-core/src/test/java/com/scalar/maven/core/ScalarHtmlRendererTest.java +104 -0
  42. package/scalar-core/src/test/java/com/scalar/maven/core/ScalarPropertiesTest.java +525 -0
  43. package/scalar-core/src/test/java/com/scalar/maven/core/config/DefaultHttpClientTest.java +61 -0
  44. package/scalar-core/src/test/java/com/scalar/maven/core/config/ScalarAgentOptionsTest.java +80 -0
  45. package/scalar-core/src/test/java/com/scalar/maven/core/config/ScalarServerTest.java +118 -0
  46. package/scalar-core/src/test/java/com/scalar/maven/core/config/ScalarSourceTest.java +105 -0
  47. package/scalar-playground-webflux/pom.xml +52 -0
  48. package/scalar-playground-webflux/src/main/java/com/scalar/maven/playground/CustomScalarWebFluxController.java +34 -0
  49. package/scalar-playground-webflux/src/main/java/com/scalar/maven/playground/PlaygroundApplication.java +27 -0
  50. package/scalar-playground-webflux/src/main/resources/application.properties +7 -0
  51. package/scalar-playground-webmvc/pom.xml +52 -0
  52. package/scalar-playground-webmvc/src/main/java/com/scalar/maven/playground/CustomScalarWebMvcController.java +34 -0
  53. package/scalar-playground-webmvc/src/main/java/com/scalar/maven/playground/PlaygroundApplication.java +27 -0
  54. package/scalar-playground-webmvc/src/main/resources/application.properties +7 -0
  55. package/scalar-webflux/pom.xml +110 -0
  56. package/scalar-webflux/src/main/java/com/scalar/maven/webflux/ScalarWebFluxActuatorEndpoint.java +103 -0
  57. package/scalar-webflux/src/main/java/com/scalar/maven/webflux/ScalarWebFluxAutoConfiguration.java +63 -0
  58. package/scalar-webflux/src/main/java/com/scalar/maven/webflux/ScalarWebFluxController.java +109 -0
  59. package/scalar-webflux/src/main/java/com/scalar/maven/webflux/SpringBootScalarProperties.java +43 -0
  60. package/scalar-webflux/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +2 -0
  61. package/scalar-webflux/src/test/java/com/scalar/maven/webflux/ScalarWebFluxActuatorEndpointTest.java +136 -0
  62. package/scalar-webflux/src/test/java/com/scalar/maven/webflux/ScalarWebFluxControllerTest.java +162 -0
  63. package/scalar-webmvc/pom.xml +103 -0
  64. package/scalar-webmvc/src/main/java/com/scalar/maven/webmvc/ScalarWebMvcActuatorEndpoint.java +97 -0
  65. package/scalar-webmvc/src/main/java/com/scalar/maven/webmvc/ScalarWebMvcAutoConfiguration.java +63 -0
  66. package/scalar-webmvc/src/main/java/com/scalar/maven/webmvc/ScalarWebMvcController.java +103 -0
  67. package/scalar-webmvc/src/main/java/com/scalar/maven/webmvc/SpringBootScalarProperties.java +43 -0
  68. package/scalar-webmvc/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports +2 -0
  69. package/scalar-webmvc/src/test/java/com/scalar/maven/webmvc/ScalarWebMvcActuatorEndpointTest.java +128 -0
  70. package/scalar-webmvc/src/test/java/com/scalar/maven/webmvc/ScalarWebMvcControllerTest.java +154 -0
@@ -0,0 +1,525 @@
1
+ package com.scalar.maven.core;
2
+
3
+ import com.scalar.maven.core.config.ScalarSource;
4
+ import com.scalar.maven.core.enums.DeveloperToolsVisibility;
5
+ import com.scalar.maven.core.enums.DocumentDownloadType;
6
+ import com.scalar.maven.core.enums.ScalarLayout;
7
+ import com.scalar.maven.core.enums.ScalarTheme;
8
+ import org.junit.jupiter.api.BeforeEach;
9
+ import org.junit.jupiter.api.DisplayName;
10
+ import org.junit.jupiter.api.Nested;
11
+ import org.junit.jupiter.api.Test;
12
+ import org.junit.jupiter.params.ParameterizedTest;
13
+ import org.junit.jupiter.params.provider.ValueSource;
14
+
15
+ import java.util.List;
16
+
17
+ import static org.assertj.core.api.Assertions.assertThat;
18
+
19
+ @DisplayName("ScalarProperties")
20
+ class ScalarPropertiesTest {
21
+
22
+ private ScalarProperties properties;
23
+
24
+ @BeforeEach
25
+ void setUp() {
26
+ properties = new ScalarProperties();
27
+ }
28
+
29
+ @Nested
30
+ @DisplayName("default values")
31
+ class DefaultValues {
32
+
33
+ @Test
34
+ @DisplayName("should have correct default URL")
35
+ void shouldHaveCorrectDefaultUrl() {
36
+ assertThat(properties.getUrl())
37
+ .isEqualTo("https://registry.scalar.com/@scalar/apis/galaxy?format=json");
38
+ }
39
+
40
+ @Test
41
+ @DisplayName("should be disabled by default")
42
+ void shouldBeDisabledByDefault() {
43
+ assertThat(properties.isEnabled()).isFalse();
44
+ }
45
+
46
+ @Test
47
+ @DisplayName("should have correct default path")
48
+ void shouldHaveCorrectDefaultPath() {
49
+ assertThat(properties.getPath()).isEqualTo("/scalar");
50
+ }
51
+
52
+ @Test
53
+ @DisplayName("should have correct default pageTitle")
54
+ void shouldHaveCorrectDefaultTitle() {
55
+ assertThat(properties.getPageTitle()).isEqualTo("Scalar API Reference");
56
+ }
57
+
58
+ @Test
59
+ @DisplayName("should have correct default showSidebar")
60
+ void shouldHaveCorrectDefaultShowSidebar() {
61
+ assertThat(properties.isShowSidebar()).isTrue();
62
+ }
63
+
64
+ @Test
65
+ @DisplayName("should have correct default hideModels")
66
+ void shouldHaveCorrectDefaultHideModels() {
67
+ assertThat(properties.isHideModels()).isFalse();
68
+ }
69
+
70
+ @Test
71
+ @DisplayName("should have correct default hideTestRequestButton")
72
+ void shouldHaveCorrectDefaultHideTestRequestButton() {
73
+ assertThat(properties.isHideTestRequestButton()).isFalse();
74
+ }
75
+
76
+ @Test
77
+ @DisplayName("should have correct default darkMode")
78
+ void shouldHaveCorrectDefaultDarkMode() {
79
+ assertThat(properties.isDarkMode()).isFalse();
80
+ }
81
+
82
+ @Test
83
+ @DisplayName("should have correct default hideDarkModeToggle")
84
+ void shouldHaveCorrectDefaultHideDarkModeToggle() {
85
+ assertThat(properties.isHideDarkModeToggle()).isFalse();
86
+ }
87
+
88
+ @Test
89
+ @DisplayName("should have correct default theme")
90
+ void shouldHaveCorrectDefaultTheme() {
91
+ assertThat(properties.getTheme()).isEqualTo(ScalarTheme.DEFAULT);
92
+ }
93
+
94
+ @Test
95
+ @DisplayName("should have correct default layout")
96
+ void shouldHaveCorrectDefaultLayout() {
97
+ assertThat(properties.getLayout()).isEqualTo(ScalarLayout.MODERN);
98
+ }
99
+
100
+ @Test
101
+ @DisplayName("should have correct default hideSearch")
102
+ void shouldHaveCorrectDefaultHideSearch() {
103
+ assertThat(properties.isHideSearch()).isFalse();
104
+ }
105
+
106
+ @Test
107
+ @DisplayName("should have correct default documentDownloadType")
108
+ void shouldHaveCorrectDefaultDocumentDownloadType() {
109
+ assertThat(properties.getDocumentDownloadType()).isEqualTo(DocumentDownloadType.BOTH);
110
+ }
111
+
112
+ @Test
113
+ @DisplayName("should have correct default actuatorEnabled")
114
+ void shouldHaveCorrectDefaultActuatorEnabled() {
115
+ assertThat(properties.isActuatorEnabled()).isFalse();
116
+ }
117
+ }
118
+
119
+ @Nested
120
+ @DisplayName("URL property")
121
+ class UrlProperty {
122
+
123
+ @Test
124
+ @DisplayName("should set and get custom URL")
125
+ void shouldSetAndGetCustomUrl() {
126
+ // Given
127
+ String customUrl = "https://example.com/api.json";
128
+
129
+ // When
130
+ properties.setUrl(customUrl);
131
+
132
+ // Then
133
+ assertThat(properties.getUrl()).isEqualTo(customUrl);
134
+ }
135
+
136
+ @Test
137
+ @DisplayName("should handle null URL")
138
+ void shouldHandleNullUrl() {
139
+ // When
140
+ properties.setUrl(null);
141
+
142
+ // Then
143
+ assertThat(properties.getUrl()).isNull();
144
+ }
145
+ }
146
+
147
+ @Nested
148
+ @DisplayName("enabled property")
149
+ class EnabledProperty {
150
+
151
+ @ParameterizedTest
152
+ @ValueSource(booleans = {true, false})
153
+ @DisplayName("should set and get enabled state")
154
+ void shouldSetAndGetEnabledState(boolean enabled) {
155
+ // When
156
+ properties.setEnabled(enabled);
157
+
158
+ // Then
159
+ assertThat(properties.isEnabled()).isEqualTo(enabled);
160
+ }
161
+ }
162
+
163
+ @Nested
164
+ @DisplayName("Sources property")
165
+ class SourcesProperty {
166
+
167
+ @Test
168
+ @DisplayName("should set and get custom sources")
169
+ void shouldSetAndGetCustomSources() {
170
+ // Given
171
+ final List<ScalarSource> sources = List.of(
172
+ new ScalarSource(
173
+ "url", "title", "slug", true),
174
+ new ScalarSource());
175
+
176
+ // When
177
+ properties.setSources(sources);
178
+
179
+ // Then
180
+ assertThat(properties.getSources()).isEqualTo(sources);
181
+ }
182
+
183
+ @Test
184
+ @DisplayName("should handle null sources")
185
+ void shouldHandleNullSources() {
186
+ // When
187
+ properties.setSources(null);
188
+
189
+ // Then
190
+ assertThat(properties.getSources()).isNull();
191
+ }
192
+ }
193
+
194
+ @Nested
195
+ @DisplayName("path property")
196
+ class PathProperty {
197
+
198
+ @Test
199
+ @DisplayName("should set and get custom path")
200
+ void shouldSetAndGetCustomPath() {
201
+ // Given
202
+ String customPath = "/api/docs";
203
+
204
+ // When
205
+ properties.setPath(customPath);
206
+
207
+ // Then
208
+ assertThat(properties.getPath()).isEqualTo(customPath);
209
+ }
210
+
211
+ @Test
212
+ @DisplayName("should handle empty path")
213
+ void shouldHandleEmptyPath() {
214
+ // When
215
+ properties.setPath("");
216
+
217
+ // Then
218
+ assertThat(properties.getPath()).isEmpty();
219
+ }
220
+
221
+ @Test
222
+ @DisplayName("should handle null path")
223
+ void shouldHandleNullPath() {
224
+ // When
225
+ properties.setPath(null);
226
+
227
+ // Then
228
+ assertThat(properties.getPath()).isNull();
229
+ }
230
+ }
231
+
232
+ @Nested
233
+ @DisplayName("showSidebar property")
234
+ class ShowSidebarProperty {
235
+
236
+ @ParameterizedTest
237
+ @ValueSource(booleans = {true, false})
238
+ @DisplayName("should set and get showSidebar state")
239
+ void shouldSetAndGetShowSidebarState(boolean showSidebar) {
240
+ // When
241
+ properties.setShowSidebar(showSidebar);
242
+
243
+ // Then
244
+ assertThat(properties.isShowSidebar()).isEqualTo(showSidebar);
245
+ }
246
+ }
247
+
248
+ @Nested
249
+ @DisplayName("hideModels property")
250
+ class HideModelsProperty {
251
+
252
+ @ParameterizedTest
253
+ @ValueSource(booleans = {true, false})
254
+ @DisplayName("should set and get hideModels state")
255
+ void shouldSetAndGetHideModelsState(boolean hideModels) {
256
+ // When
257
+ properties.setHideModels(hideModels);
258
+
259
+ // Then
260
+ assertThat(properties.isHideModels()).isEqualTo(hideModels);
261
+ }
262
+ }
263
+
264
+ @Nested
265
+ @DisplayName("hideTestRequestButton property")
266
+ class HideTestRequestButtonProperty {
267
+
268
+ @ParameterizedTest
269
+ @ValueSource(booleans = {true, false})
270
+ @DisplayName("should set and get hideTestRequestButton state")
271
+ void shouldSetAndGetHideTestRequestButtonState(boolean hideTestRequestButton) {
272
+ // When
273
+ properties.setHideTestRequestButton(hideTestRequestButton);
274
+
275
+ // Then
276
+ assertThat(properties.isHideTestRequestButton()).isEqualTo(hideTestRequestButton);
277
+ }
278
+ }
279
+
280
+ @Nested
281
+ @DisplayName("darkMode property")
282
+ class DarkModeProperty {
283
+
284
+ @ParameterizedTest
285
+ @ValueSource(booleans = {true, false})
286
+ @DisplayName("should set and get darkMode state")
287
+ void shouldSetAndGetDarkModeState(boolean darkMode) {
288
+ // When
289
+ properties.setDarkMode(darkMode);
290
+
291
+ // Then
292
+ assertThat(properties.isDarkMode()).isEqualTo(darkMode);
293
+ }
294
+ }
295
+
296
+ @Nested
297
+ @DisplayName("hideDarkModeToggle property")
298
+ class HideDarkModeToggleProperty {
299
+
300
+ @ParameterizedTest
301
+ @ValueSource(booleans = {true, false})
302
+ @DisplayName("should set and get hideDarkModeToggle state")
303
+ void shouldSetAndGetHideDarkModeToggleState(boolean hideDarkModeToggle) {
304
+ // When
305
+ properties.setHideDarkModeToggle(hideDarkModeToggle);
306
+
307
+ // Then
308
+ assertThat(properties.isHideDarkModeToggle()).isEqualTo(hideDarkModeToggle);
309
+ }
310
+ }
311
+
312
+ @Nested
313
+ @DisplayName("customCss property")
314
+ class CustomCssProperty {
315
+
316
+ @Test
317
+ @DisplayName("should set and get custom CSS")
318
+ void shouldSetAndGetCustomCss() {
319
+ // Given
320
+ String customCss = "body { background-color: #BADA55; }";
321
+
322
+ // When
323
+ properties.setCustomCss(customCss);
324
+
325
+ // Then
326
+ assertThat(properties.getCustomCss()).isEqualTo(customCss);
327
+ }
328
+
329
+ @Test
330
+ @DisplayName("should handle null custom CSS")
331
+ void shouldHandleNullCustomCss() {
332
+ // When
333
+ properties.setCustomCss(null);
334
+
335
+ // Then
336
+ assertThat(properties.getCustomCss()).isNull();
337
+ }
338
+
339
+ @Test
340
+ @DisplayName("should handle empty custom CSS")
341
+ void shouldHandleEmptyCustomCss() {
342
+ // When
343
+ properties.setCustomCss("");
344
+
345
+ // Then
346
+ assertThat(properties.getCustomCss()).isEmpty();
347
+ }
348
+ }
349
+
350
+ @Nested
351
+ @DisplayName("hideSearch property")
352
+ class HideSearchProperty {
353
+
354
+ @ParameterizedTest
355
+ @ValueSource(booleans = {true, false})
356
+ @DisplayName("should set and get hideSearch state")
357
+ void shouldSetAndGetHideSearchState(boolean hideSearch) {
358
+ // When
359
+ properties.setHideSearch(hideSearch);
360
+
361
+ // Then
362
+ assertThat(properties.isHideSearch()).isEqualTo(hideSearch);
363
+ }
364
+ }
365
+
366
+ @Nested
367
+ @DisplayName("actuatorEnabled property")
368
+ class ActuatorEnabledProperty {
369
+
370
+ @ParameterizedTest
371
+ @ValueSource(booleans = {true, false})
372
+ @DisplayName("should set and get actuatorEnabled state")
373
+ void shouldSetAndGetActuatorEnabledState(boolean actuatorEnabled) {
374
+ // When
375
+ properties.setActuatorEnabled(actuatorEnabled);
376
+
377
+ // Then
378
+ assertThat(properties.isActuatorEnabled()).isEqualTo(actuatorEnabled);
379
+ }
380
+ }
381
+
382
+ @Nested
383
+ @DisplayName("showDeveloperTools property")
384
+ class ShowDeveloperToolsProperty {
385
+
386
+ @Test
387
+ @DisplayName("should have null default value")
388
+ void shouldHaveNullDefaultValue() {
389
+ assertThat(properties.getShowDeveloperTools()).isNull();
390
+ }
391
+
392
+ @Test
393
+ @DisplayName("should set and get ALWAYS value")
394
+ void shouldSetAndGetAlwaysValue() {
395
+ // When
396
+ properties.setShowDeveloperTools(DeveloperToolsVisibility.ALWAYS);
397
+
398
+ // Then
399
+ assertThat(properties.getShowDeveloperTools()).isEqualTo(DeveloperToolsVisibility.ALWAYS);
400
+ }
401
+
402
+ @Test
403
+ @DisplayName("should set and get LOCALHOST value")
404
+ void shouldSetAndGetLocalhostValue() {
405
+ // When
406
+ properties.setShowDeveloperTools(DeveloperToolsVisibility.LOCALHOST);
407
+
408
+ // Then
409
+ assertThat(properties.getShowDeveloperTools()).isEqualTo(DeveloperToolsVisibility.LOCALHOST);
410
+ }
411
+
412
+ @Test
413
+ @DisplayName("should set and get NEVER value")
414
+ void shouldSetAndGetNeverValue() {
415
+ // When
416
+ properties.setShowDeveloperTools(DeveloperToolsVisibility.NEVER);
417
+
418
+ // Then
419
+ assertThat(properties.getShowDeveloperTools()).isEqualTo(DeveloperToolsVisibility.NEVER);
420
+ }
421
+
422
+ @Test
423
+ @DisplayName("should handle null value")
424
+ void shouldHandleNullValue() {
425
+ // Given
426
+ properties.setShowDeveloperTools(DeveloperToolsVisibility.ALWAYS);
427
+
428
+ // When
429
+ properties.setShowDeveloperTools(null);
430
+
431
+ // Then
432
+ assertThat(properties.getShowDeveloperTools()).isNull();
433
+ }
434
+ }
435
+
436
+ @Nested
437
+ @DisplayName("property combinations")
438
+ class PropertyCombinations {
439
+
440
+ @Test
441
+ @DisplayName("should handle all properties being set together")
442
+ void shouldHandleAllPropertiesBeingSetTogether() {
443
+ // Given
444
+ String customUrl = "https://custom.example.com/api.json";
445
+ String customPath = "/custom/path";
446
+ boolean customEnabled = false;
447
+ boolean customShowSidebar = false;
448
+ boolean customHideModels = true;
449
+ boolean customHideTestRequestButton = true;
450
+ boolean customDarkMode = true;
451
+ boolean customHideDarkModeToggle = true;
452
+ String customCss = "body { background-color: #BADA55; }";
453
+ String customTheme = "mars";
454
+ String customLayout = "classic";
455
+ boolean customHideSearch = true;
456
+ String customDocumentDownloadType = "json";
457
+ boolean customActuatorEnabled = true;
458
+
459
+ // When
460
+ properties.setUrl(customUrl);
461
+ properties.setEnabled(customEnabled);
462
+ properties.setPath(customPath);
463
+ properties.setShowSidebar(customShowSidebar);
464
+ properties.setHideModels(customHideModels);
465
+ properties.setHideTestRequestButton(customHideTestRequestButton);
466
+ properties.setDarkMode(customDarkMode);
467
+ properties.setHideDarkModeToggle(customHideDarkModeToggle);
468
+ properties.setCustomCss(customCss);
469
+ properties.setTheme(ScalarTheme.fromValue(customTheme));
470
+ properties.setLayout(ScalarLayout.fromValue(customLayout));
471
+ properties.setHideSearch(customHideSearch);
472
+ properties.setDocumentDownloadType(DocumentDownloadType.fromValue(customDocumentDownloadType));
473
+ properties.setActuatorEnabled(customActuatorEnabled);
474
+
475
+ // Then
476
+ assertThat(properties.getUrl()).isEqualTo(customUrl);
477
+ assertThat(properties.isEnabled()).isEqualTo(customEnabled);
478
+ assertThat(properties.getPath()).isEqualTo(customPath);
479
+ assertThat(properties.isShowSidebar()).isEqualTo(customShowSidebar);
480
+ assertThat(properties.isHideModels()).isEqualTo(customHideModels);
481
+ assertThat(properties.isHideTestRequestButton()).isEqualTo(customHideTestRequestButton);
482
+ assertThat(properties.isDarkMode()).isEqualTo(customDarkMode);
483
+ assertThat(properties.isHideDarkModeToggle()).isEqualTo(customHideDarkModeToggle);
484
+ assertThat(properties.getCustomCss()).isEqualTo(customCss);
485
+ assertThat(properties.getTheme()).isEqualTo(ScalarTheme.fromValue(customTheme));
486
+ assertThat(properties.getLayout()).isEqualTo(ScalarLayout.fromValue(customLayout));
487
+ assertThat(properties.isHideSearch()).isEqualTo(customHideSearch);
488
+ assertThat(properties.getDocumentDownloadType())
489
+ .isEqualTo(DocumentDownloadType.fromValue(customDocumentDownloadType));
490
+ assertThat(properties.isActuatorEnabled()).isEqualTo(customActuatorEnabled);
491
+ }
492
+
493
+ @Test
494
+ @DisplayName("should maintain property independence")
495
+ void shouldMaintainPropertyIndependence() {
496
+ final ScalarSource source = new ScalarSource();
497
+ source.setUrl("https://example.com/openapi.json");
498
+ final List<ScalarSource> sources = List.of(source);
499
+
500
+ // Given - set initial values
501
+ properties.setUrl("https://initial.com");
502
+ properties.setSources(sources);
503
+ properties.setEnabled(false);
504
+ properties.setPath("/initial");
505
+ properties.setShowSidebar(false);
506
+ properties.setHideModels(true);
507
+ properties.setDarkMode(true);
508
+ properties.setTheme(ScalarTheme.MARS);
509
+
510
+ // When - change only one property
511
+ properties.setUrl("https://changed.com");
512
+
513
+ // Then - only URL should change, others should remain
514
+ assertThat(properties.getUrl()).isEqualTo("https://changed.com");
515
+ assertThat(properties.getSources()).isEqualTo(sources);
516
+ assertThat(properties.isEnabled()).isFalse();
517
+ assertThat(properties.getPath()).isEqualTo("/initial");
518
+ assertThat(properties.isShowSidebar()).isFalse();
519
+ assertThat(properties.isHideModels()).isTrue();
520
+ assertThat(properties.isDarkMode()).isTrue();
521
+ assertThat(properties.getTheme()).isEqualTo(ScalarTheme.MARS);
522
+ }
523
+ }
524
+ }
525
+
@@ -0,0 +1,61 @@
1
+ package com.scalar.maven.core.config;
2
+
3
+ import com.scalar.maven.core.enums.ScalarClient;
4
+ import com.scalar.maven.core.enums.ScalarTarget;
5
+ import org.junit.jupiter.api.DisplayName;
6
+ import org.junit.jupiter.api.Nested;
7
+ import org.junit.jupiter.api.Test;
8
+
9
+ import static org.assertj.core.api.Assertions.assertThat;
10
+
11
+ @DisplayName("DefaultHttpClient")
12
+ class DefaultHttpClientTest {
13
+
14
+ @Nested
15
+ @DisplayName("construction")
16
+ class Construction {
17
+
18
+ @Test
19
+ @DisplayName("should create client with default constructor")
20
+ void shouldCreateClientWithDefaultConstructor() {
21
+ DefaultHttpClient client = new DefaultHttpClient();
22
+ assertThat(client).isNotNull();
23
+ assertThat(client.getTargetKey()).isNull();
24
+ assertThat(client.getClientKey()).isNull();
25
+ }
26
+
27
+ @Test
28
+ @DisplayName("should create client with target and client keys")
29
+ void shouldCreateClientWithTargetAndClientKeys() {
30
+ ScalarTarget targetKey = ScalarTarget.SHELL;
31
+ ScalarClient clientKey = ScalarClient.CURL;
32
+ DefaultHttpClient client = new DefaultHttpClient(targetKey, clientKey);
33
+ assertThat(client.getTargetKey()).isEqualTo(targetKey);
34
+ assertThat(client.getClientKey()).isEqualTo(clientKey);
35
+ }
36
+ }
37
+
38
+ @Nested
39
+ @DisplayName("properties")
40
+ class Properties {
41
+
42
+ @Test
43
+ @DisplayName("should set and get target key")
44
+ void shouldSetAndGetTargetKey() {
45
+ DefaultHttpClient client = new DefaultHttpClient();
46
+ ScalarTarget targetKey = ScalarTarget.SHELL;
47
+ client.setTargetKey(targetKey);
48
+ assertThat(client.getTargetKey()).isEqualTo(targetKey);
49
+ }
50
+
51
+ @Test
52
+ @DisplayName("should set and get client key")
53
+ void shouldSetAndGetClientKey() {
54
+ DefaultHttpClient client = new DefaultHttpClient();
55
+ ScalarClient clientKey = ScalarClient.CURL;
56
+ client.setClientKey(clientKey);
57
+ assertThat(client.getClientKey()).isEqualTo(clientKey);
58
+ }
59
+ }
60
+ }
61
+
@@ -0,0 +1,80 @@
1
+ package com.scalar.maven.core.config;
2
+
3
+ import com.fasterxml.jackson.core.JsonProcessingException;
4
+ import com.fasterxml.jackson.databind.ObjectMapper;
5
+ import org.junit.jupiter.api.DisplayName;
6
+ import org.junit.jupiter.api.Nested;
7
+ import org.junit.jupiter.api.Test;
8
+
9
+ import static org.assertj.core.api.Assertions.assertThat;
10
+
11
+ @DisplayName("ScalarAgentOptions")
12
+ class ScalarAgentOptionsTest {
13
+
14
+ @Nested
15
+ @DisplayName("construction")
16
+ class Construction {
17
+
18
+ @Test
19
+ @DisplayName("creates options with default constructor")
20
+ void createsWithDefaultConstructor() {
21
+ ScalarAgentOptions options = new ScalarAgentOptions();
22
+ assertThat(options).isNotNull();
23
+ assertThat(options.getKey()).isNull();
24
+ assertThat(options.getDisabled()).isNull();
25
+ }
26
+ }
27
+
28
+ @Nested
29
+ @DisplayName("properties")
30
+ class Properties {
31
+
32
+ @Test
33
+ @DisplayName("sets and gets key")
34
+ void setsAndGetsKey() {
35
+ ScalarAgentOptions options = new ScalarAgentOptions();
36
+ options.setKey("agent-key-123");
37
+ assertThat(options.getKey()).isEqualTo("agent-key-123");
38
+ }
39
+
40
+ @Test
41
+ @DisplayName("sets and gets disabled")
42
+ void setsAndGetsDisabled() {
43
+ ScalarAgentOptions options = new ScalarAgentOptions();
44
+ options.setDisabled(true);
45
+ assertThat(options.getDisabled()).isTrue();
46
+ options.setDisabled(false);
47
+ assertThat(options.getDisabled()).isFalse();
48
+ options.setDisabled(null);
49
+ assertThat(options.getDisabled()).isNull();
50
+ }
51
+ }
52
+
53
+ @Nested
54
+ @DisplayName("JSON serialization")
55
+ class JsonSerialization {
56
+
57
+ @Test
58
+ @DisplayName("serializes key and disabled to JSON")
59
+ void serializesToJson() throws JsonProcessingException {
60
+ ScalarAgentOptions options = new ScalarAgentOptions();
61
+ options.setKey("my-key");
62
+ options.setDisabled(true);
63
+
64
+ String json = new ObjectMapper().writeValueAsString(options);
65
+
66
+ assertThat(json).contains("\"key\":\"my-key\"");
67
+ assertThat(json).contains("\"disabled\":true");
68
+ }
69
+
70
+ @Test
71
+ @DisplayName("omits null fields from JSON")
72
+ void omitsNullFieldsFromJson() throws JsonProcessingException {
73
+ ScalarAgentOptions options = new ScalarAgentOptions();
74
+
75
+ String json = new ObjectMapper().writeValueAsString(options);
76
+
77
+ assertThat(json).isEqualTo("{}");
78
+ }
79
+ }
80
+ }