Merge pull request #3075 from cbornet/feign_joda

[Feign] Support joda dates in feign client and use it in petstore sample
This commit is contained in:
wing328 2016-06-09 01:28:10 +08:00
commit c11908824e
33 changed files with 75 additions and 91 deletions

View File

@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-feign.json -o samples/client/petstore/java/feign"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l java -c bin/java-petstore-feign.json -o samples/client/petstore/java/feign -DdateLibrary=joda"
java $JAVA_OPTS -jar $executable $ags

View File

@ -9,6 +9,7 @@ import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuil
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import feign.Feign;
import feign.RequestInterceptor;
@ -129,6 +130,8 @@ public class ApiClient {
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.registerModule(new JodaModule());
return objectMapper;
}

View File

@ -149,19 +149,7 @@
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
</dependency>
<!-- Base64 encoding that works in both JVM and Android -->
<dependency>
<groupId>com.brsanthu</groupId>
<artifactId>migbase64</artifactId>
<version>2.2</version>
<version>${jackson-version}</version>
</dependency>
<dependency>

View File

@ -100,8 +100,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
@ -149,19 +149,7 @@
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-joda</artifactId>
<version>2.1.5</version>
</dependency>
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>${jodatime-version}</version>
</dependency>
<!-- Base64 encoding that works in both JVM and Android -->
<dependency>
<groupId>com.brsanthu</groupId>
<artifactId>migbase64</artifactId>
<version>2.2</version>
<version>${jackson-version}</version>
</dependency>
<dependency>

View File

@ -9,6 +9,7 @@ import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuil
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import feign.Feign;
import feign.RequestInterceptor;
@ -18,11 +19,11 @@ import feign.slf4j.Slf4jLogger;
import io.swagger.client.auth.*;
import io.swagger.client.auth.OAuth.AccessTokenListener;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-02-17T17:16:23.375+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class ApiClient {
public interface Api {}
private ObjectMapper objectMapper;
protected ObjectMapper objectMapper;
private String basePath = "http://petstore.swagger.io/v2";
private Map<String, RequestInterceptor> apiAuthorizations;
private Feign.Builder feignBuilder;
@ -42,16 +43,8 @@ public class ApiClient {
RequestInterceptor auth;
if (authName == "petstore_auth") {
auth = new OAuth(OAuthFlow.implicit, "http://petstore.swagger.io/api/oauth/dialog", "", "write:pets, read:pets");
} else if (authName == "test_api_client_id") {
auth = new ApiKeyAuth("header", "x-test_api_client_id");
} else if (authName == "test_api_client_secret") {
auth = new ApiKeyAuth("header", "x-test_api_client_secret");
} else if (authName == "api_key") {
auth = new ApiKeyAuth("header", "api_key");
} else if (authName == "test_api_key_query") {
auth = new ApiKeyAuth("query", "test_api_key_query");
} else if (authName == "test_api_key_header") {
auth = new ApiKeyAuth("header", "test_api_key_header");
} else {
throw new RuntimeException("auth name \"" + authName + "\" not found in available auth names");
}
@ -135,6 +128,13 @@ public class ApiClient {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
objectMapper.registerModule(new JodaModule());
return objectMapper;
}
public ObjectMapper getObjectMapper(){
return objectMapper;
}

View File

@ -14,7 +14,7 @@ import feign.codec.EncodeException;
import feign.codec.Encoder;
import feign.RequestTemplate;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class FormAwareEncoder implements Encoder {
public static final String UTF_8 = "utf-8";
private static final String LINE_FEED = "\r\n";

View File

@ -1,6 +1,6 @@
package io.swagger.client;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).

View File

@ -2,8 +2,9 @@ package io.swagger.client.api;
import io.swagger.client.ApiClient;
import org.joda.time.LocalDate;
import java.math.BigDecimal;
import java.util.Date;
import org.joda.time.DateTime;
import java.util.ArrayList;
import java.util.HashMap;
@ -11,7 +12,7 @@ import java.util.List;
import java.util.Map;
import feign.*;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public interface FakeApi extends ApiClient.Api {
@ -37,5 +38,5 @@ public interface FakeApi extends ApiClient.Api {
"Content-type: application/xml; charset&#x3D;utf-8",
"Accept: application/xml; charset&#x3D;utf-8,application/json; charset&#x3D;utf-8",
})
void testEndpointParameters(@Param("number") BigDecimal number, @Param("_double") Double _double, @Param("string") String string, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("binary") byte[] binary, @Param("date") Date date, @Param("dateTime") Date dateTime, @Param("password") String password);
void testEndpointParameters(@Param("number") BigDecimal number, @Param("_double") Double _double, @Param("string") String string, @Param("_byte") byte[] _byte, @Param("integer") Integer integer, @Param("int32") Integer int32, @Param("int64") Long int64, @Param("_float") Float _float, @Param("binary") byte[] binary, @Param("date") LocalDate date, @Param("dateTime") DateTime dateTime, @Param("password") String password);
}

View File

@ -12,7 +12,7 @@ import java.util.List;
import java.util.Map;
import feign.*;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public interface PetApi extends ApiClient.Api {

View File

@ -10,7 +10,7 @@ import java.util.List;
import java.util.Map;
import feign.*;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public interface StoreApi extends ApiClient.Api {

View File

@ -10,7 +10,7 @@ import java.util.List;
import java.util.Map;
import feign.*;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public interface UserApi extends ApiClient.Api {

View File

@ -13,7 +13,7 @@ import java.util.Map;
/**
* AdditionalPropertiesClass
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class AdditionalPropertiesClass {
private Map<String, String> mapProperty = new HashMap<String, String>();

View File

@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* Animal
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class Animal {
private String className = null;

View File

@ -10,7 +10,7 @@ import java.util.List;
/**
* AnimalFarm
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class AnimalFarm extends ArrayList<Animal> {

View File

@ -12,7 +12,7 @@ import java.util.List;
/**
* ArrayTest
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class ArrayTest {
private List<String> arrayOfString = new ArrayList<String>();

View File

@ -11,7 +11,7 @@ import io.swagger.client.model.Animal;
/**
* Cat
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class Cat extends Animal {
private String className = null;

View File

@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* Category
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class Category {
private Long id = null;

View File

@ -11,7 +11,7 @@ import io.swagger.client.model.Animal;
/**
* Dog
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class Dog extends Animal {
private String className = null;

View File

@ -11,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* EnumTest
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class EnumTest {

View File

@ -6,13 +6,14 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.util.Date;
import org.joda.time.DateTime;
import org.joda.time.LocalDate;
/**
* FormatTest
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class FormatTest {
private Integer integer = null;
@ -24,8 +25,8 @@ public class FormatTest {
private String string = null;
private byte[] _byte = null;
private byte[] binary = null;
private Date date = null;
private Date dateTime = null;
private LocalDate date = null;
private DateTime dateTime = null;
private String uuid = null;
private String password = null;
@ -195,34 +196,34 @@ public class FormatTest {
/**
**/
public FormatTest date(Date date) {
public FormatTest date(LocalDate date) {
this.date = date;
return this;
}
@ApiModelProperty(example = "null", required = true, value = "")
@JsonProperty("date")
public Date getDate() {
public LocalDate getDate() {
return date;
}
public void setDate(Date date) {
public void setDate(LocalDate date) {
this.date = date;
}
/**
**/
public FormatTest dateTime(Date dateTime) {
public FormatTest dateTime(DateTime dateTime) {
this.dateTime = dateTime;
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("dateTime")
public Date getDateTime() {
public DateTime getDateTime() {
return dateTime;
}
public void setDateTime(Date dateTime) {
public void setDateTime(DateTime dateTime) {
this.dateTime = dateTime;
}

View File

@ -6,20 +6,20 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.client.model.Animal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.joda.time.DateTime;
/**
* MixedPropertiesAndAdditionalPropertiesClass
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class MixedPropertiesAndAdditionalPropertiesClass {
private String uuid = null;
private Date dateTime = null;
private DateTime dateTime = null;
private Map<String, Animal> map = new HashMap<String, Animal>();
@ -42,17 +42,17 @@ public class MixedPropertiesAndAdditionalPropertiesClass {
/**
**/
public MixedPropertiesAndAdditionalPropertiesClass dateTime(Date dateTime) {
public MixedPropertiesAndAdditionalPropertiesClass dateTime(DateTime dateTime) {
this.dateTime = dateTime;
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("dateTime")
public Date getDateTime() {
public DateTime getDateTime() {
return dateTime;
}
public void setDateTime(Date dateTime) {
public void setDateTime(DateTime dateTime) {
this.dateTime = dateTime;
}

View File

@ -11,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
* Model for testing model name starting with number
*/
@ApiModel(description = "Model for testing model name starting with number")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class Model200Response {
private Integer name = null;

View File

@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* ModelApiResponse
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class ModelApiResponse {
private Integer code = null;

View File

@ -11,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
* Model for testing reserved words
*/
@ApiModel(description = "Model for testing reserved words")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class ModelReturn {
private Integer _return = null;

View File

@ -11,7 +11,7 @@ import io.swagger.annotations.ApiModelProperty;
* Model for testing model name same as property name
*/
@ApiModel(description = "Model for testing model name same as property name")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class Name {
private Integer name = null;

View File

@ -6,19 +6,19 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
import org.joda.time.DateTime;
/**
* Order
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class Order {
private Long id = null;
private Long petId = null;
private Integer quantity = null;
private Date shipDate = null;
private DateTime shipDate = null;
/**
* Order Status
@ -98,17 +98,17 @@ public class Order {
/**
**/
public Order shipDate(Date shipDate) {
public Order shipDate(DateTime shipDate) {
this.shipDate = shipDate;
return this;
}
@ApiModelProperty(example = "null", value = "")
@JsonProperty("shipDate")
public Date getShipDate() {
public DateTime getShipDate() {
return shipDate;
}
public void setShipDate(Date shipDate) {
public void setShipDate(DateTime shipDate) {
this.shipDate = shipDate;
}

View File

@ -15,7 +15,7 @@ import java.util.List;
/**
* Pet
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class Pet {
private Long id = null;

View File

@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* ReadOnlyFirst
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class ReadOnlyFirst {
private String bar = null;

View File

@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* SpecialModelName
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class SpecialModelName {
private Long specialPropertyName = null;

View File

@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* Tag
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class Tag {
private Long id = null;

View File

@ -10,7 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
/**
* User
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-04T22:20:02.809+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2016-06-07T22:38:14.473+02:00")
public class User {
private Long id = null;

View File

@ -1,8 +1,9 @@
package io.swagger.client.api;
import io.swagger.client.ApiClient;
import org.joda.time.LocalDate;
import java.math.BigDecimal;
import java.util.Date;
import org.joda.time.DateTime;
import org.junit.Before;
import org.junit.Test;
@ -40,8 +41,8 @@ public class FakeApiTest {
Long int64 = null;
Float _float = null;
byte[] binary = null;
Date date = null;
Date dateTime = null;
LocalDate date = null;
DateTime dateTime = null;
String password = null;
// api.testEndpointParameters(number, _double, string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);

View File

@ -4,13 +4,14 @@ import feign.FeignException;
import io.swagger.TestUtils;
import io.swagger.client.*;
import io.swagger.client.ApiClient;
import io.swagger.client.api.*;
import io.swagger.client.model.*;
import java.lang.reflect.Field;
import java.util.Map;
import org.joda.time.DateTimeZone;
import org.junit.*;
import static org.junit.Assert.*;
@ -39,6 +40,7 @@ public class StoreApiTest {
assertEquals(order.getId(), fetched.getId());
assertEquals(order.getPetId(), fetched.getPetId());
assertEquals(order.getQuantity(), fetched.getQuantity());
assertEquals(order.getShipDate().withZone(DateTimeZone.UTC), fetched.getShipDate().withZone(DateTimeZone.UTC));
}
@Test
@ -63,7 +65,7 @@ public class StoreApiTest {
Order order = new Order();
order.setPetId(new Long(200));
order.setQuantity(new Integer(13));
order.setShipDate(new java.util.Date());
order.setShipDate(org.joda.time.DateTime.now());
order.setStatus(Order.StatusEnum.PLACED);
order.setComplete(true);