package ro.stancalau.lombok.base;

import org.junit.Before;
import org.junit.Test;
import ro.stancalau.lombok.api.ImmutablePerson;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public abstract class PersonBaseEqualsAndHashTest<T extends ImmutablePerson> implements PersonFactory<T> {

    private T person;
    private T samePerson;
    private T stranger;

    @Before
    public void setUp() throws Exception {
        person = createPerson();
        samePerson = createPerson();
        stranger = createPerson("Stranger");
    }

    @Test
    public void testNotEqualsToNull() throws Exception {
        assertFalse(person.equals(null));
    }

    @Test
    public void testEqualsToSelf() throws Exception {
        assertTrue(person.equals(person));
        assertTrue(stranger.equals(stranger));
    }

    @Test
    public void givenTwoPeopleWithDifferentNameWhenEqualsThenReturnFalse() throws Exception {
        assertFalse(person.equals(stranger));
        assertFalse(stranger.equals(person));
    }

    @Test
    public void givenPersonWithSameStateWhenEqualsThenReturnTrue() throws Exception {
        assertTrue(person.equals(samePerson));
    }

    //TODO add more tests for equals and hash

}

@@ -160,62 +160,9 @@
 ert.
-assertFalse;%0Aimport static org.junit.Assert.assertTrue
+*
 ;%0A%0Ap
@@ -312,24 +312,49 @@
 samePerson;%0A
+    private T sameClone;%0A
     private 
@@ -483,32 +483,68 @@
 createPerson();%0A
+        sameClone = createPerson();%0A
         stranger
@@ -729,20 +729,17 @@
 test
-EqualsToSelf
+Reflexive
 () t
@@ -807,31 +807,98 @@
     
+%7D%0A%0A
     
-assertTrue(stranger
+@Test%0A    public void testSymmetric() throws Exception %7B%0A        assertFalse(person
 .equ
@@ -921,92 +921,191 @@
     
-%7D%0A%0A
     
-@Test%0A    public void givenTwoPeopleWithDifferentNameWhenEqualsThenReturnFals
+assertFalse(stranger.equals(person));%0A%0A        assertTrue(person.equals(samePerson));%0A        assertTrue(samePerson.equals(person));%0A    %7D%0A%0A    @Test%0A    public void testTransitiv
 e() 
@@ -1129,36 +1129,35 @@
 %7B%0A        assert
-Fals
+Tru
 e(person.equals(
@@ -1149,39 +1149,41 @@
 (person.equals(s
-tranger
+amePerson
 ));%0A        asse
@@ -1180,38 +1180,88 @@
       assert
-F
+True(samePerson.equ
 als
-e
 (s
-tranger
+ameClone));%0A        assertTrue(sameClone
 .equals(pers
@@ -1310,16 +1310,17 @@
 enPerson
+s
 WithSame
@@ -1332,28 +1332,36 @@
 When
-EqualsThenReturnTrue
+CompareHashCodesThenAreEqual
 () t
@@ -1388,36 +1388,38 @@
       assert
-True
+Equals
 (person.
 equals(sameP
@@ -1410,81 +1410,48 @@
 son.
-equals(samePerson));%0A    %7D%0A%0A    //TODO add more tests for equals and hash%0A
+hashCode(), samePerson.hashCode());%0A    %7D
 %0A%7D%0A

Add transitive test for equals and hashcode test.