Tabnine Logo
OrderUpdateCommand.of
Code IndexAdd Tabnine to your IDE (free)

How to use
of
method
in
io.sphere.sdk.orders.commands.OrderUpdateCommand

Best Java code snippets using io.sphere.sdk.orders.commands.OrderUpdateCommand.of (Showing top 20 results out of 315)

origin: io.sphere.sdk.jvm/models

  public static OrderUpdateCommand of(final Versioned<Order> order, final UpdateAction<Order> updateAction) {
    return of(order, asList(updateAction));
  }
}
origin: commercetools/commercetools-jvm-sdk

@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;
  });
}
origin: io.sphere.sdk.jvm/sphere-models

  static OrderUpdateCommand of(final Versioned<Order> order, final UpdateAction<Order> updateAction) {
    return of(order, Collections.singletonList(updateAction));
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void changeOrderState() throws Exception {
  withOrder(client(), order -> {
    assertThat(order.getOrderState()).isEqualTo(OrderState.OPEN);
    final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, ChangeOrderState.of(OrderState.COMPLETE)));
    assertThat(updatedOrder.getOrderState()).isEqualTo(OrderState.COMPLETE);
    return updatedOrder;
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void testRemoveAddressesToOrderUpdateAction() {
  withFilledCartAndMultipleAddresses(client(), cart -> {
    withCustomer(client(),customer -> {
      withOrder(client(),customer,cart,order -> {
        final List<Address> addresses = order.getItemShippingAddresses();
        final String addressKey = addresses.get(0).getKey();
        final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, RemoveItemShippingAddress.of(addressKey)));
        assertThat(updatedOrder.getItemShippingAddresses()).hasSize(addresses.size() - 1);
        assertThat(updatedOrder.getItemShippingAddresses().stream().filter(address -> addressKey.equals(address.getKey())).collect(Collectors.toList())).isEmpty();
        return updatedOrder;
      });
    });
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void setReturnPaymentState() throws Exception {
  withOrderAndReturnInfo(client(), (order, returnInfo) -> {
    final ReturnItem returnItem = returnInfo.getItems().get(0);
    final ReturnPaymentState newPaymentState = ReturnPaymentState.REFUNDED;
    assertThat(returnItem.getPaymentState()).isNotEqualTo(newPaymentState);
    final SetReturnPaymentState action = SetReturnPaymentState.of(returnItem, newPaymentState);
    final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, action));
    final ReturnPaymentState updatedPaymentState = updatedOrder.getReturnInfo().get(0).getItems().get(0).getPaymentState();
    assertThat(updatedPaymentState).isEqualTo(newPaymentState);
    return updatedOrder;
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void locale() {
  withOrder(client(), order -> {
    assertThat(order.getLocale()).isNull();
    final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, SetLocale.of(Locale.GERMAN)));
    assertThat(updatedOrder.getLocale()).isEqualTo(GERMAN);
    return updatedOrder;
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void changePaymentState() throws Exception {
  withOrder(client(), order -> {
    final PaymentState newState = PaymentState.PAID;
    assertThat(order.getPaymentState()).isNotEqualTo(newState);
    final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, ChangePaymentState.of(newState)));
    assertThat(updatedOrder.getPaymentState()).isEqualTo(newState);
    return updatedOrder;
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void testAddAddressesToCartUpdateAction() {
  final List<Address> addressList = createAddressArray();
  withFilledCart(client(), cart -> {
    withCustomer(client(),customer -> {
      withOrder(client(),customer,cart,order -> {
        assertThat(order.getItemShippingAddresses()).isEmpty();
        List<UpdateAction<Order>> addAddresses = addressList.stream().map(AddItemShippingAddress::of).collect(Collectors.toList());
        Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order,addAddresses ));
        assertThat(updatedOrder.getItemShippingAddresses()).hasSameSizeAs(addressList);
        return updatedOrder;
      });
    });
  });
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void setOrderNumber() throws Exception {
  withOrder(client(), order -> {
    assertThat(order.getOrderNumber()).isNull();
    final String orderNumber = randomString();
    final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, SetOrderNumber.of(orderNumber)));
    assertThat(updatedOrder.getOrderNumber()).isEqualTo(orderNumber);
    return updatedOrder;
  });
}
origin: commercetools/commercetools-jvm-sdk

  public static void withOrderAndReturnInfo(final BlockingSphereClient client, final BiFunction<Order, ReturnInfo, Order> f) {
    withOrder(client, order -> {
      Assertions.assertThat(order.getReturnInfo()).isEmpty();
      final String lineItemId = order.getLineItems().get(0).getId();
      final List<LineItemReturnItemDraft> items = asList(LineItemReturnItemDraft.of(1L, lineItemId, ReturnShipmentState.RETURNED, "foo bar"));
      final AddReturnInfo action = AddReturnInfo.of(items);
      final AddDelivery addDelivery = AddDelivery.of(asList(DeliveryItem.of(lineItemId, 1)));
      final Order updatedOrder = client.executeBlocking(OrderUpdateCommand.of(order, asList(action, addDelivery)));

      final ReturnInfo returnInfo = updatedOrder.getReturnInfo().get(0);
      return f.apply(updatedOrder, returnInfo);
    });
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void setCustomType() {
  withUpdateableType(client(), type -> {
    withOrder(client(), order -> {
      final Order orderWithType = client().executeBlocking(OrderUpdateCommand.of(order, SetCustomType.ofTypeIdAndObjects(type.getId(), CUSTOM_FIELDS_MAP)));
      assertThat(orderWithType.getCustom().getType()).isEqualTo(type.toReference());
      assertThat(orderWithType.getCustom().getField(STRING_FIELD_NAME, TypeReferences.stringTypeReference())).isEqualTo("hello");
      final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(orderWithType, SetCustomField.ofObject(STRING_FIELD_NAME, "other")));
      assertThat(updatedOrder.getCustom().getField(STRING_FIELD_NAME, TypeReferences.stringTypeReference())).isEqualTo("other");
      //test clean up
      return client().executeBlocking(OrderUpdateCommand.of(updatedOrder, SetCustomType.ofRemoveType()));
    });
    return type;
  });
}
origin: commercetools/commercetools-jvm-sdk

@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;
  });
}
origin: commercetools/commercetools-jvm-sdk

  @Test
  public void execution() throws Exception {
    withOrder(client(), order -> {
      final String orderNumber = randomString();
      final Order orderWithOrderNumber = client().executeBlocking(OrderUpdateCommand.of(order,
          SetOrderNumber.of(orderNumber)));
      final Order loadedOrder = client().executeBlocking(OrderByOrderNumberGet.of(orderNumber));

      assertThat(loadedOrder.getOrderNumber()).isEqualTo(orderNumber);
      return orderWithOrderNumber;
    });
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void importCustomLineItemState() throws Exception {
  withStandardStates(client(), (State initialState, State nextState) ->
    withOrderOfCustomLineItems(client(), order -> {
      final CustomLineItem customLineItem = order.getCustomLineItems().get(0);
      assertThat(customLineItem).has(state(initialState)).has(not(state(nextState)));
      final Set<ItemState> itemStates = asSet(ItemState.of(nextState, 1L), ItemState.of(initialState, customLineItem.getQuantity() - 1));
      final Order updatedOrder = client().executeBlocking(OrderUpdateCommand.of(order, ImportCustomLineItemState.of(customLineItem, itemStates)));
      assertThat(updatedOrder.getCustomLineItems().get(0)).has(itemStates(itemStates));
    })
  );
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void orderNumber() throws Exception {
  assertOrderIsFoundWithPredicate(
      order -> client().executeBlocking(OrderUpdateCommand.of(order, SetOrderNumber.of(randomKey()))),
      order -> MODEL.orderNumber().is(order.getOrderNumber()));
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void deleteByOrderNumber() throws Exception {
  withOrder(client(), order -> {
    final String orderNumber = randomString();
    final Order orderWithOrderNumber = client().executeBlocking(OrderUpdateCommand.of(order, SetOrderNumber.of(orderNumber)));
    final Order deletedOrder = client().executeBlocking(OrderDeleteCommand.ofOrderNumber(orderNumber, orderWithOrderNumber.getVersion()));
    final Order queriedDeletedOrder = client().executeBlocking(OrderByIdGet.of(deletedOrder));
    assertThat(queriedDeletedOrder).isNull();
  });
}
origin: commercetools/commercetools-jvm-sdk

  @Test
  public void deleteByOrderNumberEraseData() throws Exception {
    withOrder(client(), order -> {
      final String orderNumber = randomString();
      final Order orderWithOrderNumber = client().executeBlocking(OrderUpdateCommand.of(order, SetOrderNumber.of(orderNumber)));

      final Order deletedOrder = client().executeBlocking(OrderDeleteCommand.ofOrderNumber(orderNumber, orderWithOrderNumber.getVersion(),true));
      final Order queriedDeletedOrder = client().executeBlocking(OrderByIdGet.of(deletedOrder));
      assertThat(queriedDeletedOrder).isNull();
    });
  }
}
origin: commercetools/commercetools-jvm-sdk

private static Order createOrderFromCart(BlockingSphereClient client, Customer customer, Cart cart) {
  final TaxCategory taxCategory = TaxCategoryFixtures.defaultTaxCategory(client);
  final SetCustomShippingMethod shippingMethodAction = SetCustomShippingMethod.of("custom shipping method", ShippingRate.of(EURO_10), taxCategory);
  final SetCustomerEmail emailAction = SetCustomerEmail.of(CUSTOMER_EMAIL);
  client.executeBlocking(CartUpdateCommand.of(cart, asList(shippingMethodAction, emailAction)));
  final CustomerSignInCommand signInCommand = CustomerSignInCommand.of(customer.getEmail(), CustomerFixtures.PASSWORD, cart.getId());
  final CustomerSignInResult signInResult = client.executeBlocking(signInCommand);
  final Order order = client.executeBlocking(OrderFromCartCreateCommand.of(signInResult.getCart()));
  return client.executeBlocking(OrderUpdateCommand.of(order, asList(
      ChangeShipmentState.of(ShipmentState.READY),
      ChangePaymentState.of(PaymentState.PENDING)
  )));
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void syncInfo() throws Exception {
  final Channel channel = persistentChannelOfRole(client(), ORDER_EXPORT);
  final String externalId = randomKey();
  assertOrderIsFoundWithPredicate(
      order -> client().executeBlocking(OrderUpdateCommand.of(order, UpdateSyncInfo.of(channel).withExternalId(externalId))),
      order -> MODEL.syncInfo().channel().is(channel).and(MODEL.syncInfo().externalId().is(externalId)).and(MODEL.syncInfo().isNotEmpty()));
}
io.sphere.sdk.orders.commandsOrderUpdateCommandof

Javadoc

Creates a command to update a Order selected by its ID using one update action.

Popular methods of OrderUpdateCommand

  • ofOrderNumber
    Creates a command to update a Order selected by its orderNumber using several update actions.
  • <init>
  • plusExpansionPaths
  • withExpansionPaths

Popular in Java

  • Creating JSON documents from java classes using gson
  • getApplicationContext (Context)
  • runOnUiThread (Activity)
  • setContentView (Activity)
  • BufferedWriter (java.io)
    Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Table (org.hibernate.mapping)
    A relational table
  • Runner (org.openjdk.jmh.runner)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now