public final class RemoveQuantity extends UpdateActionImpl<InventoryEntry>
See also InventoryEntryUpdateCommand.
withUpdateableInventoryEntry(client(), entry -> { final long removingQuantity = 4; final UpdateAction<InventoryEntry> action = RemoveQuantity.of(removingQuantity); final InventoryEntry updatedEntry = client().executeBlocking(InventoryEntryUpdateCommand.of(entry, action)); assertThat(updatedEntry.getQuantityOnStock()).isEqualTo(entry.getQuantityOnStock() - removingQuantity); assertEventually(() -> { final PagedQueryResult<InventoryEntryCreatedMessage> pagedQueryResult = client().executeBlocking( MessageQuery.of().withPredicates(m -> m.resource().is(updatedEntry)) .forMessageType(InventoryEntryCreatedMessage.MESSAGE_HINT) ); final Optional<InventoryEntryCreatedMessage> inventoryCreatedMessage = pagedQueryResult.head(); assertThat(inventoryCreatedMessage).isPresent(); assertThat(inventoryCreatedMessage.get().getResource().getId()).isEqualTo(updatedEntry.getId()); }); return updatedEntry; });
See the test code.
Modifier and Type | Method and Description |
---|---|
Long |
getQuantity() |
static RemoveQuantity |
of(long quantity) |
getAction
public Long getQuantity()
public static RemoveQuantity of(long quantity)