fix(order): project exact customer fulfillment progress in detail
This commit is contained in:
+28
-2
@@ -11,10 +11,36 @@ class InternalCustomerOrderProgressControllerTest {
|
||||
@Test void validatesInternalIdentityBeforeReadingCustomerFacts() {
|
||||
var service=mock(CustomerOrderProgressService.class);
|
||||
var controller=new InternalCustomerOrderProgressController(new InternalServiceTokenGuard("test-token"),service);
|
||||
var request=new CustomerOrderProgress.Request(11L);
|
||||
var request=new CustomerOrderProgress.Request(11L, null);
|
||||
assertThatThrownBy(()->controller.read(null,request)).isInstanceOf(org.springframework.web.server.ResponseStatusException.class);
|
||||
assertThatThrownBy(()->controller.read("wrong",request)).isInstanceOf(org.springframework.web.server.ResponseStatusException.class);
|
||||
verifyNoInteractions(service);
|
||||
controller.read("test-token",request);verify(service).read(11);
|
||||
controller.read("test-token",request);verify(service).read(11, null);
|
||||
}
|
||||
|
||||
@Test void optionalExactScopeRejectsEmptyOversizeNullOrNonPositiveItems() {
|
||||
try(var factory=jakarta.validation.Validation.buildDefaultValidatorFactory()) {
|
||||
var validator=factory.getValidator();
|
||||
for(java.util.List<Long> ids: java.util.List.of(java.util.List.<Long>of(),java.util.List.of(0L),
|
||||
java.util.Arrays.asList(1L,null),java.util.stream.LongStream.rangeClosed(1,201).boxed().toList())) {
|
||||
assertThat(validator.validate(new CustomerOrderProgress.Request(11L,ids))).isNotEmpty();
|
||||
}
|
||||
for(java.util.List<Long> ids: java.util.Arrays.asList(null,java.util.List.of(1L),java.util.stream.LongStream.rangeClosed(1,200).boxed().toList())) {
|
||||
assertThat(validator.validate(new CustomerOrderProgress.Request(11L,ids))).isEmpty();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test @SuppressWarnings("unchecked") void documentsBoundedOptionalExactOrderScope() throws Exception {
|
||||
var document=(java.util.Map<String,Object>)new org.yaml.snakeyaml.Yaml().load(
|
||||
new org.springframework.core.io.ClassPathResource("openapi/lastleg-customer-order-progress-v1.yaml").getContentAsString(java.nio.charset.StandardCharsets.UTF_8));
|
||||
var paths=(java.util.Map<String,Object>)document.get("paths");
|
||||
var operation=(java.util.Map<String,Object>)((java.util.Map<String,Object>)paths.get("/internal/lastleg/v1/customer-order-progress")).get("post");
|
||||
var content=(java.util.Map<String,Object>)((java.util.Map<String,Object>)operation.get("requestBody")).get("content");
|
||||
var schema=(java.util.Map<String,Object>)((java.util.Map<String,Object>)content.get("application/json")).get("schema");
|
||||
var ids=(java.util.Map<String,Object>)((java.util.Map<String,Object>)schema.get("properties")).get("orderIds");
|
||||
assertThat(ids).containsEntry("minItems",1).containsEntry("maxItems",200).containsEntry("nullable",true);
|
||||
assertThat((java.util.List<String>)schema.get("required")).doesNotContain("orderIds");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user