use of com.commercetools.sync.services.CartDiscountService in project commercetools-sync-java by commercetools.
the class CartDiscountServiceImplTest method updateCartDiscount_WithMockSuccessfulCtpResponse_ShouldCallCartDiscountUpdateCommand.
@Test
void updateCartDiscount_WithMockSuccessfulCtpResponse_ShouldCallCartDiscountUpdateCommand() {
// preparation
final CartDiscount mockCartDiscount = mock(CartDiscount.class);
final CartDiscountSyncOptions cartDiscountSyncOptions = CartDiscountSyncOptionsBuilder.of(mock(SphereClient.class)).build();
when(cartDiscountSyncOptions.getCtpClient().execute(any())).thenReturn(completedFuture(mockCartDiscount));
final CartDiscountService cartDiscountService = new CartDiscountServiceImpl(cartDiscountSyncOptions);
final List<UpdateAction<CartDiscount>> updateActions = singletonList(SetDescription.of(LocalizedString.ofEnglish("new_desc")));
// test
final CompletionStage<CartDiscount> result = cartDiscountService.updateCartDiscount(mockCartDiscount, updateActions);
// assertions
assertThat(result).isCompletedWithValue(mockCartDiscount);
verify(cartDiscountSyncOptions.getCtpClient()).execute(eq(CartDiscountUpdateCommand.of(mockCartDiscount, updateActions)));
}
Aggregations