@@ -0,0 +1,2169 @@
+package arez.integration.references;%0A%0Aimport arez.Arez;%0Aimport arez.annotations.Action;%0Aimport arez.annotations.ArezComponent;%0Aimport arez.annotations.Observable;%0Aimport arez.annotations.Reference;%0Aimport arez.annotations.ReferenceId;%0Aimport arez.annotations.Repository;%0Aimport arez.component.Identifiable;%0Aimport arez.component.TypeBasedLocator;%0Aimport arez.integration.AbstractArezIntegrationTest;%0Aimport java.util.Objects;%0Aimport javax.annotation.Nonnull;%0Aimport org.testng.annotations.Test;%0Aimport static org.testng.Assert.*;%0A%0Apublic class ReferenceNotFoundIntegrationTest%0A  extends AbstractArezIntegrationTest%0A%7B%0A  @Test%0A  public void scenario()%0A    throws Throwable%0A  %7B%0A    final ReferenceNotFoundIntegrationTest_Model2Repository repository =%0A      ReferenceNotFoundIntegrationTest_Model2Repository.newRepository();%0A%0A    final TypeBasedLocator locator = new TypeBasedLocator();%0A    Arez.context().registerLocator( locator );%0A%0A    final Model2 model2 = repository.create();%0A    final Object model2Id = Objects.requireNonNull( Identifiable.getArezId( model2 ) );%0A%0A    final IllegalStateException exception =%0A      expectThrows( IllegalStateException.class, () -%3E safeAction( () -%3E Model1.create( model2Id ) ) );%0A%0A    assertEquals( exception.getMessage(),%0A                  %22Reference method named 'getModel2' invoked on component named 'Model1.0' is unable to resolve entity of type arez.integration.references.ReferenceNotFoundIntegrationTest.Model2 and id = 0%22 );%0A  %7D%0A%0A  @ArezComponent%0A  static abstract class Model1%0A  %7B%0A    @Nonnull%0A    private Object _model2Id;%0A%0A    static Model1 create( @Nonnull final Object model2Id )%0A    %7B%0A      return new ReferenceNotFoundIntegrationTest_Arez_Model1( model2Id );%0A    %7D%0A%0A    Model1( @Nonnull final Object model2Id )%0A    %7B%0A      _model2Id = model2Id;%0A    %7D%0A%0A    @Reference%0A    abstract Model2 getModel2();%0A%0A    @ReferenceId%0A    @Observable%0A    @Nonnull%0A    Object getModel2Id()%0A    %7B%0A      return _model2Id;%0A    %7D%0A%0A    void setModel2Id( @Nonnull Object model2Id )%0A    %7B%0A      _model2Id = model2Id;%0A    %7D%0A  %7D%0A%0A  @Repository%0A  @ArezComponent%0A  static abstract class Model2%0A  %7B%0A    @Action%0A    void doStuff()%0A    %7B%0A    %7D%0A  %7D%0A%7D%0A

Add integration test that verifies the exception