Search in sources :

Example 11 with StateSync

use of com.commercetools.sync.states.StateSync in project commercetools-sync-java by commercetools.

the class StateSyncIT method sync_withNewStateWithNewRole_shouldAddRole.

@Test
void sync_withNewStateWithNewRole_shouldAddRole() {
    final StateDraft stateDraft = StateDraftBuilder.of(keyA, StateType.REVIEW_STATE).roles(asSet(StateRole.REVIEW_INCLUDED_IN_STATISTICS)).build();
    final StateDraft stateDraftTarget = StateDraftBuilder.of(keyA, StateType.REVIEW_STATE).roles(Collections.emptySet()).build();
    createStateInTarget(stateDraftTarget);
    final StateSyncOptions stateSyncOptions = StateSyncOptionsBuilder.of(CTP_TARGET_CLIENT).build();
    final StateSync stateSync = new StateSync(stateSyncOptions);
    // test
    final StateSyncStatistics stateSyncStatistics = stateSync.sync(singletonList(stateDraft)).toCompletableFuture().join();
    assertThat(stateSyncStatistics).hasValues(1, 0, 1, 0, 0);
    CtpQueryUtils.queryAll(CTP_TARGET_CLIENT, StateQueryBuilder.of().plusPredicates(q -> q.key().is(keyA)).build(), Function.identity()).thenApply(fetchedCategories -> fetchedCategories.stream().flatMap(List::stream).collect(Collectors.toList())).thenAccept(resultStates -> {
        Assertions.assertThat(resultStates.size()).isEqualTo(1);
        Assertions.assertThat(resultStates.get(0).getRoles().size()).isEqualTo(1);
    }).toCompletableFuture().join();
}
Also used : CustomObjectQuery(io.sphere.sdk.customobjects.queries.CustomObjectQuery) BeforeEach(org.junit.jupiter.api.BeforeEach) StateSyncStatistics(com.commercetools.sync.states.helpers.StateSyncStatistics) Arrays(java.util.Arrays) Reference(io.sphere.sdk.models.Reference) CTP_SOURCE_CLIENT(com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_SOURCE_CLIENT) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Collections.singletonList(java.util.Collections.singletonList) AfterAll(org.junit.jupiter.api.AfterAll) ReferenceIdToKeyCache(com.commercetools.sync.commons.utils.ReferenceIdToKeyCache) StateTransformUtils(com.commercetools.sync.states.utils.StateTransformUtils) StateCreateCommand(io.sphere.sdk.states.commands.StateCreateCommand) Arrays.asList(java.util.Arrays.asList) StateITUtils.getStateByKey(com.commercetools.sync.integration.commons.utils.StateITUtils.getStateByKey) SphereClient(io.sphere.sdk.client.SphereClient) CompletableFutureUtils.exceptionallyCompletedFuture(io.sphere.sdk.utils.CompletableFutureUtils.exceptionallyCompletedFuture) StateType(io.sphere.sdk.states.StateType) Assertions(org.assertj.core.api.Assertions) UnresolvedReferencesServiceImpl(com.commercetools.sync.services.impl.UnresolvedReferencesServiceImpl) BadGatewayException(io.sphere.sdk.client.BadGatewayException) ThreadLocalRandom.current(java.util.concurrent.ThreadLocalRandom.current) CompletionStageUtil.executeBlocking(com.commercetools.tests.utils.CompletionStageUtil.executeBlocking) ResourceKeyIdGraphQlRequest(com.commercetools.sync.commons.helpers.ResourceKeyIdGraphQlRequest) StateUpdateCommand(io.sphere.sdk.states.commands.StateUpdateCommand) Set(java.util.Set) StateServiceImpl(com.commercetools.sync.services.impl.StateServiceImpl) State(io.sphere.sdk.states.State) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) StateITUtils.deleteStatesFromTargetAndSource(com.commercetools.sync.integration.commons.utils.StateITUtils.deleteStatesFromTargetAndSource) Test(org.junit.jupiter.api.Test) LocalizedString(io.sphere.sdk.models.LocalizedString) List(java.util.List) CUSTOM_OBJECT_TRANSITION_CONTAINER_KEY(com.commercetools.sync.services.impl.UnresolvedReferencesServiceImpl.CUSTOM_OBJECT_TRANSITION_CONTAINER_KEY) LocalizedString.ofEnglish(io.sphere.sdk.models.LocalizedString.ofEnglish) CompletionStage(java.util.concurrent.CompletionStage) SphereInternalUtils.asSet(io.sphere.sdk.utils.SphereInternalUtils.asSet) Optional(java.util.Optional) StateDraft(io.sphere.sdk.states.StateDraft) StateITUtils.deleteStates(com.commercetools.sync.integration.commons.utils.StateITUtils.deleteStates) CTP_TARGET_CLIENT(com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IntStream(java.util.stream.IntStream) StateQuery(io.sphere.sdk.states.queries.StateQuery) BadRequestException(io.sphere.sdk.client.BadRequestException) AssertionsForStatistics.assertThat(com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat) Mockito.spy(org.mockito.Mockito.spy) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) State.referenceOfId(io.sphere.sdk.states.State.referenceOfId) StateReferenceResolver(com.commercetools.sync.states.helpers.StateReferenceResolver) UnresolvedReferencesService(com.commercetools.sync.services.UnresolvedReferencesService) StateRole(io.sphere.sdk.states.StateRole) Nonnull(javax.annotation.Nonnull) StateDraftBuilder(io.sphere.sdk.states.StateDraftBuilder) StateQueryBuilder(io.sphere.sdk.states.queries.StateQueryBuilder) StateSyncOptionsBuilder(com.commercetools.sync.states.StateSyncOptionsBuilder) CaffeineReferenceIdToKeyCacheImpl(com.commercetools.sync.commons.utils.CaffeineReferenceIdToKeyCacheImpl) StateSync(com.commercetools.sync.states.StateSync) Mockito.when(org.mockito.Mockito.when) StateSyncOptions(com.commercetools.sync.states.StateSyncOptions) CtpQueryUtils(com.commercetools.sync.commons.utils.CtpQueryUtils) WaitingToBeResolvedTransitions(com.commercetools.sync.commons.models.WaitingToBeResolvedTransitions) PagedQueryResult(io.sphere.sdk.queries.PagedQueryResult) ConcurrentModificationException(io.sphere.sdk.client.ConcurrentModificationException) Collections(java.util.Collections) StateSync(com.commercetools.sync.states.StateSync) StateDraft(io.sphere.sdk.states.StateDraft) StateSyncStatistics(com.commercetools.sync.states.helpers.StateSyncStatistics) StateSyncOptions(com.commercetools.sync.states.StateSyncOptions) Test(org.junit.jupiter.api.Test)

