@Override default Reference<TaxCategory> toReference() { return reference(this); }
@Override default Reference<TaxCategory> toReference() { return Reference.of(referenceTypeId(), getId(), this); }
@Test public void execution() { withTaxCategory(client(), taxCategory -> { final TaxCategory loadedTaxCategory = client().executeBlocking(TaxCategoryByIdGet.of(taxCategory.getId())); assertThat(loadedTaxCategory).isEqualTo(taxCategory); }); } }
static Reference<TaxCategory> referenceOfId(final String id) { return Reference.of(referenceTypeId(), id); } }
@Test public void deleteByKey() { final String key = randomKey(); final List<TaxRateDraft> taxRates = singletonList(TaxRateDraftBuilder.of("de19", 0.19, true, CountryCode.DE).build()); final TaxCategoryDraft taxCategoryDraft = TaxCategoryDraftBuilder.of(randomKey(), taxRates, "tax category description") .key(key) .build(); final TaxCategory taxCategory = client().executeBlocking(TaxCategoryCreateCommand.of(taxCategoryDraft)); client().executeBlocking(TaxCategoryDeleteCommand.ofKey(taxCategory.getKey(), taxCategory.getVersion())); final TaxCategory deletedTaxCategory = client().executeBlocking(TaxCategoryByKeyGet.of(key)); assertThat(deletedTaxCategory).isNull(); } }
@Test public void setKey() { withUpdateableTaxCategory(client(), taxCategory -> { final String newKey = randomKey(); assertThat(taxCategory.getKey()).isNotEqualTo(newKey); final TaxCategory updatedTaxCategory = client().executeBlocking(TaxCategoryUpdateCommand.of(taxCategory, SetKey.of(newKey))); assertThat(updatedTaxCategory.getKey()).isEqualTo(newKey); return updatedTaxCategory; }); }
@Test public void setDescription() { withUpdateableTaxCategory(client(), taxCategory -> { final String newDescription = randomKey(); final TaxCategory updatedTaxCategory = client().executeBlocking(TaxCategoryUpdateCommand.of(taxCategory, SetDescription.of(newDescription))); assertThat(updatedTaxCategory.getDescription()).isEqualTo(newDescription); return updatedTaxCategory; }); }
@Test public void changeTaxCategory() throws Exception { final TaxCategory newTaxCategory = TaxCategoryFixtures.defaultTaxCategory(client()); withUpdateableShippingMethod(client(), shippingMethod -> { assertThat(shippingMethod.getTaxCategory().getId()).isNotEqualTo(newTaxCategory.getId()); final ShippingMethodUpdateCommand cmd = ShippingMethodUpdateCommand.of(shippingMethod, ChangeTaxCategory.of(newTaxCategory)); final ShippingMethod updatedShippingMethod = client().executeBlocking(cmd); assertThat(updatedShippingMethod.getTaxCategory().getId()).isEqualTo(newTaxCategory.getId()); return updatedShippingMethod; }); }
/** * Creates a reference for one item of this class by a known ID. * <p> * <p>An example for categories but this applies for other resources, too:</p> * {@include.example io.sphere.sdk.categories.CategoryTest#referenceOfId()} * <p> * <p>If you already have a resource object, then use {@link #toReference()} instead:</p> * <p> * {@include.example io.sphere.sdk.categories.CategoryTest#toReference()} * * @param id the ID of the resource which should be referenced. * @return reference */ static Reference<TaxCategory> referenceOfId(final String id) { return Reference.of(referenceTypeId(), id); } }
@Test public void execution() { withTaxCategory(client(), taxCategory -> { final String key = randomKey(); final TaxCategory updatedTaxCategory = client().executeBlocking(TaxCategoryUpdateCommand.of(taxCategory, SetKey.of(key))); final TaxCategory loadedTaxCategory = client().executeBlocking(TaxCategoryByKeyGet.of(updatedTaxCategory.getKey())); assertThat(loadedTaxCategory).isEqualTo(updatedTaxCategory); }); } }
@Override default Reference<TaxCategory> toReference() { return Reference.of(referenceTypeId(), getId(), this); }
@Test public void deleteByVersioned() { final List<TaxRateDraft> taxRates = singletonList(TaxRateDraftBuilder.of("de19", 0.19, true, CountryCode.DE).build()); final TaxCategoryDraft taxCategoryDraft = TaxCategoryDraftBuilder.of(randomKey(), taxRates, "tax category description") .build(); final TaxCategory taxCategory = client().executeBlocking(TaxCategoryCreateCommand.of(taxCategoryDraft)); final String taxCategoryId = taxCategory.getId(); client().executeBlocking(TaxCategoryDeleteCommand.of(taxCategory)); final TaxCategory deletedTaxCategory = client().executeBlocking(TaxCategoryByIdGet.of(taxCategoryId)); assertThat(deletedTaxCategory).isNull(); }
/** * Creates a reference for one item of this class by a known ID. * <p> * <p>An example for categories but this applies for other resources, too:</p> * {@include.example io.sphere.sdk.categories.CategoryTest#referenceOfId()} * <p> * <p>If you already have a resource object, then use {@link #toReference()} instead:</p> * <p> * {@include.example io.sphere.sdk.categories.CategoryTest#toReference()} * * @param id the ID of the resource which should be referenced. * @return reference */ static Reference<TaxCategory> referenceOfId(final String id) { return Reference.of(referenceTypeId(), id); } }
@Override default Reference<TaxCategory> toReference() { return reference(this); }
@Override default Reference<TaxCategory> toReference() { return Reference.of(referenceTypeId(), getId(), this); }