package arez.integration;

import arez.annotations.ArezComponent;
import arez.annotations.ComponentId;
import arez.component.Identifiable;
import org.testng.annotations.Test;
import static org.testng.Assert.*;

@SuppressWarnings( "ConstantConditions" )
public final class IdentifiableIntegrationTest
  extends AbstractArezIntegrationTest
{
  @Test
  public void arezManagedArezId()
  {
    final Model1 model = new IdentifiableIntegrationTest_Arez_Model1();

    assertFalse( model instanceof Identifiable );
  }

  @Test
  public void componentManagedArezId()
  {
    final Model2 model = new IdentifiableIntegrationTest_Arez_Model2( 33 );

    assertTrue( model instanceof Identifiable );
    assertEquals( Identifiable.getArezId( model ), (Integer) 33 );
    assertEquals( Identifiable.asIdentifiable( model ), model );
  }

  @ArezComponent( allowEmpty = true )
  static abstract class Model1
  {
  }

  @ArezComponent( allowEmpty = true )
  static abstract class Model2
  {
    private final int id;

    Model2( final int id )
    {
      this.id = id;
    }

    @ComponentId
    int getId()
    {
      return id;
    }
  }
}

@@ -96,16 +96,49 @@
 nentId;%0A
+import arez.annotations.Feature;%0A
 import a
@@ -392,25 +392,25 @@
 oid 
-a
 re
-zManagedA
+qui
 re
-z
 Id
+_DISABLE
 ()%0A 
@@ -566,30 +566,24 @@
 oid 
-componentManagedA
+requi
 re
-z
 Id
+_ENABLE
 ()%0A 
@@ -844,24 +844,328 @@
 del );%0A  %7D%0A%0A
+  @Test%0A  public void requireId_DEFAULT()%0A  %7B%0A    final Model3 model = new IdentifiableIntegrationTest_Arez_Model3();%0A%0A    assertTrue( model instanceof Identifiable );%0A    assertEquals( Identifiable.getArezId( model ), (Integer) 1 );%0A    assertEquals( Identifiable.asIdentifiable( model ), model );%0A  %7D%0A%0A
   @ArezCompo
@@ -1179,32 +1179,61 @@
 llowEmpty = true
+, requireId = Feature.DISABLE
  )%0A  static abst
@@ -1294,16 +1294,44 @@
 y = true
+, requireId = Feature.ENABLE
  )%0A  sta
@@ -1512,11 +1512,121 @@
    %7D%0A  %7D
+%0A%0A  @ArezComponent( allowEmpty = true, requireId = Feature.AUTODETECT )%0A  static abstract class Model3%0A  %7B%0A  %7D
 %0A%7D%0A

Fix test to reflect current defaults