<commit_before>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(repository.jpa.qualified_abstract_entity_test_name) %>;

@java.lang.SuppressWarnings( { "UnusedDeclaration", "PMD.SystemPrintln" } )
@javax.annotation.Generated( "Domgen" )
public abstract class <%= repository.jpa.abstract_entity_test_name %>
  extends org.realityforge.guiceyloops.server.AbstractServerTest
{
<% repository.jpa.test_factories.each do |short_code, classname| -%>
  @javax.annotation.Nonnull
  @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" )
  protected <%= classname %> <%= short_code %>;
<% end -%>

  @org.testng.annotations.BeforeMethod
  public void preTest()
    throws Exception
  {
    super.preTest();
<% repository.jpa.test_factories.each do |short_code, classname| -%>
    <%= short_code %> = s( <%= classname %>.class );
<% end -%>
<%
  # TODO - there should be a better way of doing this. Perhaps Runnables/Actions that are added by facets?
  if repository.imit?
-%>
    s( javax.transaction.TransactionSynchronizationRegistry.class ).putResource( "ReplicationActive", "Test" );
<% end -%>
  }
<% if repository.sql_analysis?-%>

  @org.testng.annotations.AfterMethod
  @java.lang.Override
  public void postTest()
  {
    if ( isSqlAnalysisEnabled() && em().isOpen() && em().isJoinedToTransaction() && !em().getTransaction().getRollbackOnly() )
    {
      em().clear();
      em().createNativeQuery( "EXEC <%= repository.sql_analysis.analysis_data_module.sql.quoted_schema %>.[spPerformChecks]" ).getResultList();
      final java.util.List<<%= repository.sql_analysis.analysis_data_module.entity_by_name(:DataIssue).jpa.qualified_name %>> issues = <%= repository.sql_analysis.analysis_data_module.jpa.short_test_code %>.dataIssueRepository().findAll();
      final java.lang.StringBuilder sb = new java.lang.StringBuilder();
      if ( !issues.isEmpty() )
      {
        for ( final <%= repository.sql_analysis.analysis_data_module.entity_by_name(:DataIssue).jpa.qualified_name %> issue : issues )
        {
          final String header = issue.getCategory() + ":" + issue.getDescription();
          final String viewSql = issue.getViewSql();
          final String message = header + ( null == viewSql ? "" : ": SQL\n---" + viewSql + "---" );
          System.out.println( message );
          sb.append( "  " );
          sb.append( message );
        }
        org.testng.Assert.fail( "Database left in inconsistent state:\n" + sb.toString() );
      }
    }
    super.postTest();
  }

  protected boolean isSqlAnalysisEnabled()
  {
    return java.lang.System.getProperty( "sql_analysis.enabled", "true"  ).equals( "true" );
  }
<% end -%>
<% repository.jpa.test_modules.each_pair do |name, classname| -%>

  @javax.annotation.Nullable
  protected com.google.inject.Module new<%= name %>()
  {
    return new <%= classname =~ /\(/ ? classname : "#{classname}()" %>;
  }
<% end -%>
<% repository.jpa.test_class_contents.each do |content| -%>
<%= content -%>
<% end -%>

  @java.lang.Override
  protected com.google.inject.Module[] getModules()
  {
    final java.util.ArrayList<com.google.inject.Module> modules = new java.util.ArrayList<>();
    java.util.Collections.addAll( modules, super.getModules() );
<% repository.jpa.test_modules.keys.each do |name| -%>
    addModule( modules, new<%= name %>() );
<% end -%>
    return modules.toArray( new com.google.inject.Module[ modules.size() ] );
  }
}<commit_msg>Literal to LHS of comparison<commit_after>/* DO NOT EDIT: File is auto-generated */
package <%= to_package(repository.jpa.qualified_abstract_entity_test_name) %>;

@java.lang.SuppressWarnings( { "UnusedDeclaration", "PMD.SystemPrintln" } )
@javax.annotation.Generated( "Domgen" )
public abstract class <%= repository.jpa.abstract_entity_test_name %>
  extends org.realityforge.guiceyloops.server.AbstractServerTest
{
<% repository.jpa.test_factories.each do |short_code, classname| -%>
  @javax.annotation.Nonnull
  @edu.umd.cs.findbugs.annotations.SuppressFBWarnings( "NP_NONNULL_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR" )
  protected <%= classname %> <%= short_code %>;
<% end -%>

  @org.testng.annotations.BeforeMethod
  public void preTest()
    throws Exception
  {
    super.preTest();
<% repository.jpa.test_factories.each do |short_code, classname| -%>
    <%= short_code %> = s( <%= classname %>.class );
<% end -%>
<%
  # TODO - there should be a better way of doing this. Perhaps Runnables/Actions that are added by facets?
  if repository.imit?
-%>
    s( javax.transaction.TransactionSynchronizationRegistry.class ).putResource( "ReplicationActive", "Test" );
<% end -%>
  }
<% if repository.sql_analysis?-%>

  @org.testng.annotations.AfterMethod
  @java.lang.Override
  public void postTest()
  {
    if ( isSqlAnalysisEnabled() && em().isOpen() && em().isJoinedToTransaction() && !em().getTransaction().getRollbackOnly() )
    {
      em().clear();
      em().createNativeQuery( "EXEC <%= repository.sql_analysis.analysis_data_module.sql.quoted_schema %>.[spPerformChecks]" ).getResultList();
      final java.util.List<<%= repository.sql_analysis.analysis_data_module.entity_by_name(:DataIssue).jpa.qualified_name %>> issues = <%= repository.sql_analysis.analysis_data_module.jpa.short_test_code %>.dataIssueRepository().findAll();
      final java.lang.StringBuilder sb = new java.lang.StringBuilder();
      if ( !issues.isEmpty() )
      {
        for ( final <%= repository.sql_analysis.analysis_data_module.entity_by_name(:DataIssue).jpa.qualified_name %> issue : issues )
        {
          final String header = issue.getCategory() + ":" + issue.getDescription();
          final String viewSql = issue.getViewSql();
          final String message = header + ( null == viewSql ? "" : ": SQL\n---" + viewSql + "---" );
          System.out.println( message );
          sb.append( "  " );
          sb.append( message );
        }
        org.testng.Assert.fail( "Database left in inconsistent state:\n" + sb.toString() );
      }
    }
    super.postTest();
  }

  protected boolean isSqlAnalysisEnabled()
  {
    return "true".equals( System.getProperty( "sql_analysis.enabled", "true" ) );
  }
<% end -%>
<% repository.jpa.test_modules.each_pair do |name, classname| -%>

  @javax.annotation.Nullable
  protected com.google.inject.Module new<%= name %>()
  {
    return new <%= classname =~ /\(/ ? classname : "#{classname}()" %>;
  }
<% end -%>
<% repository.jpa.test_class_contents.each do |content| -%>
<%= content -%>
<% end -%>

  @java.lang.Override
  protected com.google.inject.Module[] getModules()
  {
    final java.util.ArrayList<com.google.inject.Module> modules = new java.util.ArrayList<>();
    java.util.Collections.addAll( modules, super.getModules() );
<% repository.jpa.test_modules.keys.each do |name| -%>
    addModule( modules, new<%= name %>() );
<% end -%>
    return modules.toArray( new com.google.inject.Module[ modules.size() ] );
  }
}
{'fraction_non_alphanumeric': 0.16112385321100917, 'fraction_numerical': 0.0, 'mean_word_length': 3.7853223593964334, 'pattern_counts': {'":': 4, '<': 65, '<?xml version=': 0, '>': 65, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7055223', 'n_tokens_mistral': 2299, 'n_tokens_neox': 2201, 'n_words': 389}