/*
 * Copyright 2019, TeamDev. All rights reserved.
 *
 * Redistribution and use in source and/or binary forms, with or without
 * modification, must retain the above copyright notice and the following
 * disclaimer.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package io.spine.validate;

import com.google.common.testing.EqualsTester;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

@DisplayName("Comparable number should")
class ComparableNumberTest {

    @Test
    @DisplayName("have a consistent equality relationship")
    void testEquals() {
        String longMaxValue = String.valueOf(Long.MAX_VALUE);
        String doubleMinValue = String.valueOf(Double.MIN_VALUE);
        new EqualsTester().addEqualityGroup(new NumberText(1).toNumber(),
                                            new NumberText("1").toNumber())
                          .addEqualityGroup(new NumberText(longMaxValue).toNumber(),
                                            new NumberText(Long.MAX_VALUE).toNumber())
                          .addEqualityGroup(new NumberText(doubleMinValue).toNumber(),
                                            new NumberText(Double.MIN_VALUE).toNumber())
                          .testEquals();
    }
}

@@ -1123,16 +1123,53 @@
 ayName;%0A
+import org.junit.jupiter.api.Nested;%0A
 import o
@@ -1195,16 +1195,16 @@
 i.Test;%0A
-
 %0A@Displa
@@ -1272,20 +1272,22 @@
 %7B%0A%0A    @
-T
+N
 est
+ed
 %0A    @Di
@@ -1339,16 +1339,101 @@
 nship%22)%0A
+    class EqualsTests %7B%0A%0A        @Test%0A        @DisplayName(%22between instances%22)%0A    
     void
@@ -1448,16 +1448,20 @@
 als() %7B%0A
+    
         
@@ -1518,24 +1518,28 @@
 E);%0A        
+    
 String doubl
@@ -1588,24 +1588,28 @@
 E);%0A        
+    
 new EqualsTe
@@ -1614,16 +1614,37 @@
 Tester()
+%0A                    
 .addEqua
@@ -1674,39 +1674,144 @@
 t(1).toNumber(),
-%0A      
+ new NumberText(%221%22).toNumber())%0A                    .addEqualityGroup(new NumberText(longMaxValue).toNumber(),%0A
                 
@@ -1839,35 +1839,46 @@
  new NumberText(
-%221%22
+Long.MAX_VALUE
 ).toNumber())%0A  
@@ -1867,38 +1867,32 @@
 UE).toNumber())%0A
-      
                 
@@ -1920,39 +1920,41 @@
 (new NumberText(
-longMax
+doubleMin
 Value).toNumber(
@@ -1986,38 +1986,32 @@
                 
-      
 new NumberText(L
@@ -2005,32 +2005,34 @@
  NumberText(
-Long.MAX
+Double.MIN
 _VALUE).toNu
@@ -2063,74 +2063,471 @@
     
-      .addEqualityGroup(new 
+.testEquals();%0A        %7D%0A%0A        @Test%0A        @DisplayName(%22between instances and primitives%22)%0A        void testEqualsBetweenPrimitives() %7B%0A            double doubleValue = Double.MAX_VALUE;%0A            int intValue = Integer.MAX_VALUE;%0A            float floatValue = Float.MAX_VALUE;%0A            long longValue = Long.MAX_VALUE;%0A%0A            new EqualsTester()%0A                    .addEqualityGroup(doubleValue, new Comparable
 Number
-Text
 (double
-Min
 Value).
-toNumber(),
+doubleValue())
 %0A   
@@ -2547,83 +2547,270 @@
     
-                        new NumberText(Double.MIN_VALUE).toNumber())%0A      
+.addEqualityGroup(intValue, new ComparableNumber(intValue).intValue())%0A                    .addEqualityGroup(floatValue, new ComparableNumber(floatValue).floatValue())%0A                    .addEqualityGroup(longValue, new ComparableNumber(longValue).longValue())%0A
     
@@ -2836,20 +2836,30 @@
 stEquals();%0A
+        %7D%0A
     %7D%0A%7D%0A

Add an equality test.