The MSPro Boomi Collection
About
ScriptEase For Boomi
ScriptEase For Boomi
  • ScriptEase
    • ScriptEase Development Environment
    • What AI says!
      • The limits of AI ...
  • Software Installation
    • Install a local Atom
  • Project Setup
    • IntelliJ Configuration
    • Verify Project Setup
  • Concepts
    • Use Test Data
  • Examples
    • 1 - Debug an existing process script
    • 9 - Aggregate Prices Example
  • Test Contexts
    • The Process Call Chain
  • Download
  • 💤Appendix
    • Script Templates
    • Java thoughts and recommendations
      • Chose newer JVM for local development
    • Boomi documentation and links
    • Initialize IntelliJ Templates
    • Script Contexts
  • Troubleshoot
    • Java the weed
    • ClassNotFoundException - GroovyStarter
    • Invalid VCS root mapping
    • An illegal reflective access operation has occurred
    • UnauthorizedAccess Error
  • Licensing
    • License Activation
    • Privacy Policy
Powered by GitBook
On this page
  • The Script Context Properties
  • Documents and Dynamic Document Properties
  • Dynamic Process Properties
  • Process Properties

Test Contexts

How to initialize documents, process and document properties

Last updated 6 months ago

In a Test Method you create and provide all the necessary information that is needed in the script. The Test Method creates the (see Concepts) and passes it to the script.

def context = new ProcessScriptContext(
        inputDocuments: [
                Document.fromText('''
                { 
                        "firstname" : "Walter", 
                        "lastname" : "Schmidt" 
                }''')
        ],
        dynProcPros: [ 
                DPP_Prop01: "2024",        
        ])
_testScript.run(context)

The Script Context Properties

The ScriptContext has the following properties:

public List<ProcessExecutionProperties> processCallChain;
public Map dynProcPros;
public Map procPros;
public final Map executionProperties;
  
// additional, ProcessScriptContext, only, properties
public List<Document> inputDocuments;
public final List<Document> outputDocuments;

See in the following chapter how to set and pass a content to a Process Script.

Documents and Dynamic Document Properties

IMPORTANT

Add input Documents from code (inline)

Use the Document.fromText() factory method to add any number of documents to the ProcessScriptContext.inputDocuments list.

ProcessScriptContext context = new ProcessScriptContext( inputDocuments: 
[
  Document.fromText('{ "firstname" : "Walter", "lastname" : "Schmidt" }'),
  Document.fromText( JsonOutput.toJson( [ firstname : "John", lastname : "Doe" ])),
  Document.fromText('''
  { 
    "firstname" : "Walter Jr.", 
    "lastname" : "Miller" 
  }'''), // Groovy multi-line text support
  
])
_testScript.run(context)
Add input Documents from file

Use a TestFilesHelper _testFiles instance to support access to files in a specified sub-directory.

Use the Document.fromFile() factory method to add any number of documents to the ProcessScriptContext.inputDocuments list.

final TestFilesHelper _testFiles = new TestFilesHelper( "testData", _sourceUri)

ProcessScriptContext context = new ProcessScriptContext(
  inputDocuments: [
    Document.fromFile( _testFiles.get( "doc01.json")),
    Document.fromFile( _testFiles.get( "doc01.json"))
  ])
_testScript.run(context)
Mixed input documents

You can mix fromText and fromFile as you want. The input documents do not care where they are coming from.

ProcessScriptContext context = new ProcessScriptContext(
  inputDocuments: [
    Document.fromFile( _testFiles.get( "doc01.json")),
    Document.fromText( '{ "firstname" : "Walter", "lastname" : "Schmidt" }')
  ])
Add input Documents with Dynamic Document Properties
// Add three documents with DDP_Prop1 and DDP_Prop02 each
ProcessScriptContext context = new ProcessScriptContext(
	inputDocuments: 
	[
		Document.fromText('Doc Content01', 
		[
			DDP_Prop01: "Doc1_Value1", 
			DDP_Prop02: "Doc1_P2"
		]),
		Document.fromText('Doc Content02', 
		[
			DDP_Prop01: "Doc2_Value1", 
			DDP_Prop02: "Doc2_P2"
		]),
		Document.fromText('Doc Content03', 
		[
			DPP_Prop01: "Doc3_Value1", 
			DPP_Prop02: "Doc3_P2"
		])
	])
_testScript.run(context)

Dynamic Process Properties

Standard
ProcessScriptContext context = new ProcessScriptContext(
  inputDocuments: [ ... ],
  dynProcPros: [
	DPP_DynProcProp01 : 1,
	DPP_DynProcProp02 : "Value01"
  ]
)
_testScript.run(context)
Explicit assignment to the script context
ProcessScriptContext context = new ProcessScriptContext()

context.dynProcPros.DPP_ProcPropString = "My Process Property"
context.dynProcPros.DPP_IntValue = 0

context.inputDocuments = [ Document.fromText('abc') ]

_testScript.run(context)

Process Properties

Process Properties need a little bit more effort. You need to provide

  • the Process Property Component Id (b91d87a4-7e8b-4a98-8ea8-a85e32bb5677) and

  • the Process Property Value Key (fcc4749d-5135-4eaa-a9cf-1b2ddc1ad12)

Process Property Ids are system independent. This means, these IDs won't change even if you copy or export process properties to a different account. The Ids remain the same!

Standard Initialization
final String ppMessageContext = "b91d87a4-7e8b-4a98-8ea8-a85e32bb5677"
final String ppKeyServiceIncident = "fcc4749d-5135-4eaa-a9cf-1b2ddc1ad12"
final String ppKeySenderAddress = "anotherGuid"

// Wrap keys in parenthesis 
// so that the variables (Ids) are taken and not the text as a string

ProcessScriptContext context = new ProcessScriptContext(
	inputDocuments: [Document.fromText("abc")],
	procPros: 
	[
		(ppMessageContext): [
				(ppKeyServiceIncident): "Incident_01",
				(ppKeySenderAddress)  : "mailto@google.com"
		]
	])

_testScript.run(context)

In this section you will learn how to initialize properties in a Test class to use them in a script. If you want to know how to access (read/write) properties in a Boomi Script, read here:

Use the Document.fromText() factory method to add any number of documents to the ProcessScriptContext.inputDocuments list. Dynamic Dcoument Properties are represented as , which is a key : value list.

ScriptContext
How to use Properties in a Boomi Script
Groovy Map
Process Property Ids