Example 12 with StateSync

use of com.commercetools.sync.states.StateSync in project commercetools-project-sync by commercetools.

the class StateSyncer method of.

public static StateSyncer of(@Nonnull final SphereClient sourceClient, @Nonnull final SphereClient targetClient, @Nonnull final Clock clock) {
    final QuadConsumer<SyncException, Optional<StateDraft>, Optional<State>, List<UpdateAction<State>>> logErrorCallback = (exception, newResourceDraft, oldResource, updateActions) -> logErrorCallback(LOGGER, "state", exception, oldResource, updateActions);
    final TriConsumer<SyncException, Optional<StateDraft>, Optional<State>> logWarningCallback = (exception, newResourceDraft, oldResource) -> logWarningCallback(LOGGER, "state", exception, oldResource);
    StateSyncOptions syncOptions = StateSyncOptionsBuilder.of(targetClient).errorCallback(logErrorCallback).warningCallback(logWarningCallback).build();
    StateSync stateSync = new StateSync(syncOptions);
    CustomObjectService customObjectService = new CustomObjectServiceImpl(targetClient);
    return new StateSyncer(stateSync, sourceClient, targetClient, customObjectService, clock);
}
Also used : StateSyncStatistics(com.commercetools.sync.states.helpers.StateSyncStatistics) SyncException(com.commercetools.sync.commons.exceptions.SyncException) StateQuery(io.sphere.sdk.states.queries.StateQuery) LoggerFactory(org.slf4j.LoggerFactory) UpdateAction(io.sphere.sdk.commands.UpdateAction) QuadConsumer(com.commercetools.sync.commons.utils.QuadConsumer) SyncUtils.logWarningCallback(com.commercetools.project.sync.util.SyncUtils.logWarningCallback) SphereClient(io.sphere.sdk.client.SphereClient) TriConsumer(com.commercetools.sync.commons.utils.TriConsumer) Nonnull(javax.annotation.Nonnull) StateSyncOptionsBuilder(com.commercetools.sync.states.StateSyncOptionsBuilder) SyncUtils.logErrorCallback(com.commercetools.project.sync.util.SyncUtils.logErrorCallback) Logger(org.slf4j.Logger) CustomObjectService(com.commercetools.project.sync.service.CustomObjectService) StateSync(com.commercetools.sync.states.StateSync) StateSyncOptions(com.commercetools.sync.states.StateSyncOptions) State(io.sphere.sdk.states.State) List(java.util.List) CompletionStage(java.util.concurrent.CompletionStage) Syncer(com.commercetools.project.sync.Syncer) StateTransformUtils.toStateDrafts(com.commercetools.sync.states.utils.StateTransformUtils.toStateDrafts) Clock(java.time.Clock) Optional(java.util.Optional) StateDraft(io.sphere.sdk.states.StateDraft) CustomObjectServiceImpl(com.commercetools.project.sync.service.impl.CustomObjectServiceImpl) StateSync(com.commercetools.sync.states.StateSync) CustomObjectService(com.commercetools.project.sync.service.CustomObjectService) Optional(java.util.Optional) State(io.sphere.sdk.states.State) CustomObjectServiceImpl(com.commercetools.project.sync.service.impl.CustomObjectServiceImpl) List(java.util.List) SyncException(com.commercetools.sync.commons.exceptions.SyncException) StateSyncOptions(com.commercetools.sync.states.StateSyncOptions)

