public final class AddQuantity extends UpdateActionImpl<InventoryEntry>
See also InventoryEntryUpdateCommand.
withUpdateableInventoryEntry(client(), entry -> { final long additionalQuantity = 4; final UpdateAction<InventoryEntry> action = AddQuantity.of(additionalQuantity); final InventoryEntry updatedEntry = client().executeBlocking(InventoryEntryUpdateCommand.of(entry, action)); assertThat(updatedEntry.getQuantityOnStock()).isEqualTo(entry.getQuantityOnStock() + additionalQuantity); 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.
InventoryEntry.getQuantityOnStock()
Modifier and Type | Method and Description |
---|---|
Long |
getQuantity() |
static AddQuantity |
of(long quantity) |
getAction
public Long getQuantity()
public static AddQuantity of(long quantity)