-
Notifications
You must be signed in to change notification settings - Fork 15
/
OrderIntegrationTests.java
36 lines (29 loc) · 1.37 KB
/
OrderIntegrationTests.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package commercetools.order;
import com.commercetools.api.models.order.Order;
import com.commercetools.api.models.order.OrderState;
import com.commercetools.api.models.order.OrderUpdate;
import commercetools.utils.CommercetoolsTestUtils;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Test;
public class OrderIntegrationTests {
@Test
public void testOrderUpdate() {
OrdersFixtures.withUpdateableOrder(order -> {
Assertions.assertThat(order).isNotNull();
Assertions.assertThat(order.getBillingAddress()).isNull();
Order updatedOrder = CommercetoolsTestUtils.getProjectApiRoot()
.orders()
.withId(order.getId())
.post(OrderUpdate.builder()
.version(order.getVersion())
.plusActions(builder -> builder.setBillingAddressBuilder()
.address(address -> address.country("DE").state("Berlin")))
.plusActions(builder -> builder.changeOrderStateBuilder().orderState(OrderState.CONFIRMED))
.build())
.executeBlocking()
.getBody();
Assertions.assertThat(updatedOrder.getBillingAddress().getCountry()).isEqualTo("DE");
return updatedOrder;
});
}
}