public interface InventoryEntryCreateCommand extends DraftBasedCreateCommandDsl<InventoryEntry,InventoryEntryDraft,InventoryEntryCreateCommand>, MetaModelReferenceExpansionDsl<InventoryEntry,InventoryEntryCreateCommand,InventoryEntryExpansionModel<InventoryEntry>>
InventoryEntry
.
withChannelOfRole(client(), INVENTORY_SUPPLY, channel -> { final String sku = randomKey(); final long quantityOnStock = 10; final ZonedDateTime expectedDelivery = tomorrowZonedDateTime(); final int restockableInDays = 3; final InventoryEntryDraft inventoryEntryDraft = InventoryEntryDraft.of(sku, quantityOnStock) .withExpectedDelivery(expectedDelivery) .withRestockableInDays(restockableInDays) .withSupplyChannel(channel); final InventoryEntry inventoryEntry = client().executeBlocking(InventoryEntryCreateCommand.of(inventoryEntryDraft)); assertThat(inventoryEntry.getSku()).isEqualTo(sku); assertThat(inventoryEntry.getQuantityOnStock()).isEqualTo(quantityOnStock); assertThat(inventoryEntry.getAvailableQuantity()).isEqualTo(quantityOnStock); assertThat(inventoryEntry.getExpectedDelivery()).isEqualTo(expectedDelivery); assertThat(inventoryEntry.getRestockableInDays()).isEqualTo(restockableInDays); assertThat(inventoryEntry.getSupplyChannel()).isEqualTo(channel.toReference()); assertEventually(() -> { final PagedQueryResult<InventoryEntryCreatedMessage> pagedQueryResult = client().executeBlocking( MessageQuery.of().withPredicates(m -> m.resource().is(inventoryEntry)) .forMessageType(InventoryEntryCreatedMessage.MESSAGE_HINT) ); final Optional<InventoryEntryCreatedMessage> inventoryCreatedMessage = pagedQueryResult.head(); assertThat(inventoryCreatedMessage).isPresent(); assertThat(inventoryCreatedMessage.get().getResource().getId()).isEqualTo(inventoryEntry.getId()); }); //delete final DeleteCommand<InventoryEntry> deleteCommand = InventoryEntryDeleteCommand.of(inventoryEntry); final InventoryEntry deletedEntry = client().executeBlocking(deleteCommand); });
See the test code.
InventoryEntryDraft
,
InventoryEntry
Modifier and Type | Method and Description |
---|---|
static InventoryEntryCreateCommand |
of(InventoryEntryDraft draft)
Creates a command object to create a
InventoryEntry . |
getDraft, withDraft
canDeserialize, deserialize, httpRequestIntent
plusExpansionPaths, withExpansionPaths
plusExpansionPaths, plusExpansionPaths, plusExpansionPaths, plusExpansionPaths, withExpansionPaths, withExpansionPaths, withExpansionPaths, withExpansionPaths
expansionPaths
static InventoryEntryCreateCommand of(InventoryEntryDraft draft)
InventoryEntry
.draft
- template to create the new object