public interface MessageByIdGet extends MetaModelGetDsl<Message,Message,MessageByIdGet,MessageExpansionModel<Message>>
withOrderAndReturnInfo(client(), ((order, returnInfo) -> { //query one message since message creation is not directly possible final MessageQuery query = MessageQuery.of() .withPredicates(m -> m.type().is("ReturnInfoAdded")) .withSort(m -> m.createdAt().sort().desc()) .withLimit(1L); assertEventually(Duration.ofSeconds(45), Duration.ofMillis(100), () -> { final Optional<Message> messageOptional = client().executeBlocking(query).head(); assertThat(messageOptional).isPresent(); final Message messageFromQueryEndpoint = messageOptional.get(); final Message message = client().executeBlocking(MessageByIdGet.of(messageFromQueryEndpoint)); assertThat(message).isEqualTo(messageFromQueryEndpoint); }); return order; }));
See the test code.
DeliveryAddedMessage
,
use MessageQuery
with a predicate by id.Modifier and Type | Method and Description |
---|---|
List<ExpansionPath<Message>> |
expansionPaths() |
static MessageByIdGet |
of(Identifiable<Message> resource) |
static MessageByIdGet |
of(String id) |
MessageByIdGet |
plusExpansionPaths(ExpansionPath<Message> expansionPath)
Creates a new object with the properties of the old object but adds
expansionPath to the expansion paths. |
MessageByIdGet |
withExpansionPaths(ExpansionPath<Message> expansionPath)
Creates a new object with the properties of the old object but replaces all expansion paths with a single
expansionPath . |
MessageByIdGet |
withExpansionPaths(List<ExpansionPath<Message>> expansionPaths)
Creates a new object with the properties of the old object but replaces all expansion paths with
expansionPaths . |
deserialize
canDeserialize, httpRequestIntent
plusExpansionPaths, withExpansionPaths
plusExpansionPaths, plusExpansionPaths, plusExpansionPaths, withExpansionPaths, withExpansionPaths
static MessageByIdGet of(String id)
static MessageByIdGet of(Identifiable<Message> resource)
List<ExpansionPath<Message>> expansionPaths()
expansionPaths
in interface ExpansionPathContainer<Message>
expansionPaths
in interface ReferenceExpansionSupport<Message>
MessageByIdGet plusExpansionPaths(ExpansionPath<Message> expansionPath)
ReferenceExpansionDsl
expansionPath
to the expansion paths.
An example in the product projection context:
final ProductProjectionByIdGet fetch = ProductProjectionByIdGet.of("id", ProductProjectionType.CURRENT); assertThat(fetch.expansionPaths()).isEmpty(); final ProductProjectionByIdGet fetch2 = fetch.plusExpansionPaths(ProductProjectionExpansionModel.of().categories()); assertThat(fetch.expansionPaths()).overridingErrorMessage("old object is unchanged").isEmpty(); assertThat(fetch2.expansionPaths()).isEqualTo(asList(ExpansionPath.of("categories[*]"))); assertThat(fetch2).isNotSameAs(fetch);
See the test code.
plusExpansionPaths
in interface ReferenceExpansionDsl<Message,MessageByIdGet>
expansionPath
- the new expansion path to add to the existing onesMessageByIdGet withExpansionPaths(ExpansionPath<Message> expansionPath)
ReferenceExpansionDsl
expansionPath
.
An example in the product projection context:
final ProductProjectionByIdGet fetch = ProductProjectionByIdGet.of("id", ProductProjectionType.CURRENT) .withExpansionPaths(ProductProjectionExpansionModel.of().categories()); assertThat(fetch.expansionPaths()) .isEqualTo(asList(ExpansionPath.of("categories[*]"))); final ProductProjectionByIdGet fetch2 = fetch.withExpansionPaths(ProductProjectionExpansionModel.of().productType()); assertThat(fetch.expansionPaths()).overridingErrorMessage("old object is unchanged") .isEqualTo(asList(ExpansionPath.of("categories[*]"))); assertThat(fetch2.expansionPaths()).isEqualTo(asList(ExpansionPath.of("productType"))); assertThat(fetch2).isNotSameAs(fetch);
See the test code.
This method also can be used to use the same expansions as in another request:
final ProductProjectionQuery query = ProductProjectionQuery.ofCurrent().withExpansionPaths(m -> m.categories()); final ProductProjectionSearch search = ProductProjectionSearch.ofCurrent().withExpansionPaths(query); assertThat(query.expansionPaths()) .hasSize(1) .as("reuse expansion spec from other request") .isEqualTo(search.expansionPaths());
See the test code.
withExpansionPaths
in interface ReferenceExpansionDsl<Message,MessageByIdGet>
expansionPath
- the new expansion pathsMessageByIdGet withExpansionPaths(List<ExpansionPath<Message>> expansionPaths)
ReferenceExpansionDsl
expansionPaths
.withExpansionPaths
in interface ReferenceExpansionDsl<Message,MessageByIdGet>
expansionPaths
- the new expansion paths