Example 13 with StateSync

use of com.commercetools.sync.states.StateSync in project commercetools-sync-java by commercetools.

the class StateSyncIT method sync_WithUpdatedState_ShouldUpdateState.

@Test
void sync_WithUpdatedState_ShouldUpdateState() {
    // preparation
    String key = this.key;
    final StateDraft stateDraft = StateDraftBuilder.of(key, StateType.REVIEW_STATE).name(ofEnglish("state-name-updated")).description(ofEnglish("state-desc-updated")).roles(Collections.singleton(StateRole.REVIEW_INCLUDED_IN_STATISTICS)).initial(true).build();
    final StateSyncOptions stateSyncOptions = StateSyncOptionsBuilder.of(CTP_TARGET_CLIENT).build();
    final StateSync stateSync = new StateSync(stateSyncOptions);
    // test
    final StateSyncStatistics stateSyncStatistics = stateSync.sync(singletonList(stateDraft)).toCompletableFuture().join();
    // assertion
    assertThat(stateSyncStatistics).hasValues(1, 0, 1, 0, 0);
    final Optional<State> oldStateAfter = getStateByKey(CTP_TARGET_CLIENT, key);
    Assertions.assertThat(oldStateAfter).hasValueSatisfying(state -> {
        Assertions.assertThat(state.getType()).isEqualTo(StateType.REVIEW_STATE);
        Assertions.assertThat(state.getName()).isEqualTo(ofEnglish("state-name-updated"));
        Assertions.assertThat(state.getDescription()).isEqualTo(ofEnglish("state-desc-updated"));
        Assertions.assertThat(state.getRoles()).isEqualTo(Collections.singleton(StateRole.REVIEW_INCLUDED_IN_STATISTICS));
        Assertions.assertThat(state.isInitial()).isEqualTo(true);
    });
    deleteStates(CTP_TARGET_CLIENT, Optional.empty());
}
Also used : StateSync(com.commercetools.sync.states.StateSync) StateDraft(io.sphere.sdk.states.StateDraft) StateSyncStatistics(com.commercetools.sync.states.helpers.StateSyncStatistics) State(io.sphere.sdk.states.State) LocalizedString(io.sphere.sdk.models.LocalizedString) StateSyncOptions(com.commercetools.sync.states.StateSyncOptions) Test(org.junit.jupiter.api.Test)

Example 14 with StateSync

use of com.commercetools.sync.states.StateSync in project commercetools-sync-java by commercetools.

