use of com.commercetools.sync.shoppinglists.ShoppingListSync in project commercetools-project-sync by commercetools.
the class ShoppingListSyncer method of.
public static ShoppingListSyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
final QuadConsumer<SyncException, Optional<ShoppingListDraft>, Optional<ShoppingList>, List<UpdateAction<ShoppingList>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "shoppingList", exception, oldResource.map(ShoppingList::getKey).orElse(IDENTIFIER_NOT_PRESENT), updateActions);
final TriConsumer<SyncException, Optional<ShoppingListDraft>, Optional<ShoppingList>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "shoppingList", exception, oldResource.map(ShoppingList::getKey).orElse(IDENTIFIER_NOT_PRESENT));
final ShoppingListSyncOptions shoppingListSyncOptions = ShoppingListSyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
final ShoppingListSync shoppingListSync = new ShoppingListSync(shoppingListSyncOptions);
final CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
return new ShoppingListSyncer(shoppingListSync, sourceClient, targetClient, customObjectService, clock);
}
use of com.commercetools.sync.shoppinglists.ShoppingListSync in project commercetools-sync-java by commercetools.
the class ShoppingListSyncIT method setUpShoppingListSync.
private void setUpShoppingListSync() {
errorMessages = new ArrayList<>();
warningMessages = new ArrayList<>();
exceptions = new ArrayList<>();
updateActionList = new ArrayList<>();
final ShoppingListSyncOptions shoppingListSyncOptions = ShoppingListSyncOptionsBuilder.of(CTP_TARGET_CLIENT).errorCallback((exception, oldResource, newResource, actions) -> {
errorMessages.add(exception.getMessage());
exceptions.add(exception);
}).warningCallback((exception, oldResource, newResource) -> warningMessages.add(exception.getMessage())).beforeUpdateCallback((updateActions, customerDraft, customer) -> {
updateActionList.addAll(Objects.requireNonNull(updateActions));
return updateActions;
}).build();
shoppingListSync = new ShoppingListSync(shoppingListSyncOptions);
}
use of com.commercetools.sync.shoppinglists.ShoppingListSync in project commercetools-sync-java by commercetools.
the class ShoppingListSyncIT method setUpShoppingListSync.
private void setUpShoppingListSync() {
errorMessages = new ArrayList<>();
warningMessages = new ArrayList<>();
exceptions = new ArrayList<>();
updateActionList = new ArrayList<>();
final ShoppingListSyncOptions shoppingListSyncOptions = ShoppingListSyncOptionsBuilder.of(CTP_TARGET_CLIENT).errorCallback((exception, oldResource, newResource, actions) -> {
errorMessages.add(exception.getMessage());
exceptions.add(exception);
}).warningCallback((exception, oldResource, newResource) -> warningMessages.add(exception.getMessage())).beforeUpdateCallback((updateActions, customerDraft, customer) -> {
updateActionList.addAll(Objects.requireNonNull(updateActions));
return updateActions;
}).build();
shoppingListSync = new ShoppingListSync(shoppingListSyncOptions);
}
Aggregations