use of com.commercetools.sync.states.helpers.StateReferenceResolver in project commercetools-sync-java by commercetools.
the class StateSyncIT method sync_WithStateWithEmptyTransitionShouldBeResolved_ShouldAddErrorMessage.
@Test
void sync_WithStateWithEmptyTransitionShouldBeResolved_ShouldAddErrorMessage() {
final StateDraft stateCDraft = StateDraftBuilder.of(keyC, StateType.REVIEW_STATE).roles(Collections.singleton(StateRole.REVIEW_INCLUDED_IN_STATISTICS)).transitions(new HashSet<>(Arrays.asList(Reference.of(State.referenceTypeId(), "")))).initial(true).build();
final StateSyncOptions stateSyncOptions = StateSyncOptionsBuilder.of(CTP_TARGET_CLIENT).batchSize(3).errorCallback((exception, oldResource, newResource, updateActions) -> {
errorCallBackMessages.add(exception.getMessage());
errorCallBackExceptions.add(exception.getCause());
}).warningCallback((exception, newResource, oldResource) -> warningCallBackMessages.add(exception.getMessage())).build();
// test
StateServiceImpl stateService = new StateServiceImpl(stateSyncOptions);
final StateReferenceResolver stateReferenceResolver = new StateReferenceResolver(stateSyncOptions, stateService);
CompletionStage<StateDraft> result = stateReferenceResolver.resolveReferences(stateCDraft);
result.exceptionally(exception -> {
Assertions.assertThat(exception.getMessage()).contains(format("Failed to resolve 'transition' reference on StateDraft with key:'%s", keyC));
return null;
}).toCompletableFuture().join();
}
Aggregations