content: /*
   * This file was automatically generated by UTestGen and EvoSuite
   * Thu Mar 21 00:42:27 GMT 2024
   */
  
  package org.petsoar.search.lucene;
  
  import org.junit.jupiter.api.Test;
  import static org.junit.jupiter.api.Assertions.*;
  import org.junit.jupiter.api.Timeout;
  import java.util.concurrent.TimeUnit;
  import static org.evosuite.runtime.EvoAssertions.*;
  import java.io.Reader;
  import java.io.StringReader;
  import java.util.List;
  import org.apache.lucene.analysis.Analyzer;
  import org.apache.lucene.analysis.TokenStream;
  import org.evosuite.runtime.EvoRunner;
  import org.evosuite.runtime.EvoRunnerParameters;
  import org.junit.runner.RunWith;
  import org.petsoar.search.lucene.DefaultLuceneDocumentFactory;
  
  @RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, separateClassLoader = true) 
  public class DefaultLuceneDocumentFactory_ESTest extends DefaultLuceneDocumentFactory_ESTest_scaffolding {
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetType() throws Throwable  {
        // Set up the field configuration with a specific type
        DefaultLuceneDocumentFactory.FieldConfiguration fieldConfiguration = new DefaultLuceneDocumentFactory.FieldConfiguration();
        fieldConfiguration.setType("NgUVYq#6j-NnTE92");
        
        // Verify that the type was set correctly
        assertEquals("NgUVYq#6j-NnTE92", fieldConfiguration.getType());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetType() throws Throwable  {
        // Test that the DefaultLuceneDocumentFactory.FieldConfiguration object is initialized with a null value for type
        DefaultLuceneDocumentFactory.FieldConfiguration defaultLuceneDocumentFactory_FieldConfiguration = new DefaultLuceneDocumentFactory.FieldConfiguration();
        String type = defaultLuceneDocumentFactory_FieldConfiguration.getType();
        assertNull(type);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesFieldConfigurationAndCallsToString() throws Throwable  {
        // Given a DefaultLuceneDocumentFactory.FieldConfiguration instance
        DefaultLuceneDocumentFactory.FieldConfiguration fieldConfig = new DefaultLuceneDocumentFactory.FieldConfiguration();
        
        // When the toString method is called on the instance
        String stringRepresentation = fieldConfig.toString();
        
        // Then the resulting string representation should be not null
        assertNotNull(stringRepresentation);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetAttributeName() throws Throwable  {
        // Given a DefaultLuceneDocumentFactory.FieldConfiguration instance
        DefaultLuceneDocumentFactory.FieldConfiguration defaultLuceneDocumentFactory_FieldConfiguration = new DefaultLuceneDocumentFactory.FieldConfiguration();
        
        // When the getAttributeName method is called on the instance
        String attributeName = defaultLuceneDocumentFactory_FieldConfiguration.getAttributeName();
        
        // Then the returned value should be null
        assertNull(attributeName);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetFieldName() throws Throwable  {
        // Given a DefaultLuceneDocumentFactory.FieldConfiguration instance
        DefaultLuceneDocumentFactory.FieldConfiguration defaultLuceneDocumentFactory_FieldConfiguration = new DefaultLuceneDocumentFactory.FieldConfiguration();
        
        // When the fieldName is accessed
        String fieldName = defaultLuceneDocumentFactory_FieldConfiguration.getFieldName();
        
        // Then the result should be null
        assertNull(fieldName);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesFieldConfigurationAndCallsEquals() throws Throwable  {
        // Given: A DefaultLuceneDocumentFactory.FieldConfiguration instance with some field configuration
        DefaultLuceneDocumentFactory.FieldConfiguration defaultLuceneDocumentFactory_FieldConfiguration = new DefaultLuceneDocumentFactory.FieldConfiguration();
        
        // When: The equals method is called with a null object
        boolean equals = defaultLuceneDocumentFactory_FieldConfiguration.equals((Object) null);
        
        // Then: The result should be false, as the field configuration cannot be equal to null
        assertFalse(equals);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetFieldName() throws Throwable  {
        // Given: a field configuration with an empty field name
        DefaultLuceneDocumentFactory.FieldConfiguration defaultLuceneDocumentFactory_FieldConfiguration = new DefaultLuceneDocumentFactory.FieldConfiguration();
        defaultLuceneDocumentFactory_FieldConfiguration.setFieldName("");
        
        // When: the getFieldName method is called
        String actualFieldName = defaultLuceneDocumentFactory_FieldConfiguration.getFieldName();
        
        // Then: the empty string is returned
        assertEquals("", actualFieldName);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testSetAttributeName() throws Throwable  {
        // Create a new instance of the DefaultLuceneDocumentFactory.FieldConfiguration class
        DefaultLuceneDocumentFactory.FieldConfiguration fieldConfiguration = new DefaultLuceneDocumentFactory.FieldConfiguration();
        
        // Set the attribute name to "Unknown type for a field, fieldName="
        fieldConfiguration.setAttributeName("Unknown type for a field, fieldName=");
        
        // Verify that the correct attribute name is returned
        assertEquals("Unknown type for a field, fieldName=", fieldConfiguration.getAttributeName());
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesDefaultAnalyzerAndCallsTokenStream() throws Throwable  {
        // No Comments were added
        DefaultLuceneDocumentFactory.DefaultAnalyzer defaultLuceneDocumentFactory_DefaultAnalyzer = new DefaultLuceneDocumentFactory.DefaultAnalyzer();
        StringReader arg1 = new StringReader("Q*9(_F)}vKooyZ");
        TokenStream tokenStream = defaultLuceneDocumentFactory_DefaultAnalyzer.tokenStream(".;", (Reader) arg1);
        assertNotNull(tokenStream);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetHandleFieldNameThrowsRuntimeException() throws Throwable  {
        DefaultLuceneDocumentFactory defaultLuceneDocumentFactory = new DefaultLuceneDocumentFactory();
        try {
        defaultLuceneDocumentFactory.getHandleFieldName("This is a sample handle");
        fail("Expecting exception: RuntimeException");
        } catch(RuntimeException e) {
        // Verify that the expected exception was thrown
        verifyException("org.petsoar.search.lucene.DefaultLuceneDocumentFactory", e);}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreateAnalyzer() throws Throwable  {
        // Given a DefaultLuceneDocumentFactory instance
        DefaultLuceneDocumentFactory defaultLuceneDocumentFactory = new DefaultLuceneDocumentFactory();
        
        // When we call the createAnalyzer method with this factory
        Analyzer createAnalyzer = defaultLuceneDocumentFactory.createAnalyzer();
        
        // Then it should return a non-null Analyzer instance
        assertNotNull(createAnalyzer);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreateDocumentThrowsRuntimeException() throws Throwable  {
        DefaultLuceneDocumentFactory.FieldConfiguration fieldConfiguration = new DefaultLuceneDocumentFactory.FieldConfiguration();
        DefaultLuceneDocumentFactory defaultLuceneDocumentFactory = new DefaultLuceneDocumentFactory();
        
        try {
        defaultLuceneDocumentFactory.createDocument(fieldConfiguration);
        fail("Expected exception not thrown");
        } catch (RuntimeException e) {
        // The following line is added to verify that the correct exception is being caught
        assertEquals("org.petsoar.search.lucene.DefaultLuceneDocumentFactory", e.getClass().getName());
        
        // The following line is added to verify that the expected message is being returned
        String expectedMessage = "Couldn't load lucene config file successfully, file=" + fieldConfiguration;
        assertEquals(expectedMessage, e.getMessage());}
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetHandleAttributeNameThrowsRuntimeException() throws Throwable  {
        // rollbacked to evosuite
        DefaultLuceneDocumentFactory arg0 = new DefaultLuceneDocumentFactory();
        // Undeclared exception!
        try { 
          arg0.getHandleAttributeName(arg0);
          fail("Expecting exception: RuntimeException");
        
        } catch(RuntimeException e) {
           //
           // Couldn't load lucene config file successfully, file=class org.petsoar.search.lucene.DefaultLuceneDocumentFactory
           //
           verifyException("org.petsoar.search.lucene.DefaultLuceneDocumentFactory", e);
        }
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testAddFieldConfiguration() throws Throwable  {
        // Given a field configuration object
        DefaultLuceneDocumentFactory.FieldConfiguration fieldConfig = new DefaultLuceneDocumentFactory.FieldConfiguration();
        
        // And a class configuration object with the field configuration added
        DefaultLuceneDocumentFactory.ClassConfiguration classConfig = new DefaultLuceneDocumentFactory.ClassConfiguration();
        classConfig.addFieldConfiguration(fieldConfig);
        
        // When we call getFieldName on the field configuration object
        String result = fieldConfig.getFieldName();
        
        // Then the result should be null, since the field name has not been set yet
        assertNull(result);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesClassConfigurationAndCallsToString() throws Throwable  {
        // Arrange
        DefaultLuceneDocumentFactory.ClassConfiguration classConfiguration = new DefaultLuceneDocumentFactory.ClassConfiguration();
        
        // Act
        String actual = classConfiguration.toString();
        
        // Assert
        assertNotNull(actual);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testCreatesClassConfigurationAndCallsEquals() throws Throwable  {
        // No Comments were added
        DefaultLuceneDocumentFactory.ClassConfiguration defaultLuceneDocumentFactory_ClassConfiguration = new DefaultLuceneDocumentFactory.ClassConfiguration();
        boolean equals = defaultLuceneDocumentFactory_ClassConfiguration.equals("org.petsoar.search.lucene.DefaultLuceneDocumentFactory$FieldConfiguration@1[attributeName=<null>,fieldName=<null>,type=<null>]");
        assertFalse(equals);
    }
  
    @Test
    @Timeout(value = 4000 , unit = TimeUnit.MILLISECONDS)
    public void testGetFieldConfigurations() throws Throwable  {
        // rollbacked to evosuite
        DefaultLuceneDocumentFactory.ClassConfiguration defaultLuceneDocumentFactory_ClassConfiguration = new DefaultLuceneDocumentFactory.ClassConfiguration();
        List fieldConfigurations = defaultLuceneDocumentFactory_ClassConfiguration.getFieldConfigurations();
        assertEquals(0, fieldConfigurations.size());
    }
  }
  