Search in sources :

Example 6 with TaxCategorySync

use of com.commercetools.sync.taxcategories.TaxCategorySync in project commercetools-sync-java by commercetools.

the class TaxCategorySyncIT method sync_withNewTaxCategory_shouldCreateTaxCategory.

@Test
void sync_withNewTaxCategory_shouldCreateTaxCategory() {
    final SubRate subRate1 = SubRate.of("subRate-1", 0.05);
    final SubRate subRate2 = SubRate.of("subRate-2", 0.06);
    final TaxRateDraft taxRateDraft = TaxRateDraftBuilder.of("%11 US", 0.11, false, CountryCode.US).subRates(asList(subRate1, subRate2)).build();
    final TaxCategoryDraft taxCategoryDraft = TaxCategoryDraftBuilder.of("tax-category-name-new", singletonList(taxRateDraft), "tax-category-description-new").key("tax-category-key-new").build();
    final TaxCategorySyncOptions taxCategorySyncOptions = TaxCategorySyncOptionsBuilder.of(CTP_TARGET_CLIENT).build();
    final TaxCategorySync taxCategorySync = new TaxCategorySync(taxCategorySyncOptions);
    // test
    final TaxCategorySyncStatistics taxCategorySyncStatistics = taxCategorySync.sync(singletonList(taxCategoryDraft)).toCompletableFuture().join();
    assertThat(taxCategorySyncStatistics).hasValues(1, 1, 0, 0);
}
Also used : TaxCategoryDraft(io.sphere.sdk.taxcategories.TaxCategoryDraft) TaxCategorySync(com.commercetools.sync.taxcategories.TaxCategorySync) TaxCategorySyncOptions(com.commercetools.sync.taxcategories.TaxCategorySyncOptions) TaxCategorySyncStatistics(com.commercetools.sync.taxcategories.helpers.TaxCategorySyncStatistics) SubRate(io.sphere.sdk.taxcategories.SubRate) TaxRateDraft(io.sphere.sdk.taxcategories.TaxRateDraft) Test(org.junit.jupiter.api.Test)

Example 7 with TaxCategorySync

use of com.commercetools.sync.taxcategories.TaxCategorySync in project commercetools-sync-java by commercetools.

the class TaxCategorySyncIT method sync_withEqualTaxCategory_shouldNotUpdateTaxCategory.

@Test
void sync_withEqualTaxCategory_shouldNotUpdateTaxCategory() {
    final SubRate subRate1 = SubRate.of("subRate-1", 0.08);
    final SubRate subRate2 = SubRate.of("subRate-2", 0.11);
    final TaxRateDraft taxRateDraft = TaxRateDraftBuilder.of("%19 VAT DE", 0.19, false, CountryCode.DE).subRates(asList(subRate1, subRate2)).build();
    final TaxCategoryDraft taxCategoryDraft = TaxCategoryDraftBuilder.of("tax-category-name", singletonList(taxRateDraft), "tax-category-description").key("tax-category-key").build();
    final TaxCategorySyncOptions taxCategorySyncOptions = TaxCategorySyncOptionsBuilder.of(CTP_TARGET_CLIENT).build();
    final TaxCategorySync taxCategorySync = new TaxCategorySync(taxCategorySyncOptions);
    // test
    final TaxCategorySyncStatistics taxCategorySyncStatistics = taxCategorySync.sync(singletonList(taxCategoryDraft)).toCompletableFuture().join();
    assertThat(taxCategorySyncStatistics).hasValues(1, 0, 0, 0);
}
Also used : TaxCategoryDraft(io.sphere.sdk.taxcategories.TaxCategoryDraft) TaxCategorySync(com.commercetools.sync.taxcategories.TaxCategorySync) TaxCategorySyncOptions(com.commercetools.sync.taxcategories.TaxCategorySyncOptions) TaxCategorySyncStatistics(com.commercetools.sync.taxcategories.helpers.TaxCategorySyncStatistics) SubRate(io.sphere.sdk.taxcategories.SubRate) TaxRateDraft(io.sphere.sdk.taxcategories.TaxRateDraft) Test(org.junit.jupiter.api.Test)

Aggregations

TaxCategorySync (com.commercetools.sync.taxcategories.TaxCategorySync)7 TaxCategorySyncOptions (com.commercetools.sync.taxcategories.TaxCategorySyncOptions)7 TaxCategorySyncStatistics (com.commercetools.sync.taxcategories.helpers.TaxCategorySyncStatistics)7 TaxCategoryDraft (io.sphere.sdk.taxcategories.TaxCategoryDraft)7 TaxRateDraft (io.sphere.sdk.taxcategories.TaxRateDraft)7 SubRate (io.sphere.sdk.taxcategories.SubRate)6 Test (org.junit.jupiter.api.Test)6 TaxCategory (io.sphere.sdk.taxcategories.TaxCategory)5 TaxRate (io.sphere.sdk.taxcategories.TaxRate)5 TaxCategorySyncOptionsBuilder (com.commercetools.sync.taxcategories.TaxCategorySyncOptionsBuilder)4 SphereClient (io.sphere.sdk.client.SphereClient)4 TaxCategoryDraftBuilder (io.sphere.sdk.taxcategories.TaxCategoryDraftBuilder)4 TaxRateDraftBuilder (io.sphere.sdk.taxcategories.TaxRateDraftBuilder)4 TaxCategoryQuery (io.sphere.sdk.taxcategories.queries.TaxCategoryQuery)4 List (java.util.List)4 Optional (java.util.Optional)4 CompletableFuture (java.util.concurrent.CompletableFuture)4 Nonnull (javax.annotation.Nonnull)4 AssertionsForStatistics.assertThat (com.commercetools.sync.commons.asserts.statistics.AssertionsForStatistics.assertThat)3 CTP_TARGET_CLIENT (com.commercetools.sync.integration.commons.utils.SphereClientUtils.CTP_TARGET_CLIENT)3