BAEL-430: Added performance tests for mapping frameworks (#4092)
* BAEL-430: Added performance tests for mapping frameworks * Fixes * Removed @Test annotation.
This commit is contained in:
parent
1d0a6248e5
commit
0dfaafac5c
|
@ -0,0 +1,79 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>performancetests</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ma.glasnost.orika</groupId>
|
||||
<artifactId>orika-core</artifactId>
|
||||
<version>1.5.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.sf.dozer</groupId>
|
||||
<artifactId>dozer</artifactId>
|
||||
<version>5.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.craftsman</groupId>
|
||||
<artifactId>dozer-jdk8-support</artifactId>
|
||||
<version>1.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-jdk8</artifactId>
|
||||
<version>1.2.0.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.modelmapper</groupId>
|
||||
<artifactId>modelmapper</artifactId>
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.googlecode.jmapper-framework</groupId>
|
||||
<artifactId>jmapper-core</artifactId>
|
||||
<version>1.6.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-core</artifactId>
|
||||
<version>1.20</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjdk.jmh</groupId>
|
||||
<artifactId>jmh-generator-annprocess</artifactId>
|
||||
<version>1.20</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.5.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>1.2.0.Final</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,11 @@
|
|||
package com.baeldung.performancetests;
|
||||
|
||||
import com.baeldung.performancetests.model.destination.DestinationCode;
|
||||
import com.baeldung.performancetests.model.source.SourceCode;
|
||||
import com.baeldung.performancetests.model.source.SourceOrder;
|
||||
import com.baeldung.performancetests.model.destination.Order;
|
||||
|
||||
public interface Converter {
|
||||
Order convert(SourceOrder sourceOrder);
|
||||
DestinationCode convert(SourceCode sourceCode);
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.baeldung.performancetests.dozer;
|
||||
|
||||
import com.baeldung.performancetests.Converter;
|
||||
import com.baeldung.performancetests.model.destination.DestinationCode;
|
||||
import com.baeldung.performancetests.model.source.SourceCode;
|
||||
import com.baeldung.performancetests.model.source.SourceOrder;
|
||||
import com.baeldung.performancetests.model.destination.Order;
|
||||
import org.dozer.DozerBeanMapper;
|
||||
import org.dozer.Mapper;
|
||||
|
||||
public class DozerConverter implements Converter {
|
||||
private final Mapper mapper;
|
||||
|
||||
public DozerConverter() {
|
||||
DozerBeanMapper mapper = new DozerBeanMapper();
|
||||
mapper.addMapping(DozerConverter.class.getResourceAsStream("/dozer-mapping.xml"));
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order convert(SourceOrder sourceOrder) {
|
||||
return mapper.map(sourceOrder,Order.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DestinationCode convert(SourceCode sourceCode) {
|
||||
return mapper.map(sourceCode, DestinationCode.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.baeldung.performancetests.jmapper;
|
||||
|
||||
import com.baeldung.performancetests.Converter;
|
||||
import com.baeldung.performancetests.model.destination.DestinationCode;
|
||||
import com.baeldung.performancetests.model.source.SourceCode;
|
||||
import com.baeldung.performancetests.model.source.SourceOrder;
|
||||
import com.baeldung.performancetests.model.destination.Order;
|
||||
import com.googlecode.jmapper.JMapper;
|
||||
import com.googlecode.jmapper.api.JMapperAPI;
|
||||
|
||||
public class JMapperConverter implements Converter {
|
||||
JMapper realLifeMapper;
|
||||
JMapper simpleMapper;
|
||||
public JMapperConverter() {
|
||||
JMapperAPI api = new JMapperAPI().add(JMapperAPI.mappedClass(Order.class));
|
||||
realLifeMapper = new JMapper(Order.class, SourceOrder.class, api);
|
||||
JMapperAPI simpleApi = new JMapperAPI().add(JMapperAPI.mappedClass(DestinationCode.class));
|
||||
simpleMapper = new JMapper(DestinationCode.class, SourceCode.class, simpleApi);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order convert(SourceOrder sourceOrder) {
|
||||
return (Order) realLifeMapper.getDestination(sourceOrder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DestinationCode convert(SourceCode sourceCode) {
|
||||
return (DestinationCode) simpleMapper.getDestination(sourceCode);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.baeldung.performancetests.mapstruct;
|
||||
|
||||
import com.baeldung.performancetests.Converter;
|
||||
import com.baeldung.performancetests.model.destination.DestinationCode;
|
||||
import com.baeldung.performancetests.model.source.SourceCode;
|
||||
import com.baeldung.performancetests.model.source.SourceOrder;
|
||||
import com.baeldung.performancetests.model.destination.Order;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mapping;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface MapStructConverter extends Converter {
|
||||
MapStructConverter MAPPER = Mappers.getMapper(MapStructConverter.class);
|
||||
|
||||
@Mapping(source = "status", target = "orderStatus")
|
||||
@Override
|
||||
Order convert(SourceOrder sourceOrder);
|
||||
|
||||
@Override
|
||||
DestinationCode convert(SourceCode sourceCode);
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package com.baeldung.performancetests.model.destination;
|
||||
|
||||
public enum AccountStatus {
|
||||
ACTIVE, NOT_ACTIVE, BANNED
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.baeldung.performancetests.model.destination;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@JGlobalMap
|
||||
public class Address {
|
||||
private String street;
|
||||
private String city;
|
||||
private String postalCode;
|
||||
|
||||
public Address() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null) return false;
|
||||
if(o.getClass() == com.baeldung.performancetests.model.source.Address.class) {
|
||||
com.baeldung.performancetests.model.source.Address address =
|
||||
(com.baeldung.performancetests.model.source.Address) o;
|
||||
return Objects.equals(street, address.getStreet()) &&
|
||||
Objects.equals(city, address.getCity()) &&
|
||||
Objects.equals(postalCode, address.getPostalCode()) &&
|
||||
Objects.equals(country, address.getCountry());
|
||||
}
|
||||
if(o.getClass() != getClass()) return false;
|
||||
Address address = (Address) o;
|
||||
return Objects.equals(street, address.street) &&
|
||||
Objects.equals(city, address.city) &&
|
||||
Objects.equals(postalCode, address.postalCode) &&
|
||||
Objects.equals(country, address.country);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return Objects.hash(street, city, postalCode, country);
|
||||
}
|
||||
|
||||
private String country;
|
||||
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getPostalCode() {
|
||||
return postalCode;
|
||||
}
|
||||
|
||||
public void setPostalCode(String postalCode) {
|
||||
this.postalCode = postalCode;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public Address(String street, String city, String postalCode, String country) {
|
||||
|
||||
this.street = street;
|
||||
this.city = city;
|
||||
this.postalCode = postalCode;
|
||||
this.country = country;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.baeldung.performancetests.model.destination;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
import com.googlecode.jmapper.annotations.JMapAccessor;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@JGlobalMap
|
||||
public class DeliveryData {
|
||||
private Address deliveryAddress;
|
||||
@JMapAccessor(get = "isPrePaid", set = "setPrePaid")
|
||||
private boolean isPrePaid;
|
||||
private String trackingCode;
|
||||
private int expectedDeliveryTimeInDays;
|
||||
|
||||
public DeliveryData() {
|
||||
}
|
||||
|
||||
public Address getDeliveryAddress() {
|
||||
return deliveryAddress;
|
||||
}
|
||||
|
||||
public void setDeliveryAddress(Address deliveryAddress) {
|
||||
this.deliveryAddress = deliveryAddress;
|
||||
}
|
||||
|
||||
public boolean isPrePaid() {
|
||||
return isPrePaid;
|
||||
}
|
||||
|
||||
public void setPrePaid(boolean prePaid) {
|
||||
isPrePaid = prePaid;
|
||||
}
|
||||
|
||||
public String getTrackingCode() {
|
||||
return trackingCode;
|
||||
}
|
||||
|
||||
public void setTrackingCode(String trackingCode) {
|
||||
this.trackingCode = trackingCode;
|
||||
}
|
||||
|
||||
public int getExpectedDeliveryTimeInDays() {
|
||||
return expectedDeliveryTimeInDays;
|
||||
}
|
||||
|
||||
public void setExpectedDeliveryTimeInDays(int expectedDeliveryTimeInDays) {
|
||||
this.expectedDeliveryTimeInDays = expectedDeliveryTimeInDays;
|
||||
}
|
||||
|
||||
public DeliveryData(Address deliveryAddress, boolean isPrePaid, String trackingCode, int expectedDeliveryTimeInDays) {
|
||||
this.deliveryAddress = deliveryAddress;
|
||||
this.isPrePaid = isPrePaid;
|
||||
this.trackingCode = trackingCode;
|
||||
this.expectedDeliveryTimeInDays = expectedDeliveryTimeInDays;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null) return false;
|
||||
if(o.getClass() == com.baeldung.performancetests.model.source.DeliveryData.class) {
|
||||
com.baeldung.performancetests.model.source.DeliveryData deliveryData =
|
||||
(com.baeldung.performancetests.model.source.DeliveryData) o;
|
||||
return isPrePaid == deliveryData.isPrePaid() &&
|
||||
expectedDeliveryTimeInDays == deliveryData.getExpectedDeliveryTimeInDays() &&
|
||||
Objects.equals(deliveryAddress, deliveryData.getDeliveryAddress()) &&
|
||||
Objects.equals(trackingCode, deliveryData.getTrackingCode());
|
||||
}
|
||||
if (o.getClass() != getClass()) return false;
|
||||
DeliveryData that = (DeliveryData) o;
|
||||
return isPrePaid == that.isPrePaid &&
|
||||
expectedDeliveryTimeInDays == that.expectedDeliveryTimeInDays &&
|
||||
Objects.equals(deliveryAddress, that.deliveryAddress) &&
|
||||
Objects.equals(trackingCode, that.trackingCode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return Objects.hash(deliveryAddress, isPrePaid, trackingCode, expectedDeliveryTimeInDays);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.baeldung.performancetests.model.destination;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JMap;
|
||||
|
||||
public class DestinationCode {
|
||||
@JMap
|
||||
String code;
|
||||
|
||||
public DestinationCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public DestinationCode() {
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.baeldung.performancetests.model.destination;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@JGlobalMap
|
||||
public class Discount {
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private BigDecimal discountPrice;
|
||||
|
||||
public Discount() {
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null) return false;
|
||||
if (o.getClass() == com.baeldung.performancetests.model.source.Discount.class) {
|
||||
com.baeldung.performancetests.model.source.Discount discount =
|
||||
(com.baeldung.performancetests.model.source.Discount) o;
|
||||
return Objects.equal(startTime, discount.getStartTime()) &&
|
||||
Objects.equal(endTime, discount.getEndTime()) &&
|
||||
Objects.equal(discountPrice, discount.getDiscountPrice());
|
||||
}
|
||||
if(o.getClass() != getClass()) return false;
|
||||
Discount discount = (Discount) o;
|
||||
return Objects.equal(startTime, discount.startTime) &&
|
||||
Objects.equal(endTime, discount.endTime) &&
|
||||
Objects.equal(discountPrice, discount.discountPrice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(startTime, endTime, discountPrice);
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public BigDecimal getDiscountPrice() {
|
||||
return discountPrice;
|
||||
}
|
||||
|
||||
public void setDiscountPrice(BigDecimal discountPrice) {
|
||||
this.discountPrice = discountPrice;
|
||||
}
|
||||
|
||||
public Discount(String startTime, String endTime, BigDecimal discountPrice) {
|
||||
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
this.discountPrice = discountPrice;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,210 @@
|
|||
package com.baeldung.performancetests.model.destination;
|
||||
|
||||
import com.baeldung.performancetests.model.source.SourceOrder;
|
||||
import com.google.common.base.Objects;
|
||||
import com.googlecode.jmapper.annotations.JMap;
|
||||
import com.googlecode.jmapper.annotations.JMapConversion;
|
||||
|
||||
import java.util.List;
|
||||
public class Order {
|
||||
@JMap
|
||||
private User orderingUser;
|
||||
@JMap
|
||||
private List<Product> orderedProducts;
|
||||
@JMap("status")
|
||||
private OrderStatus orderStatus;
|
||||
@JMap
|
||||
private String orderDate;
|
||||
@JMap
|
||||
private String orderFinishDate;
|
||||
@JMap
|
||||
private PaymentType paymentType;
|
||||
@JMap
|
||||
private Discount discount;
|
||||
@JMap
|
||||
private int orderId;
|
||||
@JMap
|
||||
private DeliveryData deliveryData;
|
||||
@JMap
|
||||
private Shop offeringShop;
|
||||
|
||||
public Order() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null) return false;
|
||||
if (o.getClass() == SourceOrder.class) {
|
||||
SourceOrder order =
|
||||
(SourceOrder) o;
|
||||
return Objects.equal(orderingUser, order.getOrderingUser()) &&
|
||||
Objects.equal(orderedProducts, order.getOrderedProducts()) &&
|
||||
orderStatus.ordinal() == order.getStatus().ordinal() &&
|
||||
Objects.equal(orderDate, order.getOrderDate()) &&
|
||||
Objects.equal(orderFinishDate, order.getOrderFinishDate()) &&
|
||||
paymentType.ordinal() == order.getPaymentType().ordinal() &&
|
||||
Objects.equal(discount, order.getDiscount()) &&
|
||||
Objects.equal(deliveryData, order.getDeliveryData());
|
||||
}
|
||||
if (o.getClass() != getClass()) return false;
|
||||
Order order = (Order) o;
|
||||
return Objects.equal(orderingUser, order.orderingUser) &&
|
||||
Objects.equal(orderedProducts, order.orderedProducts) &&
|
||||
orderStatus == order.orderStatus &&
|
||||
Objects.equal(orderDate, order.orderDate) &&
|
||||
Objects.equal(orderFinishDate, order.orderFinishDate) &&
|
||||
paymentType == order.paymentType &&
|
||||
Objects.equal(discount, order.discount) &&
|
||||
Objects.equal(deliveryData, order.deliveryData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(orderingUser, orderedProducts, orderStatus, orderDate, orderFinishDate, paymentType, discount, deliveryData);
|
||||
}
|
||||
|
||||
public User getOrderingUser() {
|
||||
return orderingUser;
|
||||
}
|
||||
|
||||
public void setOrderingUser(User orderingUser) {
|
||||
this.orderingUser = orderingUser;
|
||||
}
|
||||
|
||||
public List<Product> getOrderedProducts() {
|
||||
return orderedProducts;
|
||||
}
|
||||
|
||||
public void setOrderedProducts(List<Product> orderedProducts) {
|
||||
this.orderedProducts = orderedProducts;
|
||||
}
|
||||
|
||||
public OrderStatus getOrderStatus() {
|
||||
return orderStatus;
|
||||
}
|
||||
|
||||
public void setOrderStatus(OrderStatus status) {
|
||||
this.orderStatus = status;
|
||||
}
|
||||
|
||||
public String getOrderDate() {
|
||||
return orderDate;
|
||||
}
|
||||
|
||||
public void setOrderDate(String orderDate) {
|
||||
this.orderDate = orderDate;
|
||||
}
|
||||
|
||||
public String getOrderFinishDate() {
|
||||
return orderFinishDate;
|
||||
}
|
||||
|
||||
public void setOrderFinishDate(String orderFinishDate) {
|
||||
this.orderFinishDate = orderFinishDate;
|
||||
}
|
||||
|
||||
public PaymentType getPaymentType() {
|
||||
return paymentType;
|
||||
}
|
||||
|
||||
public void setPaymentType(PaymentType paymentType) {
|
||||
this.paymentType = paymentType;
|
||||
}
|
||||
|
||||
public Discount getDiscount() {
|
||||
return discount;
|
||||
}
|
||||
|
||||
public void setDiscount(Discount discount) {
|
||||
this.discount = discount;
|
||||
}
|
||||
|
||||
public DeliveryData getDeliveryData() {
|
||||
return deliveryData;
|
||||
}
|
||||
|
||||
public void setDeliveryData(DeliveryData deliveryData) {
|
||||
this.deliveryData = deliveryData;
|
||||
}
|
||||
|
||||
|
||||
public int getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(int orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public Order(User orderingUser, List<Product> orderedProducts, OrderStatus orderStatus, String orderDate, String orderFinishDate, PaymentType paymentType, Discount discount, int orderId, DeliveryData deliveryData, Shop offeringShop) {
|
||||
|
||||
this.orderingUser = orderingUser;
|
||||
this.orderedProducts = orderedProducts;
|
||||
this.orderStatus = orderStatus;
|
||||
this.orderDate = orderDate;
|
||||
this.orderFinishDate = orderFinishDate;
|
||||
this.paymentType = paymentType;
|
||||
this.discount = discount;
|
||||
this.orderId = orderId;
|
||||
this.deliveryData = deliveryData;
|
||||
this.offeringShop = offeringShop;
|
||||
}
|
||||
|
||||
public Shop getOfferingShop() {
|
||||
return offeringShop;
|
||||
}
|
||||
|
||||
public void setOfferingShop(Shop offeringShop) {
|
||||
this.offeringShop = offeringShop;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@JMapConversion(from = "status", to = "orderStatus")
|
||||
public OrderStatus conversion(com.baeldung.performancetests.model.source.OrderStatus status) {
|
||||
OrderStatus orderStatus = null;
|
||||
switch(status) {
|
||||
case CREATED:
|
||||
orderStatus = OrderStatus.CREATED;
|
||||
break;
|
||||
case FINISHED:
|
||||
orderStatus = OrderStatus.FINISHED;
|
||||
break;
|
||||
|
||||
case CONFIRMED:
|
||||
orderStatus = OrderStatus.CONFIRMED;
|
||||
break;
|
||||
|
||||
case COLLECTING:
|
||||
orderStatus = OrderStatus.COLLECTING;
|
||||
break;
|
||||
|
||||
case IN_TRANSPORT:
|
||||
orderStatus = OrderStatus.IN_TRANSPORT;
|
||||
break;
|
||||
}
|
||||
return orderStatus;
|
||||
}
|
||||
|
||||
@JMapConversion(from = "paymentType", to = "paymentType")
|
||||
public PaymentType conversion(com.baeldung.performancetests.model.source.PaymentType type) {
|
||||
PaymentType paymentType = null;
|
||||
switch(type) {
|
||||
case CARD:
|
||||
paymentType = PaymentType.CARD;
|
||||
break;
|
||||
|
||||
case CASH:
|
||||
paymentType = PaymentType.CASH;
|
||||
break;
|
||||
|
||||
case TRANSFER:
|
||||
paymentType = PaymentType.TRANSFER;
|
||||
break;
|
||||
}
|
||||
return paymentType;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package com.baeldung.performancetests.model.destination;
|
||||
|
||||
public enum OrderStatus {
|
||||
CREATED, CONFIRMED, COLLECTING, IN_TRANSPORT, FINISHED
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package com.baeldung.performancetests.model.destination;
|
||||
|
||||
public enum PaymentType {
|
||||
CASH, CARD, TRANSFER
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package com.baeldung.performancetests.model.destination;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@JGlobalMap
|
||||
public class Product {
|
||||
private BigDecimal price;
|
||||
private int quantity;
|
||||
|
||||
public Product() {
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public int getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(int quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
public RefundPolicy getRefundPolicy() {
|
||||
return refundPolicy;
|
||||
}
|
||||
|
||||
public void setRefundPolicy(RefundPolicy refundPolicy) {
|
||||
this.refundPolicy = refundPolicy;
|
||||
}
|
||||
|
||||
private String name;
|
||||
|
||||
public Product(BigDecimal price, int quantity, String name, String description, boolean available, RefundPolicy refundPolicy) {
|
||||
this.price = price;
|
||||
this.quantity = quantity;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.available = available;
|
||||
this.refundPolicy = refundPolicy;
|
||||
}
|
||||
|
||||
String description;
|
||||
boolean available;
|
||||
private RefundPolicy refundPolicy;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null) return false;
|
||||
if (o.getClass() == com.baeldung.performancetests.model.source.Product.class) {
|
||||
com.baeldung.performancetests.model.source.Product product =
|
||||
(com.baeldung.performancetests.model.source.Product) o;
|
||||
return quantity == product.getQuantity() &&
|
||||
available == product.isAvailable() &&
|
||||
Objects.equal(price, product.getPrice()) &&
|
||||
Objects.equal(name, product.getName()) &&
|
||||
Objects.equal(description, product.getDescription()) &&
|
||||
Objects.equal(refundPolicy, product.getRefundPolicy());
|
||||
}
|
||||
if(o.getClass() != getClass()) return false;
|
||||
Product product = (Product) o;
|
||||
return quantity == product.quantity &&
|
||||
available == product.available &&
|
||||
Objects.equal(price, product.price) &&
|
||||
Objects.equal(name, product.name) &&
|
||||
Objects.equal(description, product.description) &&
|
||||
Objects.equal(refundPolicy, product.refundPolicy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(price, quantity, name, description, available, refundPolicy);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package com.baeldung.performancetests.model.destination;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
import com.googlecode.jmapper.annotations.JMapAccessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@JGlobalMap
|
||||
public class RefundPolicy {
|
||||
@JMapAccessor(get = "isRefundable", set = "setRefundable")
|
||||
private boolean isRefundable;
|
||||
private int refundTimeInDays;
|
||||
|
||||
public RefundPolicy() {
|
||||
}
|
||||
|
||||
public boolean isRefundable() {
|
||||
return isRefundable;
|
||||
}
|
||||
|
||||
public void setRefundable(boolean refundable) {
|
||||
isRefundable = refundable;
|
||||
}
|
||||
|
||||
public int getRefundTimeInDays() {
|
||||
return refundTimeInDays;
|
||||
}
|
||||
|
||||
public void setRefundTimeInDays(int refundTimeInDays) {
|
||||
this.refundTimeInDays = refundTimeInDays;
|
||||
}
|
||||
|
||||
public List<String> getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setNotes(List<String> notes) {
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
public RefundPolicy(boolean isRefundable, int refundTimeInDays, List<String> notes) {
|
||||
|
||||
this.isRefundable = isRefundable;
|
||||
this.refundTimeInDays = refundTimeInDays;
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
private List<String> notes;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null) return false;
|
||||
if (o.getClass() == com.baeldung.performancetests.model.source.RefundPolicy.class) {
|
||||
com.baeldung.performancetests.model.source.RefundPolicy that = (com.baeldung.performancetests.model.source.RefundPolicy) o;
|
||||
return isRefundable == that.isRefundable() &&
|
||||
refundTimeInDays == that.getRefundTimeInDays() &&
|
||||
Objects.equal(notes, that.getNotes());
|
||||
}
|
||||
if (o.getClass() != getClass()) return false;
|
||||
RefundPolicy that = (RefundPolicy) o;
|
||||
return isRefundable == that.isRefundable &&
|
||||
refundTimeInDays == that.refundTimeInDays &&
|
||||
Objects.equal(notes, that.notes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(isRefundable, refundTimeInDays, notes);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.baeldung.performancetests.model.destination;
|
||||
|
||||
import com.baeldung.performancetests.model.source.User;
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
|
||||
@JGlobalMap
|
||||
public class Review {
|
||||
|
||||
int shippingGrade;
|
||||
int pricingGrade;
|
||||
int serviceGrade;
|
||||
User reviewingUser;
|
||||
String note;
|
||||
|
||||
public int getShippingGrade() {
|
||||
return shippingGrade;
|
||||
}
|
||||
|
||||
public void setShippingGrade(int shippingGrade) {
|
||||
this.shippingGrade = shippingGrade;
|
||||
}
|
||||
|
||||
public int getPricingGrade() {
|
||||
return pricingGrade;
|
||||
}
|
||||
|
||||
public void setPricingGrade(int pricingGrade) {
|
||||
this.pricingGrade = pricingGrade;
|
||||
}
|
||||
|
||||
public int getServiceGrade() {
|
||||
return serviceGrade;
|
||||
}
|
||||
|
||||
public void setServiceGrade(int serviceGrade) {
|
||||
this.serviceGrade = serviceGrade;
|
||||
}
|
||||
|
||||
public User getReviewingUser() {
|
||||
return reviewingUser;
|
||||
}
|
||||
|
||||
public void setReviewingUser(User reviewingUser) {
|
||||
this.reviewingUser = reviewingUser;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public Review() {
|
||||
|
||||
}
|
||||
|
||||
public Review(int shippingGrade, int pricingGrade, int serviceGrade, User reviewingUser, String note) {
|
||||
|
||||
this.shippingGrade = shippingGrade;
|
||||
this.pricingGrade = pricingGrade;
|
||||
this.serviceGrade = serviceGrade;
|
||||
this.reviewingUser = reviewingUser;
|
||||
this.note = note;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,57 @@
|
|||
package com.baeldung.performancetests.model.destination;
|
||||
|
||||
import com.baeldung.performancetests.model.source.Address;
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
|
||||
import java.util.List;
|
||||
@JGlobalMap
|
||||
public class Shop {
|
||||
|
||||
private String shopName;
|
||||
private Address shopAddres;
|
||||
private String shopUrl;
|
||||
private List<Review> reviews;
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName;
|
||||
}
|
||||
|
||||
public Address getShopAddres() {
|
||||
return shopAddres;
|
||||
}
|
||||
|
||||
public void setShopAddres(Address shopAddres) {
|
||||
this.shopAddres = shopAddres;
|
||||
}
|
||||
|
||||
public String getShopUrl() {
|
||||
return shopUrl;
|
||||
}
|
||||
|
||||
public void setShopUrl(String shopUrl) {
|
||||
this.shopUrl = shopUrl;
|
||||
}
|
||||
|
||||
public Shop() {
|
||||
}
|
||||
|
||||
public List<Review> getReviews() {
|
||||
return reviews;
|
||||
}
|
||||
|
||||
public void setReviews(List<Review> reviews) {
|
||||
this.reviews = reviews;
|
||||
}
|
||||
|
||||
public Shop(String shopName, Address shopAddres, String shopUrl, List<Review> reviews) {
|
||||
|
||||
this.shopName = shopName;
|
||||
this.shopAddres = shopAddres;
|
||||
this.shopUrl = shopUrl;
|
||||
this.reviews = reviews;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
package com.baeldung.performancetests.model.destination;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
import com.googlecode.jmapper.annotations.JMapConversion;
|
||||
|
||||
@JGlobalMap
|
||||
public class User {
|
||||
private String username;
|
||||
private String email;
|
||||
private AccountStatus userAccountStatus;
|
||||
|
||||
public User(String username, String email, AccountStatus userAccountStatus) {
|
||||
this.username = username;
|
||||
this.email = email;
|
||||
this.userAccountStatus = userAccountStatus;
|
||||
}
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public AccountStatus getUserAccountStatus() {
|
||||
return userAccountStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null) return false;
|
||||
if (o.getClass() == com.baeldung.performancetests.model.source.User.class) {
|
||||
com.baeldung.performancetests.model.source.User user =
|
||||
(com.baeldung.performancetests.model.source.User) o;
|
||||
return Objects.equal(username, user.getUsername()) &&
|
||||
Objects.equal(email, user.getEmail()) &&
|
||||
userAccountStatus.ordinal() == user.getUserAccountStatus().ordinal();
|
||||
}
|
||||
if (o.getClass() != getClass()) return false;
|
||||
User user = (User) o;
|
||||
return Objects.equal(username, user.username) &&
|
||||
Objects.equal(email, user.email) &&
|
||||
userAccountStatus == user.userAccountStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(username, email, userAccountStatus);
|
||||
}
|
||||
|
||||
public void setUserAccountStatus(AccountStatus userAccountStatus) {
|
||||
this.userAccountStatus = userAccountStatus;
|
||||
}
|
||||
|
||||
|
||||
@JMapConversion(from = "userAccountStatus", to = "userAccountStatus")
|
||||
public AccountStatus conversion(com.baeldung.performancetests.model.source.AccountStatus status) {
|
||||
AccountStatus accountStatus = null;
|
||||
switch(status) {
|
||||
case ACTIVE:
|
||||
accountStatus = AccountStatus.ACTIVE;
|
||||
break;
|
||||
case NOT_ACTIVE:
|
||||
accountStatus = AccountStatus.NOT_ACTIVE;
|
||||
break;
|
||||
|
||||
case BANNED:
|
||||
accountStatus = AccountStatus.BANNED;
|
||||
break;
|
||||
}
|
||||
return accountStatus;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.baeldung.performancetests.model.source;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
|
||||
public enum AccountStatus {
|
||||
ACTIVE, NOT_ACTIVE, BANNED
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.baeldung.performancetests.model.source;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
|
||||
public class Address {
|
||||
private String street;
|
||||
private String city;
|
||||
private String postalCode;
|
||||
|
||||
public Address() {
|
||||
}
|
||||
|
||||
private String country;
|
||||
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getPostalCode() {
|
||||
return postalCode;
|
||||
}
|
||||
|
||||
public void setPostalCode(String postalCode) {
|
||||
this.postalCode = postalCode;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return country;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public Address(String street, String city, String postalCode, String country) {
|
||||
|
||||
this.street = street;
|
||||
this.city = city;
|
||||
this.postalCode = postalCode;
|
||||
this.country = country;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.baeldung.performancetests.model.source;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
import com.googlecode.jmapper.annotations.JMapAccessor;
|
||||
|
||||
public class DeliveryData {
|
||||
private Address deliveryAddress;
|
||||
@JMapAccessor(get = "isPrePaid", set = "setPrePaid")
|
||||
private boolean isPrePaid;
|
||||
private String trackingCode;
|
||||
private int expectedDeliveryTimeInDays;
|
||||
|
||||
public DeliveryData() {
|
||||
}
|
||||
|
||||
public Address getDeliveryAddress() {
|
||||
return deliveryAddress;
|
||||
}
|
||||
|
||||
public void setDeliveryAddress(Address deliveryAddress) {
|
||||
this.deliveryAddress = deliveryAddress;
|
||||
}
|
||||
|
||||
public boolean isPrePaid() {
|
||||
return isPrePaid;
|
||||
}
|
||||
|
||||
public void setPrePaid(boolean prePaid) {
|
||||
isPrePaid = prePaid;
|
||||
}
|
||||
|
||||
public String getTrackingCode() {
|
||||
return trackingCode;
|
||||
}
|
||||
|
||||
public void setTrackingCode(String trackingCode) {
|
||||
this.trackingCode = trackingCode;
|
||||
}
|
||||
|
||||
public int getExpectedDeliveryTimeInDays() {
|
||||
return expectedDeliveryTimeInDays;
|
||||
}
|
||||
|
||||
public void setExpectedDeliveryTimeInDays(int expectedDeliveryTimeInDays) {
|
||||
this.expectedDeliveryTimeInDays = expectedDeliveryTimeInDays;
|
||||
}
|
||||
|
||||
public DeliveryData(Address deliveryAddress, boolean isPrePaid, String trackingCode, int expectedDeliveryTimeInDays) {
|
||||
this.deliveryAddress = deliveryAddress;
|
||||
this.isPrePaid = isPrePaid;
|
||||
this.trackingCode = trackingCode;
|
||||
this.expectedDeliveryTimeInDays = expectedDeliveryTimeInDays;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.baeldung.performancetests.model.source;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
public class Discount {
|
||||
private String startTime;
|
||||
private String endTime;
|
||||
private BigDecimal discountPrice;
|
||||
|
||||
public Discount() {
|
||||
}
|
||||
|
||||
public String getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(String startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public String getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(String endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public BigDecimal getDiscountPrice() {
|
||||
return discountPrice;
|
||||
}
|
||||
|
||||
public void setDiscountPrice(BigDecimal discountPrice) {
|
||||
this.discountPrice = discountPrice;
|
||||
}
|
||||
|
||||
public Discount(String startTime, String endTime, BigDecimal discountPrice) {
|
||||
|
||||
this.startTime = startTime;
|
||||
this.endTime = endTime;
|
||||
this.discountPrice = discountPrice;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.baeldung.performancetests.model.source;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
|
||||
public enum OrderStatus {
|
||||
CREATED, CONFIRMED, COLLECTING, IN_TRANSPORT, FINISHED
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.baeldung.performancetests.model.source;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
|
||||
public enum PaymentType {
|
||||
CASH, CARD, TRANSFER
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package com.baeldung.performancetests.model.source;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class Product {
|
||||
private BigDecimal price;
|
||||
private int quantity;
|
||||
|
||||
public Product() {
|
||||
}
|
||||
|
||||
public BigDecimal getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(BigDecimal price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public int getQuantity() {
|
||||
return quantity;
|
||||
}
|
||||
|
||||
public void setQuantity(int quantity) {
|
||||
this.quantity = quantity;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public boolean isAvailable() {
|
||||
return available;
|
||||
}
|
||||
|
||||
public void setAvailable(boolean available) {
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
public RefundPolicy getRefundPolicy() {
|
||||
return refundPolicy;
|
||||
}
|
||||
|
||||
public void setRefundPolicy(RefundPolicy refundPolicy) {
|
||||
this.refundPolicy = refundPolicy;
|
||||
}
|
||||
|
||||
private String name;
|
||||
|
||||
public Product(BigDecimal price, int quantity, String name, String description, boolean available, RefundPolicy refundPolicy) {
|
||||
this.price = price;
|
||||
this.quantity = quantity;
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.available = available;
|
||||
this.refundPolicy = refundPolicy;
|
||||
}
|
||||
|
||||
String description;
|
||||
boolean available;
|
||||
private RefundPolicy refundPolicy;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.baeldung.performancetests.model.source;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
import com.googlecode.jmapper.annotations.JMapAccessor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RefundPolicy {
|
||||
@JMapAccessor(get = "isRefundable", set = "setRefundable")
|
||||
private boolean isRefundable;
|
||||
private int refundTimeInDays;
|
||||
|
||||
public RefundPolicy() {
|
||||
}
|
||||
|
||||
public boolean isRefundable() {
|
||||
return isRefundable;
|
||||
}
|
||||
|
||||
public void setRefundable(boolean refundable) {
|
||||
isRefundable = refundable;
|
||||
}
|
||||
|
||||
public int getRefundTimeInDays() {
|
||||
return refundTimeInDays;
|
||||
}
|
||||
|
||||
public void setRefundTimeInDays(int refundTimeInDays) {
|
||||
this.refundTimeInDays = refundTimeInDays;
|
||||
}
|
||||
|
||||
public List<String> getNotes() {
|
||||
return notes;
|
||||
}
|
||||
|
||||
public void setNotes(List<String> notes) {
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
public RefundPolicy(boolean isRefundable, int refundTimeInDays, List<String> notes) {
|
||||
|
||||
this.isRefundable = isRefundable;
|
||||
this.refundTimeInDays = refundTimeInDays;
|
||||
this.notes = notes;
|
||||
}
|
||||
|
||||
private List<String> notes;
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.baeldung.performancetests.model.source;
|
||||
|
||||
public class Review {
|
||||
|
||||
int shippingGrade;
|
||||
int pricingGrade;
|
||||
int serviceGrade;
|
||||
User reviewingUser;
|
||||
String note;
|
||||
|
||||
public int getShippingGrade() {
|
||||
return shippingGrade;
|
||||
}
|
||||
|
||||
public void setShippingGrade(int shippingGrade) {
|
||||
this.shippingGrade = shippingGrade;
|
||||
}
|
||||
|
||||
public int getPricingGrade() {
|
||||
return pricingGrade;
|
||||
}
|
||||
|
||||
public void setPricingGrade(int pricingGrade) {
|
||||
this.pricingGrade = pricingGrade;
|
||||
}
|
||||
|
||||
public int getServiceGrade() {
|
||||
return serviceGrade;
|
||||
}
|
||||
|
||||
public void setServiceGrade(int serviceGrade) {
|
||||
this.serviceGrade = serviceGrade;
|
||||
}
|
||||
|
||||
public User getReviewingUser() {
|
||||
return reviewingUser;
|
||||
}
|
||||
|
||||
public void setReviewingUser(User reviewingUser) {
|
||||
this.reviewingUser = reviewingUser;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
public void setNote(String note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
public Review() {
|
||||
|
||||
}
|
||||
|
||||
public Review(int shippingGrade, int pricingGrade, int serviceGrade, User reviewingUser, String note) {
|
||||
|
||||
this.shippingGrade = shippingGrade;
|
||||
this.pricingGrade = pricingGrade;
|
||||
this.serviceGrade = serviceGrade;
|
||||
this.reviewingUser = reviewingUser;
|
||||
this.note = note;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.baeldung.performancetests.model.source;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Shop {
|
||||
|
||||
private String shopName;
|
||||
private Address shopAddres;
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName;
|
||||
}
|
||||
|
||||
public Address getShopAddres() {
|
||||
return shopAddres;
|
||||
}
|
||||
|
||||
public void setShopAddres(Address shopAddres) {
|
||||
this.shopAddres = shopAddres;
|
||||
}
|
||||
|
||||
public Shop() {
|
||||
}
|
||||
|
||||
public String getShopUrl() {
|
||||
return shopUrl;
|
||||
}
|
||||
|
||||
public void setShopUrl(String shopUrl) {
|
||||
this.shopUrl = shopUrl;
|
||||
}
|
||||
|
||||
public List<Review> getReviews() {
|
||||
return reviews;
|
||||
}
|
||||
|
||||
public void setReviews(List<Review> reviews) {
|
||||
this.reviews = reviews;
|
||||
}
|
||||
|
||||
public Shop(String shopName, Address shopAddres, String shopUrl, List<Review> reviews) {
|
||||
|
||||
this.shopName = shopName;
|
||||
this.shopAddres = shopAddres;
|
||||
this.shopUrl = shopUrl;
|
||||
this.reviews = reviews;
|
||||
}
|
||||
|
||||
private String shopUrl;
|
||||
private List<Review> reviews;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.baeldung.performancetests.model.source;
|
||||
|
||||
public class SourceCode {
|
||||
String code;
|
||||
|
||||
public SourceCode() {
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public SourceCode(String code) {
|
||||
|
||||
this.code = code;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package com.baeldung.performancetests.model.source;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
public class SourceOrder {
|
||||
private String orderFinishDate;
|
||||
private PaymentType paymentType;
|
||||
private Discount discount;
|
||||
private DeliveryData deliveryData;
|
||||
private User orderingUser;
|
||||
private List<Product> orderedProducts;
|
||||
private Shop offeringShop;
|
||||
private int orderId;
|
||||
private OrderStatus status;
|
||||
private String orderDate;
|
||||
public SourceOrder() {
|
||||
}
|
||||
|
||||
public User getOrderingUser() {
|
||||
return orderingUser;
|
||||
}
|
||||
|
||||
public void setOrderingUser(User orderingUser) {
|
||||
this.orderingUser = orderingUser;
|
||||
}
|
||||
|
||||
public List<Product> getOrderedProducts() {
|
||||
return orderedProducts;
|
||||
}
|
||||
|
||||
public void setOrderedProducts(List<Product> orderedProducts) {
|
||||
this.orderedProducts = orderedProducts;
|
||||
}
|
||||
|
||||
public OrderStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(OrderStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getOrderDate() {
|
||||
return orderDate;
|
||||
}
|
||||
|
||||
public void setOrderDate(String orderDate) {
|
||||
this.orderDate = orderDate;
|
||||
}
|
||||
|
||||
public String getOrderFinishDate() {
|
||||
return orderFinishDate;
|
||||
}
|
||||
|
||||
public void setOrderFinishDate(String orderFinishDate) {
|
||||
this.orderFinishDate = orderFinishDate;
|
||||
}
|
||||
|
||||
public PaymentType getPaymentType() {
|
||||
return paymentType;
|
||||
}
|
||||
|
||||
public void setPaymentType(PaymentType paymentType) {
|
||||
this.paymentType = paymentType;
|
||||
}
|
||||
|
||||
public Discount getDiscount() {
|
||||
return discount;
|
||||
}
|
||||
|
||||
public void setDiscount(Discount discount) {
|
||||
this.discount = discount;
|
||||
}
|
||||
|
||||
public DeliveryData getDeliveryData() {
|
||||
return deliveryData;
|
||||
}
|
||||
|
||||
public void setDeliveryData(DeliveryData deliveryData) {
|
||||
this.deliveryData = deliveryData;
|
||||
}
|
||||
|
||||
public Shop getOfferingShop() {
|
||||
return offeringShop;
|
||||
}
|
||||
|
||||
public void setOfferingShop(Shop offeringShop) {
|
||||
this.offeringShop = offeringShop;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public int getOrderId() {
|
||||
return orderId;
|
||||
}
|
||||
|
||||
public void setOrderId(int orderId) {
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
public SourceOrder(OrderStatus status, String orderDate, String orderFinishDate, PaymentType paymentType, Discount discount, DeliveryData deliveryData, User orderingUser, List<Product> orderedProducts, Shop offeringShop, int orderId) {
|
||||
|
||||
this.status = status;
|
||||
this.orderDate = orderDate;
|
||||
this.orderFinishDate = orderFinishDate;
|
||||
this.paymentType = paymentType;
|
||||
this.discount = discount;
|
||||
this.deliveryData = deliveryData;
|
||||
this.orderingUser = orderingUser;
|
||||
this.orderedProducts = orderedProducts;
|
||||
this.offeringShop = offeringShop;
|
||||
this.orderId = orderId;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package com.baeldung.performancetests.model.source;
|
||||
|
||||
import com.googlecode.jmapper.annotations.JGlobalMap;
|
||||
|
||||
public class User {
|
||||
private String username;
|
||||
private String email;
|
||||
private AccountStatus userAccountStatus;
|
||||
|
||||
public User(String username, String email, AccountStatus userAccountStatus) {
|
||||
this.username = username;
|
||||
this.email = email;
|
||||
this.userAccountStatus = userAccountStatus;
|
||||
}
|
||||
|
||||
public User() {
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public AccountStatus getUserAccountStatus() {
|
||||
return userAccountStatus;
|
||||
}
|
||||
|
||||
public void setUserAccountStatus(AccountStatus userAccountStatus) {
|
||||
this.userAccountStatus = userAccountStatus;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.baeldung.performancetests.modelmapper;
|
||||
|
||||
import com.baeldung.performancetests.Converter;
|
||||
import com.baeldung.performancetests.model.destination.DestinationCode;
|
||||
import com.baeldung.performancetests.model.source.SourceCode;
|
||||
import com.baeldung.performancetests.model.source.SourceOrder;
|
||||
import com.baeldung.performancetests.model.destination.Order;
|
||||
import org.modelmapper.ModelMapper;
|
||||
|
||||
public class ModelMapperConverter implements Converter {
|
||||
private ModelMapper modelMapper;
|
||||
|
||||
public ModelMapperConverter() {
|
||||
modelMapper = new ModelMapper();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order convert(SourceOrder sourceOrder) {
|
||||
return modelMapper.map(sourceOrder, Order.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DestinationCode convert(SourceCode sourceCode) {
|
||||
return modelMapper.map(sourceCode, DestinationCode.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.baeldung.performancetests.orika;
|
||||
|
||||
import com.baeldung.performancetests.Converter;
|
||||
import com.baeldung.performancetests.model.destination.DestinationCode;
|
||||
import com.baeldung.performancetests.model.source.SourceCode;
|
||||
import com.baeldung.performancetests.model.source.SourceOrder;
|
||||
import com.baeldung.performancetests.model.destination.Order;
|
||||
import ma.glasnost.orika.MapperFacade;
|
||||
import ma.glasnost.orika.MapperFactory;
|
||||
import ma.glasnost.orika.impl.DefaultMapperFactory;
|
||||
|
||||
public class OrikaConverter implements Converter{
|
||||
private MapperFacade mapperFacade;
|
||||
|
||||
public OrikaConverter() {
|
||||
MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
|
||||
|
||||
mapperFactory.classMap(Order.class, SourceOrder.class).field("orderStatus", "status").byDefault().register();
|
||||
mapperFacade = mapperFactory.getMapperFacade();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order convert(SourceOrder sourceOrder) {
|
||||
return mapperFacade.map(sourceOrder, Order.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DestinationCode convert(SourceCode sourceCode) {
|
||||
return mapperFacade.map(sourceCode, DestinationCode.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mappings xmlns="http://dozer.sourceforge.net"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://dozer.sourceforge.net
|
||||
http://dozer.sourceforge.net/schema/beanmapping.xsd">
|
||||
|
||||
<configuration>
|
||||
<stop-on-errors>true</stop-on-errors>
|
||||
<date-format>MM/dd/yyyy HH:mm</date-format>
|
||||
<wildcard>true</wildcard>
|
||||
</configuration>
|
||||
|
||||
<mapping>
|
||||
<class-a>com.baeldung.performancetests.model.source.SourceOrder</class-a>
|
||||
<class-b>com.baeldung.performancetests.model.destination.Order</class-b>
|
||||
<field>
|
||||
<a>status</a>
|
||||
<b>orderStatus</b>
|
||||
</field>
|
||||
</mapping>
|
||||
<mapping>
|
||||
<class-a>com.baeldung.performancetests.model.source.SourceCode</class-a>
|
||||
<class-b>com.baeldung.performancetests.model.destination.DestinationCode</class-b>
|
||||
</mapping>
|
||||
</mappings>
|
|
@ -0,0 +1,193 @@
|
|||
package com.baeldung.performancetests.benchmark;
|
||||
|
||||
import com.baeldung.performancetests.dozer.DozerConverter;
|
||||
import com.baeldung.performancetests.jmapper.JMapperConverter;
|
||||
import com.baeldung.performancetests.mapstruct.MapStructConverter;
|
||||
import com.baeldung.performancetests.model.destination.DestinationCode;
|
||||
import com.baeldung.performancetests.model.source.*;
|
||||
import com.baeldung.performancetests.model.destination.Order;
|
||||
import com.baeldung.performancetests.modelmapper.ModelMapperConverter;
|
||||
import com.baeldung.performancetests.orika.OrikaConverter;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.RunnerException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@State(Scope.Group)
|
||||
public class MappingFrameworksPerformance {
|
||||
SourceOrder sourceOrder = null;
|
||||
SourceCode sourceCode = null;
|
||||
@Setup
|
||||
public void setUp() {
|
||||
User user = new User("John", "John@doe.com", AccountStatus.ACTIVE);
|
||||
RefundPolicy refundPolicy = new RefundPolicy(true, 30, Collections.singletonList("Refundable only if not used!"));
|
||||
|
||||
Product product = new Product(BigDecimal.valueOf(10.99),
|
||||
100,
|
||||
"Sample Product",
|
||||
"Sample Product to be sold",
|
||||
true,
|
||||
refundPolicy
|
||||
);
|
||||
|
||||
Discount discount = new Discount(Instant.now().toString(), Instant.now().toString(), BigDecimal.valueOf(5.99));
|
||||
Address deliveryAddress = new Address("Washington Street 5", "New York", "55045", "USA");
|
||||
DeliveryData deliveryData = new DeliveryData(deliveryAddress, true, "", 10);
|
||||
Address shopAddress = new Address("Roosvelt Street 9", "Boston", "55042", "USA");
|
||||
User reviewingUser = new User("John", "Johhny@John.com", AccountStatus.ACTIVE);
|
||||
User negativeReviewingUser = new User("Carl", "Carl@Coral.com", AccountStatus.ACTIVE);
|
||||
Review review = new Review(5, 5, 5, reviewingUser, "The best shop I've ever bought things in");
|
||||
|
||||
Review negativeReview = new Review(1, 1, 1, negativeReviewingUser, "I will never buy anything again here!");
|
||||
|
||||
List<Review> reviewList = new ArrayList<>();
|
||||
reviewList.add(review);
|
||||
reviewList.add(negativeReview);
|
||||
Shop shop = new Shop("Super Shop", shopAddress,"www.super-shop.com",reviewList);
|
||||
|
||||
sourceOrder = new SourceOrder(OrderStatus.CONFIRMED,
|
||||
Instant.now().toString(),
|
||||
Instant.MAX.toString(),
|
||||
PaymentType.TRANSFER,
|
||||
discount,
|
||||
deliveryData,
|
||||
user,
|
||||
Collections.singletonList(product),
|
||||
shop,
|
||||
1
|
||||
);
|
||||
|
||||
sourceCode = new SourceCode("This is source code!");
|
||||
}
|
||||
|
||||
|
||||
public void main(String[] args) throws IOException, RunnerException {
|
||||
org.openjdk.jmh.Main.main(args);
|
||||
}
|
||||
|
||||
|
||||
@Benchmark
|
||||
@Group("realLifeTest")
|
||||
@Fork(value = 1, warmups = 1)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@BenchmarkMode(Mode.All)
|
||||
public void orikaMapperRealLifeBenchmark() {
|
||||
OrikaConverter orikaConverter = new OrikaConverter();
|
||||
Order mappedOrder = orikaConverter.convert(sourceOrder);
|
||||
Assert.assertEquals(mappedOrder, sourceOrder);
|
||||
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@Group("realLifeTest")
|
||||
@Fork(value = 1, warmups = 1)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@BenchmarkMode(Mode.All)
|
||||
public void jmapperRealLifeBenchmark() {
|
||||
JMapperConverter jmapperConverter = new JMapperConverter();
|
||||
Order mappedOrder = jmapperConverter.convert(sourceOrder);
|
||||
Assert.assertEquals(mappedOrder, sourceOrder);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@Group("realLifeTest")
|
||||
@Fork(value = 1, warmups = 1)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@BenchmarkMode(Mode.All)
|
||||
public void modelMapperRealLifeBenchmark() {
|
||||
ModelMapperConverter modelMapperConverter = new ModelMapperConverter();
|
||||
Order mappedOrder = modelMapperConverter.convert(sourceOrder);
|
||||
Assert.assertEquals(mappedOrder, sourceOrder);
|
||||
}
|
||||
|
||||
|
||||
@Benchmark
|
||||
@Group("realLifeTest")
|
||||
@Fork(value = 1, warmups = 1)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@BenchmarkMode(Mode.All)
|
||||
public void dozerMapperRealLifeBenchmark() {
|
||||
DozerConverter dozerConverter = new DozerConverter();
|
||||
Order mappedOrder = dozerConverter.convert(sourceOrder);
|
||||
Assert.assertEquals(mappedOrder, sourceOrder);
|
||||
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@Group("realLifeTest")
|
||||
@Fork(value = 1, warmups = 1)
|
||||
@BenchmarkMode(Mode.All)
|
||||
public void mapStructRealLifeMapperBenchmark() {
|
||||
MapStructConverter converter = MapStructConverter.MAPPER;
|
||||
Order mappedOrder = converter.convert(sourceOrder);
|
||||
Assert.assertEquals(mappedOrder, sourceOrder);
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@Group("simpleTest")
|
||||
@Fork(value = 1, warmups = 1)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@BenchmarkMode(Mode.All)
|
||||
public void orikaMapperSimpleBenchmark() {
|
||||
OrikaConverter orikaConverter = new OrikaConverter();
|
||||
DestinationCode mappedCode = orikaConverter.convert(sourceCode);
|
||||
Assert.assertEquals(mappedCode.getCode(), sourceCode.getCode());
|
||||
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@Group("simpleTest")
|
||||
@Fork(value = 1, warmups = 1)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@BenchmarkMode(Mode.All)
|
||||
public void jmapperSimpleBenchmark() {
|
||||
JMapperConverter jmapperConverter = new JMapperConverter();
|
||||
DestinationCode mappedCode = jmapperConverter.convert(sourceCode);
|
||||
Assert.assertEquals(mappedCode.getCode(), sourceCode.getCode());
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@Group("simpleTest")
|
||||
@Fork(value = 1, warmups = 1)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@BenchmarkMode(Mode.All)
|
||||
public void modelMapperBenchmark() {
|
||||
ModelMapperConverter modelMapperConverter = new ModelMapperConverter();
|
||||
DestinationCode mappedCode = modelMapperConverter.convert(sourceCode);
|
||||
Assert.assertEquals(mappedCode.getCode(), sourceCode.getCode());
|
||||
}
|
||||
|
||||
|
||||
@Benchmark
|
||||
@Group("simpleTest")
|
||||
@Fork(value = 1, warmups = 1)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@BenchmarkMode(Mode.All)
|
||||
public void dozerMapperSimpleBenchmark() {
|
||||
DozerConverter dozerConverter = new DozerConverter();
|
||||
Order mappedOrder = dozerConverter.convert(sourceOrder);
|
||||
Assert.assertEquals(mappedOrder, sourceOrder);
|
||||
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
@Group("simpleTest")
|
||||
@Fork(value = 1, warmups = 1)
|
||||
@OutputTimeUnit(TimeUnit.MILLISECONDS)
|
||||
@BenchmarkMode(Mode.All)
|
||||
public void mapStructMapperSimpleBenchmark() {
|
||||
MapStructConverter converter = MapStructConverter.MAPPER;
|
||||
DestinationCode mappedCode = converter.convert(sourceCode);
|
||||
Assert.assertEquals(mappedCode.getCode(), sourceCode.getCode());
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<mappings xmlns="http://dozer.sourceforge.net"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://dozer.sourceforge.net
|
||||
http://dozer.sourceforge.net/schema/beanmapping.xsd">
|
||||
|
||||
<configuration>
|
||||
<stop-on-errors>true</stop-on-errors>
|
||||
<date-format>MM/dd/yyyy HH:mm</date-format>
|
||||
<wildcard>true</wildcard>
|
||||
</configuration>
|
||||
|
||||
<mapping>
|
||||
<class-a>com.baeldung.performancetests.model.source.SourceOrder</class-a>
|
||||
<class-b>com.baeldung.performancetests.model.destination.Order</class-b>
|
||||
<field>
|
||||
<a>status</a>
|
||||
<b>orderStatus</b>
|
||||
</field>
|
||||
</mapping>
|
||||
</mappings>
|
Loading…
Reference in New Issue