package org.realityforge.arez.integration;

import org.realityforge.arez.Arez;
import org.realityforge.guiceyloops.shared.ValueUtil;
import org.testng.annotations.Test;
import static org.testng.Assert.*;

public class EqualsAndHashCodeTest
{
  @Test
  public void equalsAndHashBasedOnId()
  {
    final PersonModel person1 = PersonModel.create( ValueUtil.randomString(), ValueUtil.randomString() );
    final PersonModel person2 = PersonModel.create( ValueUtil.randomString(), ValueUtil.randomString() );
    final PersonModel person3 =
      Arez.context().safeAction( () -> PersonModel.create( person1.getFirstName(), person1.getLastName() ) );

    assertEquals( person1.hashCode(), person1.hashCode() );
    assertNotEquals( person1.hashCode(), person2.hashCode() );
    assertNotEquals( person1.hashCode(), person3.hashCode() );

    //noinspection EqualsWithItself
    assertTrue( person1.equals( person1 ) );
    assertFalse( person1.equals( person2 ) );
    assertFalse( person1.equals( person3 ) );
  }
}

@@ -37,16 +37,49 @@
 ation;%0A%0A
+import javax.annotation.Nonnull;%0A
 import o
@@ -105,16 +105,125 @@
 z.Arez;%0A
+import org.realityforge.arez.annotations.ArezComponent;%0Aimport org.realityforge.arez.annotations.Observable;%0A
 import o
@@ -381,164 +381,670 @@
 t%0A%7B%0A
+%0A
   @
-Test%0A  public void equalsAndHashBasedOnId(
+SuppressWarnings( %22WeakerAccess%22 )%0A  @ArezComponent%0A  public static class PersonModel%0A  %7B%0A    @Nonnull%0A    private String _firstName;%0A%0A    @Nonnull%0A    public static PersonModel create( @Nonnull final String firstName 
 )%0A  
+ 
+ 
 %7B%0A    
-final PersonModel person1 = PersonModel.create( ValueUtil.randomString(), ValueUtil.randomString() );
+  return new EqualsAndHashCodeTest$Arez_PersonModel( firstName );%0A    %7D%0A%0A    PersonModel( @Nonnull final String firstName )%0A    %7B%0A      _firstName = firstName;%0A    %7D%0A%0A    @Observable%0A    @Nonnull%0A    public String getFirstName()%0A    %7B%0A      return _firstName;%0A    %7D%0A%0A    public void setFirstName( @Nonnull final String firstName )%0A    %7B%0A      _firstName = firstName;%0A    %7D%0A  %7D%0A%0A  @Test%0A  public void equalsAndHashBasedOnId()%0A  %7B
 %0A   
@@ -1068,17 +1068,17 @@
 l person
-2
+1
  = Perso
@@ -1116,17 +1116,71 @@
 String()
-,
+ );%0A    final PersonModel person2 = PersonModel.create(
  ValueUt
@@ -1317,31 +1317,8 @@
 me()
-, person1.getLastName()
  ) )

Use an isolated model so it does not interfere with other integration tests