public static MetaAttributes randomMetaAttributes() { final String metaTitle = "meta title" + randomString(); final String metaDescription = "meta description" + randomString(); final String metaKeywords = "meta keywords," + randomString(); return MetaAttributes.metaAttributesOf(ENGLISH, metaTitle, metaDescription, metaKeywords); }
public static MetaAttributes randomMetaAttributes() { final String metaTitle = "meta title" + randomString(); final String metaDescription = "meta description" + randomString(); final String metaKeywords = "meta keywords," + randomString(); return MetaAttributes.metaAttributesOf(ENGLISH, metaTitle, metaDescription, metaKeywords); }
public static MetaAttributes randomMetaAttributes() { final String metaTitle = "meta title" + randomString(); final String metaDescription = "meta description" + randomString(); final String metaKeywords = "meta keywords," + randomString(); return MetaAttributes.metaAttributesOf(ENGLISH, metaTitle, metaDescription, metaKeywords); }
@Test public void orderNumber() throws Exception { final String orderNumber = randomString(); testOrderAspect(builder -> builder.orderNumber(orderNumber), order -> assertThat(order.getOrderNumber()).contains(orderNumber)); }
@Test public void ofTemplateShouldCopyAllProperties() throws Exception { final ProductVariantDraftDsl template = ProductVariantDraftBuilder.of() .attributes(Collections.emptyList()) .assets(Collections.emptyList()) .key(randomString()) .sku(randomString()) .prices(Collections.emptyList()) .build(); final ProductVariantDraftDsl copy = ProductVariantDraftBuilder.of(template).build(); assertThat(copy).isEqualTo(template); }
public static void withShoppingListAndTaxedProduct(final BlockingSphereClient client, final BiFunction<ShoppingList, Product, ShoppingList> f) { withTaxedProduct(client, product -> { final ShoppingList shoppingList = createShoppingList(client, randomString()); final ShoppingList shoppingListToDelete = f.apply(shoppingList, product); client.executeBlocking(ShoppingListDeleteCommand.of(shoppingListToDelete)); }); }
public static void withTaxedProduct(final BlockingSphereClient client, final Consumer<Product> user) { TaxCategoryFixtures.withTransientTaxCategory(client, taxCategory -> withProduct(client, randomString(), product -> { final Product productWithTaxes = client.executeBlocking(createSetTaxesCommand(taxCategory, product)); user.accept(productWithTaxes); }) ); }
public static void withUpdateableShippingMethod(final BlockingSphereClient client, final Consumer<ShippingMethod> consumer) { withTaxCategory(client, taxCategory -> { final ShippingMethodDraft draft = ShippingMethodDraft.of(randomString(), "test shipping method", taxCategory, asList()); final ShippingMethod shippingMethod = client.executeBlocking(ShippingMethodCreateCommand.of(draft)); consumer.accept(shippingMethod); }); } }
@Test public void constructionWithoutName() { final CustomerDraft customerDraft = CustomerDraftDsl.of(randomString(), "password"); assertThat(customerDraft.getLastName()).isNull(); assertThat(customerDraft.getFirstName()).isNull(); assertThat(customerDraft.getName().getLastName()).isNull(); } }
public static void withCustomerGroup(final BlockingSphereClient client, final UnaryOperator<CustomerGroup> consumer) { final String name = randomString(); final String key = randomKey(); final CustomerGroupDraft customerGroupDraft = CustomerGroupDraft.of(name,key); final CustomerGroup customerGroup = client.executeBlocking(CustomerGroupCreateCommand.of(customerGroupDraft)); final CustomerGroup updatedCustomerGroup = consumer.apply(customerGroup); final Optional<CustomerGroup> customerGroupOptional = Optional.ofNullable(client.executeBlocking(CustomerGroupByIdGet.of(updatedCustomerGroup.getId()))); customerGroupOptional.ifPresent(group -> client.executeBlocking(CustomerGroupDeleteCommand.of(updatedCustomerGroup))); }
public static ShoppingListDraftDsl newShoppingListDraftWithTextLineItems() { final List<TextLineItemDraft> textLineItemDrafts = asList( TextLineItemDraftBuilder.of(en(randomString()), 1L).build(), TextLineItemDraftBuilder.of(en(randomString()), 2L).build(), TextLineItemDraftBuilder.of(en(randomString()), 3L).build()); final ShoppingListDraftDsl shoppingListDraft = newShoppingListDraftBuilder().textLineItems(textLineItemDrafts).build(); return shoppingListDraft; } public static ShoppingListDraftDsl newShoppingListDraftWithLineItems(final Product product) {
@Test public void changeName() throws Exception { withCustomerGroup(client(), customerGroup -> { final String newName = randomString(); assertThat(customerGroup.getName()).isNotEqualTo(newName); final CustomerGroup updatedCustomerGroup = client().executeBlocking(CustomerGroupUpdateCommand.of(customerGroup, ChangeName.of(newName))); assertThat(updatedCustomerGroup.getName()).isEqualTo(newName); return updatedCustomerGroup; }); } }
@Test public void setDescription() throws Exception { withUpdateableShippingMethod(client(), shippingMethod -> { final String newDescription = randomString(); assertThat(shippingMethod.getDescription()).isNotEqualTo(newDescription); final ShippingMethodUpdateCommand cmd = ShippingMethodUpdateCommand.of(shippingMethod, SetDescription.of(newDescription)); final ShippingMethod updatedShippingMethod = client().executeBlocking(cmd); assertThat(updatedShippingMethod.getDescription()).isEqualTo(newDescription); return updatedShippingMethod; }); }
@Test public void changeName() throws Exception { withUpdateableShippingMethod(client(), shippingMethod -> { final String newName = randomString(); assertThat(shippingMethod.getName()).isNotEqualTo(newName); final ShippingMethodUpdateCommand cmd = ShippingMethodUpdateCommand.of(shippingMethod, ChangeName.of(newName)); final ShippingMethod updatedShippingMethod = client().executeBlocking(cmd); assertThat(updatedShippingMethod.getName()).isEqualTo(newName); return updatedShippingMethod; }); }
@Test public void changeName() throws Exception { ZoneFixtures.withUpdateableZone(client(), zone -> { final String newName = randomString(); assertThat(zone.getName()).isNotEqualTo(newName); final ZoneUpdateCommand command = ZoneUpdateCommand.of(zone, ChangeName.of(newName)); final Zone updatedZone = client().executeBlocking(command); assertThat(updatedZone.getName()).isEqualTo(newName); return updatedZone; }, CountryCode.AM); }
public static void withUpdateableShippingMethod(final BlockingSphereClient client, final UnaryOperator<ShippingMethodDraftBuilder> builderMapper, final Function<ShippingMethod, ShippingMethod> f) { withTaxCategory(client, taxCategory -> { final ShippingMethodDraftBuilder builder = ShippingMethodDraftBuilder.of(randomString(), "test shipping method", taxCategory.toReference(), asList(), false); final ShippingMethodDraft draft = builderMapper.apply(builder).build(); final ShippingMethod shippingMethod = client.executeBlocking(ShippingMethodCreateCommand.of(draft)); final ShippingMethod possiblyUpdatedShippingMethod = f.apply(shippingMethod); client.executeBlocking(ShippingMethodDeleteCommand.of(possiblyUpdatedShippingMethod)); }); }
@Test public void changeOrderStateByOrderNumber() throws Exception { withOrder(client(), order -> { assertThat(order.getOrderState()).isEqualTo(OrderState.OPEN); final String orderNumber = randomString(); final Order orderWithOrderNumber = client().executeBlocking(OrderUpdateCommand.of(order, SetOrderNumber.of(orderNumber))); final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.ofOrderNumber(orderNumber, orderWithOrderNumber.getVersion(), ChangeOrderState.of(OrderState.COMPLETE))); assertThat(updatedOrder.getOrderState()).isEqualTo(OrderState.COMPLETE); return updatedOrder; }); }
public static void withUpdateableShoppingList(final BlockingSphereClient client, final Function<ShoppingList, ShoppingList> f){ final ShoppingListDraft draft = newShoppingListDraftBuilder() .name(en(randomString())) .description(en(randomString())) .key(randomKey()) .slug(randomSlug()).build(); final ShoppingList shoppingList = client.executeBlocking(ShoppingListCreateCommand.of(draft)); final ShoppingList possiblyUpdatedShoppingList = f.apply(shoppingList); client.executeBlocking(ShoppingListDeleteCommand.of(possiblyUpdatedShoppingList)); }
@Test public void referenceExpansion() throws Exception { withOrder(client(), order -> { assertThat(order.getOrderNumber()).isNull(); final String orderNumber = randomString(); final OrderUpdateCommand orderUpdateCommand = OrderUpdateCommand.of(order, SetOrderNumber.of(orderNumber)).plusExpansionPaths(m -> m.cart()); final Order updatedOrder = client().executeBlocking(orderUpdateCommand); assertThat(updatedOrder.getCart().getObj()).isNotNull(); return updatedOrder; }); }
@Test public void queryBySku() throws Exception { withProduct(client(), product -> { final String sku = "sku-" + randomString(); final Product productWithSku = client().executeBlocking(ProductUpdateCommand.of(product, SetSku.of(MASTER_VARIANT_ID, sku))); final QueryPredicate<ProductProjection> predicate = model().masterVariant().sku().is(sku); checkOneResult(productWithSku, predicate); }); }