|
21 | 21 | import java.util.ArrayList; |
22 | 22 | import java.util.HashMap; |
23 | 23 | import java.util.Map; |
| 24 | +import java.util.UUID; |
24 | 25 |
|
25 | 26 | class RequestInformationTest { |
26 | 27 | @Test |
@@ -131,6 +132,29 @@ void SetsPathParametersOfPeriodAndDurationType() { |
131 | 132 | assertTrue(uriResult.toString().contains("seatingDuration='PT30M'")); |
132 | 133 | } |
133 | 134 |
|
| 135 | + |
| 136 | + @Test |
| 137 | + void SetsQueryParametersOfPeriodAndDurationTypedArray() throws IllegalStateException, URISyntaxException { |
| 138 | + // Arrange as the request builders would |
| 139 | + final RequestInformation requestInfo = new RequestInformation(); |
| 140 | + requestInfo.httpMethod = HttpMethod.GET; |
| 141 | + requestInfo.urlTemplate = "http://localhost/{?periods}"; |
| 142 | + |
| 143 | + final GetQueryParameters queryParameters = new GetQueryParameters(); |
| 144 | + queryParameters.messageAges = new PeriodAndDuration[] { |
| 145 | + PeriodAndDuration.parse("PT30M"), |
| 146 | + PeriodAndDuration.parse("PT20M"), |
| 147 | + PeriodAndDuration.parse("PT1H20M") |
| 148 | + }; |
| 149 | + |
| 150 | + // Act |
| 151 | + requestInfo.addQueryParameters(queryParameters); |
| 152 | + |
| 153 | + // Assert |
| 154 | + final URI uri = requestInfo.getUri(); |
| 155 | + assertEquals("http://localhost/?periods=PT30M,PT20M,PT1H20M", uri.toString()); |
| 156 | + } |
| 157 | + |
134 | 158 | @Test |
135 | 159 | void ExpandQueryParametersAfterPathParams() { |
136 | 160 | // Arrange as the request builders would |
@@ -207,6 +231,26 @@ void SetsPathParametersOfBooleanType() { |
207 | 231 | assertTrue(uriResult.toString().contains("count=true")); |
208 | 232 | } |
209 | 233 |
|
| 234 | + @Test |
| 235 | + void SetsQueryParametersOfBooleanTypedArray() throws IllegalStateException, URISyntaxException { |
| 236 | + // Arrange as the request builders would |
| 237 | + final RequestInformation requestInfo = new RequestInformation(); |
| 238 | + requestInfo.httpMethod = HttpMethod.GET; |
| 239 | + requestInfo.urlTemplate = "http://localhost/{?expandChildren}"; |
| 240 | + |
| 241 | + final GetQueryParameters queryParameters = new GetQueryParameters(); |
| 242 | + queryParameters.expandChildren = new Boolean[] { |
| 243 | + true, false, true, true |
| 244 | + }; |
| 245 | + |
| 246 | + // Act |
| 247 | + requestInfo.addQueryParameters(queryParameters); |
| 248 | + |
| 249 | + // Assert |
| 250 | + final URI uri = requestInfo.getUri(); |
| 251 | + assertEquals("http://localhost/?expandChildren=true,false,true,true", uri.toString()); |
| 252 | + } |
| 253 | + |
210 | 254 | @Test |
211 | 255 | void SetsPathParametersOfUUIDType() { |
212 | 256 | // Arrange as the request builders would |
@@ -239,6 +283,28 @@ void SetsQueryParametersOfUUIDType() { |
239 | 283 | assertTrue(uriResult.toString().contains("?id=f0f351e7-8e5f-4d0e-8f2a-7b5e4b6f4f3e")); |
240 | 284 | } |
241 | 285 |
|
| 286 | + @Test |
| 287 | + void SetsQueryParametersOfUUIDTypedArray() throws IllegalStateException, URISyntaxException { |
| 288 | + // Arrange as the request builders would |
| 289 | + final RequestInformation requestInfo = new RequestInformation(); |
| 290 | + requestInfo.httpMethod = HttpMethod.GET; |
| 291 | + requestInfo.urlTemplate = "http://localhost/{?datasetIds}"; |
| 292 | + |
| 293 | + final GetQueryParameters queryParameters = new GetQueryParameters(); |
| 294 | + queryParameters.datasetIds = new UUID[] { |
| 295 | + UUID.fromString("f0f351e7-8e5f-4d0e-8f2a-7b5e4b6f4f3e"), |
| 296 | + UUID.fromString("a2f351e7-8e5f-4d0e-8f2a-7b5e4b6f4f3e") |
| 297 | + }; |
| 298 | + |
| 299 | + // Act |
| 300 | + requestInfo.addQueryParameters(queryParameters); |
| 301 | + |
| 302 | + // Assert |
| 303 | + final URI uri = requestInfo.getUri(); |
| 304 | + assertEquals("http://localhost/?datasetIds=f0f351e7-8e5f-4d0e-8f2a-7b5e4b6f4f3e,a2f351e7-8e5f-4d0e-8f2a-7b5e4b6f4f3e", uri.toString()); |
| 305 | + } |
| 306 | + |
| 307 | + |
242 | 308 | @Test |
243 | 309 | void SetsParsableContent() { |
244 | 310 | // Arrange as the request builders would |
@@ -415,12 +481,25 @@ class GetQueryParameters implements QueryParameters { |
415 | 481 |
|
416 | 482 | @jakarta.annotation.Nullable public TestEnum[] datasets; |
417 | 483 |
|
| 484 | + @jakarta.annotation.Nullable public UUID[] datasetIds; |
| 485 | + |
| 486 | + /** Per-dataset boolean indicating whether to resolve its child datasets */ |
| 487 | + @jakarta.annotation.Nullable public Boolean[] expandChildren; |
| 488 | + |
| 489 | + /** |
| 490 | + * Minimum message ages as duration, per dataset |
| 491 | + */ |
| 492 | + @jakarta.annotation.Nullable public PeriodAndDuration[] messageAges; |
| 493 | + |
418 | 494 | @jakarta.annotation.Nonnull public Map<String, Object> toQueryParameters() { |
419 | | - final Map<String, Object> allQueryParams = new HashMap(); |
| 495 | + final Map<String, Object> allQueryParams = new HashMap<>(); |
420 | 496 | allQueryParams.put("%24select", select); |
421 | 497 | allQueryParams.put("%24search", search); |
422 | 498 | allQueryParams.put("dataset", dataset); |
423 | 499 | allQueryParams.put("datasets", datasets); |
| 500 | + allQueryParams.put("datasetIds", datasetIds); |
| 501 | + allQueryParams.put("expandChildren", expandChildren); |
| 502 | + allQueryParams.put("periods", messageAges); |
424 | 503 | return allQueryParams; |
425 | 504 | } |
426 | 505 | } |
0 commit comments