the class StateSyncIT method sync_WithConcurrentModificationExceptionAndFailedFetch_ShouldFailToReFetchAndUpdate.

@Test
void sync_WithConcurrentModificationExceptionAndFailedFetch_ShouldFailToReFetchAndUpdate() {
    // preparation
    final SphereClient spyClient = buildClientWithConcurrentModificationUpdateAndFailedFetchOnRetry();
    final StateSyncOptions spyOptions = StateSyncOptionsBuilder.of(spyClient).errorCallback((exception, oldResource, newResource, updateActions) -> {
        errorCallBackMessages.add(exception.getMessage());
        errorCallBackExceptions.add(exception.getCause());
    }).warningCallback((exception, newResource, oldResource) -> warningCallBackMessages.add(exception.getMessage())).build();
    final StateSync stateSync = new StateSync(spyOptions);
    final StateDraft stateDraft = StateDraftBuilder.of(key, StateType.REVIEW_STATE).name(ofEnglish("state-name-updated")).description(ofEnglish("state-desc-updated")).roles(Collections.singleton(StateRole.REVIEW_INCLUDED_IN_STATISTICS)).initial(true).build();
    final StateSyncStatistics syncStatistics = executeBlocking(stateSync.sync(singletonList(stateDraft)));
    // Test and assertion
    assertThat(syncStatistics).hasValues(1, 0, 0, 1, 0);
    Assertions.assertThat(errorCallBackMessages).hasSize(1);
    Assertions.assertThat(errorCallBackExceptions).hasSize(1);
    Assertions.assertThat(errorCallBackExceptions.get(0).getCause()).isExactlyInstanceOf(BadGatewayException.class);
    Assertions.assertThat(errorCallBackMessages.get(0)).contains(format("Failed to update state with key: '%s'. Reason: Failed to fetch from CTP while retrying " + "after concurrency modification.", stateDraft.getKey()));
}
Also used : CustomObjectQuery(io.sphere.sdk.customobjects.queries.CustomObjectQuery) BeforeEach(org.junit.jupiter.api.BeforeEach) StateSyncStatistics(com.commercetools.sync.states.helpers.StateSyncStatistics) Arrays(java.util.Arrays) Reference(io.sphere.sdk.models.Reference) CTP_SOURCE_CLIENT(com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_SOURCE_CLIENT) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Collections.singletonList(java.util.Collections.singletonList) AfterAll(org.junit.jupiter.api.AfterAll) ReferenceIdToKeyCache(com.commercetools.sync.commons.utils.ReferenceIdToKeyCache) StateTransformUtils(com.commercetools.sync.states.utils.StateTransformUtils) StateCreateCommand(io.sphere.sdk.states.commands.StateCreateCommand) Arrays.asList(java.util.Arrays.asList) StateITUtils.getStateByKey(com.commercetools.sync.integration.commons.utils.StateITUtils.getStateByKey) SphereClient(io.sphere.sdk.client.SphereClient) CompletableFutureUtils.exceptionallyCompletedFuture(io.sphere.sdk.utils.CompletableFutureUtils.exceptionallyCompletedFuture) StateType(io.sphere.sdk.states.StateType) Assertions(org.assertj.core.api.Assertions) UnresolvedReferencesServiceImpl(com.commercetools.sync.services.impl.UnresolvedReferencesServiceImpl) BadGatewayException(io.sphere.sdk.client.BadGatewayException) ThreadLocalRandom.current(java.util.concurrent.ThreadLocalRandom.current) CompletionStageUtil.executeBlocking(com.commercetools.tests.utils.CompletionStageUtil.executeBlocking) ResourceKeyIdGraphQlRequest(com.commercetools.sync.commons.helpers.ResourceKeyIdGraphQlRequest) StateUpdateCommand(io.sphere.sdk.states.commands.StateUpdateCommand) Set(java.util.Set) StateServiceImpl(com.commercetools.sync.services.impl.StateServiceImpl) State(io.sphere.sdk.states.State) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) StateITUtils.deleteStatesFromTargetAndSource(com.commercetools.sync.integration.commons.utils.StateITUtils.deleteStatesFromTargetAndSource) Test(org.junit.jupiter.api.Test) LocalizedString(io.sphere.sdk.models.LocalizedString) List(java.util.List) CUSTOM_OBJECT_TRANSITION_CONTAINER_KEY(com.commercetools.sync.services.impl.UnresolvedReferencesServiceImpl.CUSTOM_OBJECT_TRANSITION_CONTAINER_KEY) LocalizedString.ofEnglish(io.sphere.sdk.models.LocalizedString.ofEnglish) CompletionStage(java.util.concurrent.CompletionStage) SphereInternalUtils.asSet(io.sphere.sdk.utils.SphereInternalUtils.asSet) Optional(java.util.Optional) StateDraft(io.sphere.sdk.states.StateDraft) StateITUtils.deleteStates(com.commercetools.sync.integration.commons.utils.StateITUtils.deleteStates) CTP_TARGET_CLIENT(com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IntStream(java.util.stream.IntStream) StateQuery(io.sphere.sdk.states.queries.StateQuery) BadRequestException(io.sphere.sdk.client.BadRequestException) AssertionsForStatistics.assertThat(com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat) Mockito.spy(org.mockito.Mockito.spy) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) State.referenceOfId(io.sphere.sdk.states.State.referenceOfId) StateReferenceResolver(com.commercetools.sync.states.helpers.StateReferenceResolver) UnresolvedReferencesService(com.commercetools.sync.services.UnresolvedReferencesService) StateRole(io.sphere.sdk.states.StateRole) Nonnull(javax.annotation.Nonnull) StateDraftBuilder(io.sphere.sdk.states.StateDraftBuilder) StateQueryBuilder(io.sphere.sdk.states.queries.StateQueryBuilder) StateSyncOptionsBuilder(com.commercetools.sync.states.StateSyncOptionsBuilder) CaffeineReferenceIdToKeyCacheImpl(com.commercetools.sync.commons.utils.CaffeineReferenceIdToKeyCacheImpl) StateSync(com.commercetools.sync.states.StateSync) Mockito.when(org.mockito.Mockito.when) StateSyncOptions(com.commercetools.sync.states.StateSyncOptions) CtpQueryUtils(com.commercetools.sync.commons.utils.CtpQueryUtils) WaitingToBeResolvedTransitions(com.commercetools.sync.commons.models.WaitingToBeResolvedTransitions) PagedQueryResult(io.sphere.sdk.queries.PagedQueryResult) ConcurrentModificationException(io.sphere.sdk.client.ConcurrentModificationException) Collections(java.util.Collections) StateSync(com.commercetools.sync.states.StateSync) StateDraft(io.sphere.sdk.states.StateDraft) StateSyncStatistics(com.commercetools.sync.states.helpers.StateSyncStatistics) SphereClient(io.sphere.sdk.client.SphereClient) StateSyncOptions(com.commercetools.sync.states.StateSyncOptions) Test(org.junit.jupiter.api.Test)

