<commit_before>package org.testeditor.tcl.dsl.jvmmodel.builder

import org.junit.Test
import org.testeditor.dsl.common.testing.DummyFixture
import org.testeditor.dsl.common.testing.DummyLocatorStrategy
import org.testeditor.fixture.core.AbstractTestCase

class TestCaseWithSeparateConfigTest extends AbstractStandaloneBuilderTest {

	@Test
	def void testGenerateWithSeparateConfiguration() {
		// given
		val configSource = '''
			package com.example
			
			config MyConfig
			
			Setup:
				Component: GreetingApplication
				- Start application "org.testeditor.swing.exammple.Greetings"
			
			Cleanup:
				Component: GreetingApplication
				- Stop application
		'''
		val testSource = '''
			package com.example
						
			# SimpleTest
			
			config MyConfig
			
			* Test Step
				Component: GreetingApplication
				- Wait for "3" seconds
		'''
		writeFile("src/com/example/Dummy.aml", DummyFixture.amlModel)
		writeFile("src/com/example/MyConfig.config", configSource)
		writeFile("src/com/example/SimpleTest.tcl", testSource)
		classPathEntries += DummyFixture.classPathEntry
		classPathEntries += DummyLocatorStrategy.classPathEntry
		classPathEntries += AbstractTestCase.classPathEntry

		// when
		builder.launch

		// then
		val configOutput = readFile("src-gen/com/example/MyConfig.java").removeJavaDoc
		val testOutput = readFile("src-gen/com/example/SimpleTest.java").removeJavaDoc
		configOutput.assertEquals('''
			package com.example;
			
			import org.junit.After;
			import org.junit.Before;
			import org.testeditor.dsl.common.testing.DummyFixture;
			import org.testeditor.fixture.core.AbstractTestCase;
			import org.testeditor.fixture.core.TestRunReporter;
			
			@SuppressWarnings("all")
			public abstract class MyConfig extends AbstractTestCase {
			  protected DummyFixture dummyFixture = new DummyFixture();
			  
			  @Before
			  public void setupMyConfig() throws Exception {
			    
			    reporter.enter(TestRunReporter.SemanticUnit.COMPONENT, "GreetingApplication");
			    
			    reporter.enter(TestRunReporter.SemanticUnit.STEP, "Start application \"org.testeditor.swing.exammple.Greetings\"");
			    dummyFixture.startApplication("org.testeditor.swing.exammple.Greetings");
			  }
			  
			  @After
			  public void cleanupMyConfig() throws Exception {
			    
			    reporter.enter(TestRunReporter.SemanticUnit.COMPONENT, "GreetingApplication");
			    
			    reporter.enter(TestRunReporter.SemanticUnit.STEP, "Stop application");
			    dummyFixture.stopApplication();
			  }
			}
		'''.toString)
		testOutput.assertEquals('''
			package com.example;
			
			import com.example.MyConfig;
			import org.junit.Test;
			import org.testeditor.fixture.core.TestRunReporter;
			
			@SuppressWarnings("all")
			public class SimpleTest extends MyConfig {
			  @Test
			  public void execute() throws Exception {
			    
			    reporter.enter(TestRunReporter.SemanticUnit.SPECIFICATION_STEP, "Test Step");
			    
			    reporter.enter(TestRunReporter.SemanticUnit.COMPONENT, "GreetingApplication");
			    
			    reporter.enter(TestRunReporter.SemanticUnit.STEP, "Wait for \"3\" seconds");
			    dummyFixture.waitSeconds(3);
			  }
			}
		'''.toString)
	}
	
	
	@Test
	def void testGenerateConfigurationWithUnknownFixture() {
		// given
		val configSource = '''
			package com.example
			
			config MyConfig
			
			Setup:
				Component: GreetingApplication
				- Start application "org.testeditor.swing.exammple.Greetings"
				- do something
			
			Cleanup:
				Component: GreetingApplication
				- Stop application
		'''
		val testSource = '''
			package com.example
						
			# SimpleTest
			
			config MyConfig
			
			* Test Step
				Component: GreetingApplication
				- Wait for "3" seconds
		'''
		writeFile("src/com/example/Dummy.aml", DummyFixture.amlModel)
		writeFile("src/com/example/MyConfig.config", configSource)
		writeFile("src/com/example/SimpleTest.tcl", testSource)
		classPathEntries += DummyFixture.classPathEntry
		classPathEntries += DummyLocatorStrategy.classPathEntry
		classPathEntries += AbstractTestCase.classPathEntry

		// when
		builder.launch

		// then
		val configOutput = readFile("src-gen/com/example/MyConfig.java").removeJavaDoc
		val testOutput = readFile("src-gen/com/example/SimpleTest.java").removeJavaDoc
		configOutput.assertContains('''
			org.junit.Assert.fail("Template 'do something' cannot be resolved with any known macro/fixture. Please check your Configuration 'MyConfig' in line 8.");
		'''.toString)
	}
	

}<commit_msg>TE-493 remove unused line (reduce warnings)<commit_after>package org.testeditor.tcl.dsl.jvmmodel.builder

