Search in sources :

Example 11 with InventoryService

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);
}
Also used : ChannelService(com.commercetools.sync.services.ChannelService) InventorySyncMockUtils.getMockChannelService(com.commercetools.sync.inventories.InventorySyncMockUtils.getMockChannelService) InventorySyncMockUtils.getMockInventoryService(com.commercetools.sync.inventories.InventorySyncMockUtils.getMockInventoryService) InventoryService(com.commercetools.sync.services.InventoryService) InventorySyncStatistics(com.commercetools.sync.inventories.helpers.InventorySyncStatistics) InventoryEntry(io.sphere.sdk.inventory.InventoryEntry) InventorySyncMockUtils.getMockInventoryEntry(com.commercetools.sync.inventories.InventorySyncMockUtils.getMockInventoryEntry) TypeService(com.commercetools.sync.services.TypeService) Test(org.junit.jupiter.api.Test)

Example 12 with InventoryService

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());
}
Also used : InventoryEntryDraft(io.sphere.sdk.inventory.InventoryEntryDraft) ChannelService(com.commercetools.sync.services.ChannelService) InventorySyncMockUtils.getMockChannelService(com.commercetools.sync.inventories.InventorySyncMockUtils.getMockChannelService) InventorySyncMockUtils.getMockInventoryService(com.commercetools.sync.inventories.InventorySyncMockUtils.getMockInventoryService) InventoryService(com.commercetools.sync.services.InventoryService) InventoryEntry(io.sphere.sdk.inventory.InventoryEntry) InventorySyncMockUtils.getMockInventoryEntry(com.commercetools.sync.inventories.InventorySyncMockUtils.getMockInventoryEntry) TypeService(com.commercetools.sync.services.TypeService) Test(org.junit.jupiter.api.Test)

Aggregations

InventoryService (com.commercetools.sync.services.InventoryService)12 InventorySyncMockUtils.getMockInventoryEntry (com.commercetools.sync.inventories.InventorySyncMockUtils.getMockInventoryEntry)11 InventorySyncMockUtils.getMockInventoryService (com.commercetools.sync.inventories.InventorySyncMockUtils.getMockInventoryService)11 TypeService (com.commercetools.sync.services.TypeService)11 InventoryEntry (io.sphere.sdk.inventory.InventoryEntry)11 Test (org.junit.jupiter.api.Test)10 InventorySyncMockUtils.getMockChannelService (com.commercetools.sync.inventories.InventorySyncMockUtils.getMockChannelService)9 ChannelService (com.commercetools.sync.services.ChannelService)9 InventorySyncStatistics (com.commercetools.sync.inventories.helpers.InventorySyncStatistics)8 InventoryEntryDraft (io.sphere.sdk.inventory.InventoryEntryDraft)8 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1