Example 15 with StateSync

use of com.commercetools.sync.states.StateSync in project commercetools-sync-java by commercetools.

the class StateSyncIT method sync_WithExceptionWhenFetchingUnresolvedTransition_ShouldPrintErrorMessage.

@Test
void sync_WithExceptionWhenFetchingUnresolvedTransition_ShouldPrintErrorMessage() {
    final StateDraft stateCDraft = createStateDraft(keyC);
    final State stateC = createStateInSource(stateCDraft);
    final StateDraft stateBDraft = createStateDraft(keyB, stateC);
    final State stateB = createStateInSource(stateBDraft);
    final StateDraft stateADraft = createStateDraft(keyA, stateB, stateC);
    final State stateA = createStateInSource(stateADraft);
    final SphereClient spyClient = spy(CTP_TARGET_CLIENT);
    when(spyClient.execute(any(CustomObjectQuery.class))).thenReturn(exceptionallyCompletedFuture(new BadRequestException("a test exception"))).thenReturn(exceptionallyCompletedFuture(new ConcurrentModificationException())).thenCallRealMethod();
    final StateSyncOptions stateSyncOptions = StateSyncOptionsBuilder.of(spyClient).batchSize(3).errorCallback((exception, oldResource, newResource, updateActions) -> {
        errorCallBackMessages.add(exception.getMessage());
        errorCallBackExceptions.add(exception.getCause());
    }).warningCallback((exception, newResource, oldResource) -> warningCallBackMessages.add(exception.getMessage())).build();
    final StateSync stateSync = new StateSync(stateSyncOptions);
    final List<StateDraft> stateDrafts = StateTransformUtils.toStateDrafts(CTP_SOURCE_CLIENT, referenceIdToKeyCache, Arrays.asList(stateA, stateB, stateC)).join();
    // test
    final StateSyncStatistics stateSyncStatistics = stateSync.sync(stateDrafts).toCompletableFuture().join();
    assertThat(stateSyncStatistics).hasValues(3, 1, 0, 2, 1);
    Assertions.assertThat(errorCallBackExceptions).isNotEmpty();
    Assertions.assertThat(errorCallBackMessages).isNotEmpty();
    Assertions.assertThat(errorCallBackMessages.get(0)).contains(format("Failed to fetch StateDrafts waiting to be resolved with keys"));
}
Also used : CustomObjectQuery(io.sphere.sdk.customobjects.queries.CustomObjectQuery) BeforeEach(org.junit.jupiter.api.BeforeEach) StateSyncStatistics(com.commercetools.sync.states.helpers.StateSyncStatistics) Arrays(java.util.Arrays) Reference(io.sphere.sdk.models.Reference) CTP_SOURCE_CLIENT(com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_SOURCE_CLIENT) CompletableFuture.completedFuture(java.util.concurrent.CompletableFuture.completedFuture) Collections.singletonList(java.util.Collections.singletonList) AfterAll(org.junit.jupiter.api.AfterAll) ReferenceIdToKeyCache(com.commercetools.sync.commons.utils.ReferenceIdToKeyCache) StateTransformUtils(com.commercetools.sync.states.utils.StateTransformUtils) StateCreateCommand(io.sphere.sdk.states.commands.StateCreateCommand) Arrays.asList(java.util.Arrays.asList) StateITUtils.getStateByKey(com.commercetools.sync.integration.commons.utils.StateITUtils.getStateByKey) SphereClient(io.sphere.sdk.client.SphereClient) CompletableFutureUtils.exceptionallyCompletedFuture(io.sphere.sdk.utils.CompletableFutureUtils.exceptionallyCompletedFuture) StateType(io.sphere.sdk.states.StateType) Assertions(org.assertj.core.api.Assertions) UnresolvedReferencesServiceImpl(com.commercetools.sync.services.impl.UnresolvedReferencesServiceImpl) BadGatewayException(io.sphere.sdk.client.BadGatewayException) ThreadLocalRandom.current(java.util.concurrent.ThreadLocalRandom.current) CompletionStageUtil.executeBlocking(com.commercetools.tests.utils.CompletionStageUtil.executeBlocking) ResourceKeyIdGraphQlRequest(com.commercetools.sync.commons.helpers.ResourceKeyIdGraphQlRequest) StateUpdateCommand(io.sphere.sdk.states.commands.StateUpdateCommand) Set(java.util.Set) StateServiceImpl(com.commercetools.sync.services.impl.StateServiceImpl) State(io.sphere.sdk.states.State) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) StateITUtils.deleteStatesFromTargetAndSource(com.commercetools.sync.integration.commons.utils.StateITUtils.deleteStatesFromTargetAndSource) Test(org.junit.jupiter.api.Test) LocalizedString(io.sphere.sdk.models.LocalizedString) List(java.util.List) CUSTOM_OBJECT_TRANSITION_CONTAINER_KEY(com.commercetools.sync.services.impl.UnresolvedReferencesServiceImpl.CUSTOM_OBJECT_TRANSITION_CONTAINER_KEY) LocalizedString.ofEnglish(io.sphere.sdk.models.LocalizedString.ofEnglish) CompletionStage(java.util.concurrent.CompletionStage) SphereInternalUtils.asSet(io.sphere.sdk.utils.SphereInternalUtils.asSet) Optional(java.util.Optional) StateDraft(io.sphere.sdk.states.StateDraft) StateITUtils.deleteStates(com.commercetools.sync.integration.commons.utils.StateITUtils.deleteStates) CTP_TARGET_CLIENT(com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) IntStream(java.util.stream.IntStream) StateQuery(io.sphere.sdk.states.queries.StateQuery) BadRequestException(io.sphere.sdk.client.BadRequestException) AssertionsForStatistics.assertThat(com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat) Mockito.spy(org.mockito.Mockito.spy) Function(java.util.function.Function) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) State.referenceOfId(io.sphere.sdk.states.State.referenceOfId) StateReferenceResolver(com.commercetools.sync.states.helpers.StateReferenceResolver) UnresolvedReferencesService(com.commercetools.sync.services.UnresolvedReferencesService) StateRole(io.sphere.sdk.states.StateRole) Nonnull(javax.annotation.Nonnull) StateDraftBuilder(io.sphere.sdk.states.StateDraftBuilder) StateQueryBuilder(io.sphere.sdk.states.queries.StateQueryBuilder) StateSyncOptionsBuilder(com.commercetools.sync.states.StateSyncOptionsBuilder) CaffeineReferenceIdToKeyCacheImpl(com.commercetools.sync.commons.utils.CaffeineReferenceIdToKeyCacheImpl) StateSync(com.commercetools.sync.states.StateSync) Mockito.when(org.mockito.Mockito.when) StateSyncOptions(com.commercetools.sync.states.StateSyncOptions) CtpQueryUtils(com.commercetools.sync.commons.utils.CtpQueryUtils) WaitingToBeResolvedTransitions(com.commercetools.sync.commons.models.WaitingToBeResolvedTransitions) PagedQueryResult(io.sphere.sdk.queries.PagedQueryResult) ConcurrentModificationException(io.sphere.sdk.client.ConcurrentModificationException) Collections(java.util.Collections) StateSync(com.commercetools.sync.states.StateSync) ConcurrentModificationException(io.sphere.sdk.client.ConcurrentModificationException) StateDraft(io.sphere.sdk.states.StateDraft) State(io.sphere.sdk.states.State) StateSyncStatistics(com.commercetools.sync.states.helpers.StateSyncStatistics) SphereClient(io.sphere.sdk.client.SphereClient) BadRequestException(io.sphere.sdk.client.BadRequestException) CustomObjectQuery(io.sphere.sdk.customobjects.queries.CustomObjectQuery) StateSyncOptions(com.commercetools.sync.states.StateSyncOptions) Test(org.junit.jupiter.api.Test)