import org.junit.Test
import org.testeditor.dsl.common.testing.DummyFixture
import org.testeditor.dsl.common.testing.DummyLocatorStrategy
import org.testeditor.fixture.core.AbstractTestCase

class TestCaseWithSeparateConfigTest extends AbstractStandaloneBuilderTest {

	@Test
	def void testGenerateWithSeparateConfiguration() {
		// given
		val configSource = '''
			package com.example
			
			config MyConfig
			
			Setup:
				Component: GreetingApplication
				- Start application "org.testeditor.swing.exammple.Greetings"
			
			Cleanup:
				Component: GreetingApplication
				- Stop application
		'''
		val testSource = '''
			package com.example
						
			# SimpleTest
			
			config MyConfig
			
			* Test Step
				Component: GreetingApplication
				- Wait for "3" seconds
		'''
		writeFile("src/com/example/Dummy.aml", DummyFixture.amlModel)
		writeFile("src/com/example/MyConfig.config", configSource)
		writeFile("src/com/example/SimpleTest.tcl", testSource)
		classPathEntries += DummyFixture.classPathEntry
		classPathEntries += DummyLocatorStrategy.classPathEntry
		classPathEntries += AbstractTestCase.classPathEntry

		// when
		builder.launch

		// then
		val configOutput = readFile("src-gen/com/example/MyConfig.java").removeJavaDoc
		val testOutput = readFile("src-gen/com/example/SimpleTest.java").removeJavaDoc
		configOutput.assertEquals('''
			package com.example;
			
			import org.junit.After;
			import org.junit.Before;
			import org.testeditor.dsl.common.testing.DummyFixture;
			import org.testeditor.fixture.core.AbstractTestCase;
			import org.testeditor.fixture.core.TestRunReporter;
			
			@SuppressWarnings("all")
			public abstract class MyConfig extends AbstractTestCase {
			  protected DummyFixture dummyFixture = new DummyFixture();
			  
			  @Before
			  public void setupMyConfig() throws Exception {
			    
			    reporter.enter(TestRunReporter.SemanticUnit.COMPONENT, "GreetingApplication");
			    
			    reporter.enter(TestRunReporter.SemanticUnit.STEP, "Start application \"org.testeditor.swing.exammple.Greetings\"");
			    dummyFixture.startApplication("org.testeditor.swing.exammple.Greetings");
			  }
			  
			  @After
			  public void cleanupMyConfig() throws Exception {
			    
			    reporter.enter(TestRunReporter.SemanticUnit.COMPONENT, "GreetingApplication");
			    
			    reporter.enter(TestRunReporter.SemanticUnit.STEP, "Stop application");
			    dummyFixture.stopApplication();
			  }
			}
		'''.toString)
		testOutput.assertEquals('''
			package com.example;
			
			import com.example.MyConfig;
			import org.junit.Test;
			import org.testeditor.fixture.core.TestRunReporter;
			
			@SuppressWarnings("all")
			public class SimpleTest extends MyConfig {
			  @Test
			  public void execute() throws Exception {
			    
			    reporter.enter(TestRunReporter.SemanticUnit.SPECIFICATION_STEP, "Test Step");
			    
			    reporter.enter(TestRunReporter.SemanticUnit.COMPONENT, "GreetingApplication");
			    
			    reporter.enter(TestRunReporter.SemanticUnit.STEP, "Wait for \"3\" seconds");
			    dummyFixture.waitSeconds(3);
			  }
			}
		'''.toString)
	}
	
	
	@Test
	def void testGenerateConfigurationWithUnknownFixture() {
		// given
		val configSource = '''
			package com.example
			
			config MyConfig
			
			Setup:
				Component: GreetingApplication
				- Start application "org.testeditor.swing.exammple.Greetings"
				- do something
			
			Cleanup:
				Component: GreetingApplication
				- Stop application
		'''
		val testSource = '''
			package com.example
						
			# SimpleTest
			
			config MyConfig
			
			* Test Step
				Component: GreetingApplication
				- Wait for "3" seconds
		'''
		writeFile("src/com/example/Dummy.aml", DummyFixture.amlModel)
		writeFile("src/com/example/MyConfig.config", configSource)
		writeFile("src/com/example/SimpleTest.tcl", testSource)
		classPathEntries += DummyFixture.classPathEntry
		classPathEntries += DummyLocatorStrategy.classPathEntry
		classPathEntries += AbstractTestCase.classPathEntry

		// when
		builder.launch

		// then
		val configOutput = readFile("src-gen/com/example/MyConfig.java").removeJavaDoc
		configOutput.assertContains('''
			org.junit.Assert.fail("Template 'do something' cannot be resolved with any known macro/fixture. Please check your Configuration 'MyConfig' in line 8.");
		'''.toString)
	}
	

}
{'fraction_non_alphanumeric': 0.09847047002344535, 'fraction_numerical': 0.001451378809869376, 'mean_word_length': 3.577414409810935, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '836792', 'n_tokens_mistral': 3192, 'n_tokens_neox': 2632, 'n_words': 476}