use of com.commercetools.sync.commons.models.WaitingToBeResolved in project commercetools-sync-java by commercetools.
the class UnresolvedReferencesServiceImplTest method delete_OnSuccess_ShouldMakeRequestWithSha1HashedKey.
@SuppressWarnings("unchecked")
@Test
void delete_OnSuccess_ShouldMakeRequestWithSha1HashedKey() {
// preparation
final CustomObject customObjectMock = mock(CustomObject.class);
final ProductDraft productDraftMock = mock(ProductDraft.class);
when(productDraftMock.getKey()).thenReturn("product-draft-key");
final WaitingToBeResolvedProducts waitingDraft = new WaitingToBeResolvedProducts(productDraftMock, singleton("test-ref"));
when(customObjectMock.getValue()).thenReturn(waitingDraft);
when(productSyncOptions.getCtpClient().execute(any(CustomObjectDeleteCommand.class))).thenReturn(completedFuture(customObjectMock));
final ArgumentCaptor<CustomObjectDeleteCommand<WaitingToBeResolved>> requestArgumentCaptor = ArgumentCaptor.forClass(CustomObjectDeleteCommand.class);
// test
final Optional<WaitingToBeResolvedProducts> toBeResolvedOptional = service.delete("product-draft-key", CUSTOM_OBJECT_PRODUCT_CONTAINER_KEY, WaitingToBeResolvedProducts.class).toCompletableFuture().join();
// assertions
verify(productSyncOptions.getCtpClient()).execute(requestArgumentCaptor.capture());
assertThat(toBeResolvedOptional).contains(waitingDraft);
final CustomObjectDeleteCommand<WaitingToBeResolved> value = requestArgumentCaptor.getValue();
assertThat(value.httpRequestIntent().getPath()).contains(sha1Hex(productDraftMock.getKey()));
}
Aggregations