Aggregations

StateSync (com.commercetools.sync.states.StateSync)27 StateSyncOptions (com.commercetools.sync.states.StateSyncOptions)27 StateSyncStatistics (com.commercetools.sync.states.helpers.StateSyncStatistics)27 StateDraft (io.sphere.sdk.states.StateDraft)26 Test (org.junit.jupiter.api.Test)26 State (io.sphere.sdk.states.State)23 WaitingToBeResolvedTransitions (com.commercetools.sync.commons.models.WaitingToBeResolvedTransitions)21 UnresolvedReferencesServiceImpl (com.commercetools.sync.services.impl.UnresolvedReferencesServiceImpl)21 SphereClient (io.sphere.sdk.client.SphereClient)21 LocalizedString (io.sphere.sdk.models.LocalizedString)21 StateSyncOptionsBuilder (com.commercetools.sync.states.StateSyncOptionsBuilder)20 AssertionsForStatistics.assertThat (com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat)19 ResourceKeyIdGraphQlRequest (com.commercetools.sync.commons.helpers.ResourceKeyIdGraphQlRequest)19 CaffeineReferenceIdToKeyCacheImpl (com.commercetools.sync.commons.utils.CaffeineReferenceIdToKeyCacheImpl)19 CtpQueryUtils (com.commercetools.sync.commons.utils.CtpQueryUtils)19 ReferenceIdToKeyCache (com.commercetools.sync.commons.utils.ReferenceIdToKeyCache)19 CTP_SOURCE_CLIENT (com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_SOURCE_CLIENT)19 CTP_TARGET_CLIENT (com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT)19 StateITUtils.deleteStates (com.commercetools.sync.integration.commons.utils.StateITUtils.deleteStates)19 StateITUtils.deleteStatesFromTargetAndSource (com.commercetools.sync.integration.commons.utils.StateITUtils.deleteStatesFromTargetAndSource)19