package org.realityforge.arez.processor;

import com.google.testing.compile.JavaFileObjects;
import com.google.testing.compile.JavaSourceSubjectFactory;
import javax.annotation.Nonnull;
import javax.tools.JavaFileObject;
import static com.google.common.truth.Truth.assert_;

abstract class AbstractArezProcessorTest
{
  void assertSuccessfulCompile( @Nonnull final String classname )
  {
    final String file = classname.replaceAll( "\\.", "/" );
    assertSuccessfulCompile( "input/" + file + ".java", "expected/" + file + ".java" );
  }

  private void assertSuccessfulCompile( @Nonnull final String inputResource,
                                        @Nonnull final String expectedOutputResource )
  {
    final JavaFileObject source = JavaFileObjects.forResource( inputResource );
    assert_().about( JavaSourceSubjectFactory.javaSource() ).
      that( source ).
      processedWith( new ArezProcessor() ).
      compilesWithoutError().
      and().generatesSources( JavaFileObjects.forResource( expectedOutputResource ) );
  }
}

@@ -397,21 +397,27 @@
 l String
- file
+%5B%5D elements
  = class
@@ -425,118 +425,662 @@
 ame.
-replaceAll( %22%5C%5C.%22, %22/%22 );%0A    assertSuccessfulCompile( %22input/%22 + file + %22.java%22, %22expected/%22 + file + %22.java%22
+contains( %22.%22 ) ? classname.split( %22.%22 ) : new String%5B%5D%7B classname %7D;%0A    final StringBuilder input = new StringBuilder();%0A    final StringBuilder expected = new StringBuilder();%0A    input.append( %22input%22 );%0A    expected.append( %22expected%22 );%0A    for ( int i = 0; i %3C elements.length; i++ )%0A    %7B%0A      input.append( '/' );%0A      input.append( elements%5B i %5D );%0A      expected.append( '/' );%0A      if ( i == elements.length - 1 )%0A      %7B%0A        expected.append( %22Arez_%22 );%0A      %7D%0A      expected.append( elements%5B i %5D );%0A    %7D%0A    input.append( %22.java%22 );%0A    expected.append( %22.java%22 );%0A    assertSuccessfulCompile( input.toString(), expected.toString()
  );%0A

Fix the generation of classnames