how to get Job instances instead of GeneratedItems out of DslScriptLoader.runDslEngine

67 views
Skip to first unread message

Torsten Reinhard

unread,
May 19, 2015, 10:38:33 AM5/19/15
to job-dsl...@googlegroups.com
Hi again,

How can I get the "Job" instances (as object), instead of a Set<GeneratedJob> that contains only the name/template of the Job ?

my Testclass currently looks like:

@Mixin(JobSpecMixin)
class StartupShutdownWebLogicSpec extends Specification {

   
JobParent jobParent = createJobParent()
   
JobManagement jm = jobParent.getJm()

   
@Unroll
   
void 'test XML output #environment'() {
        given
:
       
File file = new File('jobs', 'StartupShutdown-WebLogic.groovy')
        jm
.parameters.put("ENVIRONMENT", environment)
        jm
.parameters.put("GROUP", "pbdel")

       
when:
       
GeneratedItems generatedItems = DslScriptLoader.runDslEngine file.text, jm

       
then:
        generatedItems
.getJobs().size() == jobCount
       
       
where:
        environment
<< ["env1", "env3", "edu", "prv", "pre", "prod"]
        jobCount
<< [ 3, 3, 2, 2, 3, 3]
   
}
}



Should i use DslScriptLoader.runDslEngineForParent ? Or is there an easy way to transform GeneratedJob into Job instance ?

I need the Job instance for further assertions in my TestCase.

Thanx, Torsten


Matt Sheehan

unread,
May 19, 2015, 11:21:08 AM5/19/15
to job-dsl...@googlegroups.com

Hi Torsten.

I think runDslEngineForParent is the way to go for that.

ScriptRequest scriptRequest = new ScriptRequest(null, file.text, new File('.').toURI().toURL())
JobParent jobParent = DslScriptLoader.runDslEngineForParent scriptRequest, jm
println jobParent.referencedJobs.size()
--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/68c5cccc-61e2-4c0a-9531-ccf365ff6876%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages