use of com.commercetools.sync.services.InventoryService in project commercetools-sync-java by commercetools.
the class InventorySyncTest method sync_WithNullInInputList_ShouldIncrementFailedStatistics.
@Test
void sync_WithNullInInputList_ShouldIncrementFailedStatistics() {
final InventoryService inventoryService = getMockInventoryService(existingInventories, mock(InventoryEntry.class), mock(InventoryEntry.class));
final ChannelService channelService = getMockChannelService(getMockSupplyChannel(REF_3, KEY_3));
final InventorySyncOptions options = getInventorySyncOptions(3, false);
final InventorySync inventorySync = new InventorySync(options, inventoryService, channelService, mock(TypeService.class));
final InventorySyncStatistics stats = inventorySync.sync(singletonList(null)).toCompletableFuture().join();
assertThat(stats).hasValues(1, 0, 0, 1);
assertThat(errorCallBackMessages).isNotEmpty();
assertThat(errorCallBackMessages.get(0)).isEqualTo("InventoryEntryDraft is null.");
assertThat(errorCallBackExceptions).isNotEmpty();
assertThat(errorCallBackExceptions.get(0)).isEqualTo(null);
}
use of com.commercetools.sync.services.InventoryService in project commercetools-sync-java by commercetools.
the class InventorySyncTest method sync_WithOnlyDraftsToCreate_ShouldCallBeforeCreateCallback.
@Test
void sync_WithOnlyDraftsToCreate_ShouldCallBeforeCreateCallback() {
// preparation
final InventoryEntryDraft inventoryEntryDraft = InventoryEntryDraftBuilder.of("newSKU", 1L).build();
final InventorySyncOptions optionsSpy = spy(getInventorySyncOptions(1, false));
final InventoryService inventoryService = getMockInventoryService(existingInventories, mock(InventoryEntry.class), mock(InventoryEntry.class));
final ChannelService channelService = getMockChannelService(getMockSupplyChannel(REF_3, KEY_3));
final InventorySync inventorySync = new InventorySync(optionsSpy, inventoryService, channelService, mock(TypeService.class));
// test
inventorySync.sync(singletonList(inventoryEntryDraft)).toCompletableFuture().join();
// assertion
verify(optionsSpy).applyBeforeCreateCallback(any());
verify(optionsSpy, never()).applyBeforeUpdateCallback(any(), any(), any());
}
Aggregations