use of com.commercetools.sync.integration.commons.utils.TypeITUtils.TYPE_NAME_2 in project commercetools-sync-java by commercetools.
the class TypeSyncIT method sync_WithConcurrentModificationException_ShouldRetryToUpdateNewTypeWithSuccess.
@Test
void sync_WithConcurrentModificationException_ShouldRetryToUpdateNewTypeWithSuccess() {
// Preparation
final SphereClient spyClient = buildClientWithConcurrentModificationUpdate();
final TypeDraft typeDraft = TypeDraftBuilder.of(TYPE_KEY_2, TYPE_NAME_2, ResourceTypeIdsSetBuilder.of().addChannels()).build();
CTP_TARGET_CLIENT.execute(TypeCreateCommand.of(typeDraft)).toCompletableFuture().join();
final TypeDraft updatedDraft = TypeDraftBuilder.of(typeDraft).name(TYPE_NAME_1).build();
final TypeSyncOptions typeSyncOptions = TypeSyncOptionsBuilder.of(spyClient).build();
final TypeSync typeSync = new TypeSync(typeSyncOptions);
// test
final TypeSyncStatistics statistics = typeSync.sync(Collections.singletonList(updatedDraft)).toCompletableFuture().join();
// assertion
assertThat(statistics).hasValues(1, 0, 1, 0);
// Assert CTP state.
final PagedQueryResult<Type> queryResult = CTP_TARGET_CLIENT.execute(TypeQuery.of().plusPredicates(queryModel -> queryModel.key().is(typeDraft.getKey()))).toCompletableFuture().join();
assertThat(queryResult.head()).hasValueSatisfying(type -> assertThat(type.getName()).isEqualTo(TYPE_NAME_1));
}
Aggregations