public interface OrderByIdGet extends MetaModelGetDsl<Order,Order,OrderByIdGet,OrderExpansionModel<Order>>
withStateByBuilder(client(), builder -> builder.type(StateType.ORDER_STATE), state -> { withFilledCart(client(), cart -> { final Order order = client().executeBlocking(OrderFromCartCreateCommand.of(cart)); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, TransitionState.of(state)) .plusExpansionPaths(OrderExpansionModel::state) .plusExpansionPaths(OrderExpansionModel::cart) ); assertThat(updatedOrder.getLineItems()).isEqualTo(cart.getLineItems()); assertThat(updatedOrder.getCustomLineItems()).isEqualTo(cart.getCustomLineItems()); assertThat(updatedOrder.getCart().getId()).isEqualTo(cart.getId()); assertThat(updatedOrder.getCart()).is(expanded()); final Cart orderedCart = updatedOrder.getCart().getObj(); assertThat(orderedCart).isNotNull(); assertThat(orderedCart.getId()).isEqualTo(cart.getId()); assertThat(orderedCart.getCartState()).isEqualTo(CartState.ORDERED); assertThat(updatedOrder.getState()).is(expanded()); //to be able to delete the state transition we have to delete the associated order. client().executeBlocking(OrderDeleteCommand.of(updatedOrder)); }); });
See the test code.
Modifier and Type | Method and Description |
---|---|
List<ExpansionPath<Order>> |
expansionPaths() |
static OrderByIdGet |
of(Identifiable<Order> resource) |
static OrderByIdGet |
of(String id) |
OrderByIdGet |
plusExpansionPaths(ExpansionPath<Order> expansionPath)
Creates a new object with the properties of the old object but adds
expansionPath to the expansion paths. |
OrderByIdGet |
withExpansionPaths(ExpansionPath<Order> expansionPath)
Creates a new object with the properties of the old object but replaces all expansion paths with a single
expansionPath . |
OrderByIdGet |
withExpansionPaths(List<ExpansionPath<Order>> 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 OrderByIdGet of(String id)
static OrderByIdGet of(Identifiable<Order> resource)
List<ExpansionPath<Order>> expansionPaths()
expansionPaths
in interface ExpansionPathContainer<Order>
expansionPaths
in interface ReferenceExpansionSupport<Order>
OrderByIdGet plusExpansionPaths(ExpansionPath<Order> 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<Order,OrderByIdGet>
expansionPath
- the new expansion path to add to the existing onesOrderByIdGet withExpansionPaths(ExpansionPath<Order> 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<Order,OrderByIdGet>
expansionPath
- the new expansion pathsOrderByIdGet withExpansionPaths(List<ExpansionPath<Order>> expansionPaths)
ReferenceExpansionDsl
expansionPaths
.withExpansionPaths
in interface ReferenceExpansionDsl<Order,OrderByIdGet>
expansionPaths
- the new expansion paths