package org.jgrades.api.lic.model;

import org.apache.commons.lang3.builder.EqualsBuilder;
import org.apache.commons.lang3.builder.HashCodeBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.joda.time.DateTime;

import javax.xml.bind.annotation.*;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;

@XmlRootElement(name = "product")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = {"name", "version", "validFrom", "validTo"})
@XmlJavaTypeAdapter(type = DateTime.class, value = DateTimeAdapter.class)
public class Product {

    @XmlElement(name = "name", required = true)
    private String name;

    @XmlElement(name = "version", required = true)
    private String version;

    @XmlElement(name = "valid_from", required = true)
    private DateTime validFrom;

    @XmlElement(name = "valid_to", required = true)
    private DateTime validTo;

    public Product() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public DateTime getValidFrom() {
        return validFrom;
    }

    public void setValidFrom(DateTime validFrom) {
        this.validFrom = validFrom;
    }

    public DateTime getValidTo() {
        return validTo;
    }

    public void setValidTo(DateTime validTo) {
        this.validTo = validTo;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (obj == this) {
            return true;
        }
        if (obj.getClass() != getClass()) {
            return false;
        }
        Product rhs = (Product) obj;
        return new EqualsBuilder()
                .append(this.name, rhs.name)
                .append(this.version, rhs.version)
                .append(this.validFrom, rhs.validFrom)
                .append(this.validTo, rhs.validTo)
                .isEquals();
    }

    @Override
    public int hashCode() {
        return new HashCodeBuilder()
                .append(name)
                .append(version)
                .append(validFrom)
                .append(validTo)
                .toHashCode();
    }


    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("name", name)
                .append("version", version)
                .append("validFrom", validFrom)
                .append("validTo", validTo)
                .toString();
    }
}

@@ -1978,16 +1978,28 @@
 alidFrom
+.getMillis()
 , rhs.va
@@ -1997,32 +1997,44 @@
 ), rhs.validFrom
+.getMillis()
 )%0A              
@@ -2055,16 +2055,28 @@
 .validTo
+.getMillis()
 , rhs.va
@@ -2076,24 +2076,36 @@
  rhs.validTo
+.getMillis()
 )%0A          

Fix test