agave-jobs/jobs-core/src/test/java/org/iplantc/service/jobs/managers/launchers/StartupScriptJobMacroResolverTest.java
/**
	 * Ensures templated startup script values in the job's {@link ExecutionSystem} resolve the macros in the template.
	 * @param job the job to use to resolve the template macros
	 * @param pathToStartupScript the startupPath value to test
	 * @param expectedValue the expected value of the startup script after resolution
	 */
Ensures templated startup script values in the job's  ExecutionSystem resolve the macros in the template.
@param job the job to use to resolve the template macros
@param pathToStartupScript the startupPath value to test
@param expectedValue the expected value of the startup script after resolution
Ensures templated startup script values in the job ' s ExecutionSystem resolve the macros in the template . @param job the job to use to resolve the template macros @param pathToStartupScript the startupPath value to test @param expectedValue the expected value of the startup script after resolution
@Test(dataProvider = "testResolveStartupScriptMacrosReturnsResolvedStringProvider")
	public void testResolveStartupScriptMacrosReturnsResolvedString(Job job, String pathToStartupScript, String expectedValue) {
		try {
			ExecutionSystem executionSystem = new ExecutionSystem();
			executionSystem.setSystemId(job.getSystem());
			executionSystem.setStartupScript(pathToStartupScript);
			BatchQueue queue = new BatchQueue();
			queue.setName(job.getBatchQueue());
			queue.setMappedName("effective" + job.getBatchQueue());
			executionSystem.addBatchQueue(queue);
			StartupScriptJobMacroResolver resolver = mock(StartupScriptJobMacroResolver.class);
			when(resolver.getJob()).thenReturn(job);
			when(resolver.getExecutionSystem()).thenReturn(executionSystem);
			when(resolver.resolveStartupScriptSystemMacros(eq(executionSystem), any())).thenCallRealMethod();
			when(resolver.resolveStartupScriptJobMacro(eq(job), eq(executionSystem), any())).thenCallRealMethod();
			when(resolver.resolve()).thenCallRealMethod();
			String result = resolver.resolve();
			Assert.assertEquals(result, expectedValue, "Startup script macro should have resolved to the expected value");
		} catch (SystemArgumentException | JobMacroResolutionException e) {
			Assert.fail("Resolving an empty startup script should return empty string.", e);
		}
	}
@ Test ( dataProvider = "testResolveStartupScriptMacrosReturnsResolvedStringProvider" ) public void testResolveStartupScriptMacrosReturnsResolvedString ( Job job , String pathToStartupScript , String expectedValue ) { try { ExecutionSystem executionSystem = new ExecutionSystem ( ) ; executionSystem . setSystemId ( job . getSystem ( ) ) ; executionSystem . setStartupScript ( pathToStartupScript ) ; BatchQueue queue = new BatchQueue ( ) ; queue . setName ( job . getBatchQueue ( ) ) ; queue . setMappedName ( "effective" + job . getBatchQueue ( ) ) ; executionSystem . addBatchQueue ( queue ) ; StartupScriptJobMacroResolver resolver = mock ( StartupScriptJobMacroResolver . class ) ; when ( resolver . getJob ( ) ) . thenReturn ( job ) ; when ( resolver . getExecutionSystem ( ) ) . thenReturn ( executionSystem ) ; when ( resolver . resolveStartupScriptSystemMacros ( eq ( executionSystem ) , any ( ) ) ) . thenCallRealMethod ( ) ; when ( resolver . resolveStartupScriptJobMacro ( eq ( job ) , eq ( executionSystem ) , any ( ) ) ) . thenCallRealMethod ( ) ; when ( resolver . resolve ( ) ) . thenCallRealMethod ( ) ; String result = resolver . resolve ( ) ; Assert . assertEquals ( result , expectedValue , "Startup script macro should have resolved to the expected value" ) ; } catch ( SystemArgumentException | JobMacroResolutionException e ) { Assert . fail ( "Resolving an empty startup script should return empty string." , e ) ; } }
Ensures templated startup script values in the job's {@link ExecutionSystem} resolve the macros in the template.
Ensures templated startup script values in the job ' s { @link ExecutionSystem } resolve the macros in the template .