use of com.commercetools.sync.services.ChannelService 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());
}
use of com.commercetools.sync.services.ChannelService in project commercetools-sync-java by commercetools.
the class InventorySyncMockUtils method getMockChannelService.
/**
* Returns mock instance of {@link InventoryService} with the specified parameters as mock results
* of calling the {@link ChannelService#createAndCacheChannel(String)} and {@link
* ChannelService#fetchCachedChannelId(String)} (String)} of the mock channel service.
*
* @param createdSupplyChannel result of future resulting from calling {@link
* ChannelService#createAndCacheChannel(String)}
* @return mock instance of {@link InventoryService}.
*/
public static ChannelService getMockChannelService(@Nonnull final Channel createdSupplyChannel) {
final String createdSupplyChannelId = createdSupplyChannel.getId();
final ChannelService channelService = mock(ChannelService.class);
when(channelService.fetchCachedChannelId(anyString())).thenReturn(completedFuture(Optional.of(createdSupplyChannelId)));
when(channelService.createAndCacheChannel(any())).thenReturn(completedFuture(Optional.of(createdSupplyChannel)));
return channelService;
}
Aggregations