Sign In   Register
  Tuesday, 27 July 2021
  1 Replies
  191 Visits
0
Votes
Undo
  Subscribe

Hi,

when using a Fluent Form Prefill, the service returns a 'Document', so you can use this pattern in unit tests to examine the prefill formXml:

Document result = (Document) new ServiceInvoker(svcDef)
.setLogger(logger)
.invoke(params)

assert result != null

Path path = new Path(result)

assert "9999" == path.val("//Customer/Address/PostCode")

However, when using a Fluent Function, with trigger = Open, that returns a FuncResult, not the actual funcResult.appDoc or similar.

How can I unit test a Fluent Function (Open) so that I can verify the prefill data?

How do I get access to the 'appDoc'?

I have tried a few options, like MockTxn, MockFuncParam, MockDocument, Document with Test XML Data, but all results return the seed formXml with no data, or other results that aren't correct.

Thanks

Mark

3 months ago
·
#14209
Accepted Answer
0
Votes
Undo

Solved.

It seems that the xmlDoc used as the parameter to the funcParam is available after the function has been called, even though it isn't present explicitly as part of the funcResult.

So, using code like the following in a test gives access to the 'prefill' content, so I can assert that the function performs as expected.

I set the 'Test XML Data' as the seed xml for the form.

String xmlData = testParams.get("Test XML Data")
XmlDoc xmlDoc = new XmlDoc(xmlData)

MockRequest mockRequest = new MockRequest()
mockRequest.setParameter("channel", "TEST")

Txn txn = new MockVoBuilder().createTxnOpened()
FuncParam funcParam = new FuncParam(FuncParam.TRIGGER_FORM_OPEN, xmlDoc.document, [:], mockRequest, svcDef, txn, null)

FormFuncResult result = (FormFuncResult) new ServiceInvoker(svcDef).invoke("funcParam", funcParam)

logger.debug(xmlDoc.getText("//Channel"))

assert xmlDoc.getText("//Channel") == "TEST"

That wasn't obvious to me while building tests and using the funcParam and funcResult, but it seems to work.

So, I hope that helps someone.

Thanks

Mark

Mark Murray selected the reply #14209 as the answer for this post — 3 months ago
3 months ago
·
#14209
Accepted Answer
0
Votes
Undo

Solved.

It seems that the xmlDoc used as the parameter to the funcParam is available after the function has been called, even though it isn't present explicitly as part of the funcResult.

So, using code like the following in a test gives access to the 'prefill' content, so I can assert that the function performs as expected.

I set the 'Test XML Data' as the seed xml for the form.

String xmlData = testParams.get("Test XML Data")
XmlDoc xmlDoc = new XmlDoc(xmlData)

MockRequest mockRequest = new MockRequest()
mockRequest.setParameter("channel", "TEST")

Txn txn = new MockVoBuilder().createTxnOpened()
FuncParam funcParam = new FuncParam(FuncParam.TRIGGER_FORM_OPEN, xmlDoc.document, [:], mockRequest, svcDef, txn, null)

FormFuncResult result = (FormFuncResult) new ServiceInvoker(svcDef).invoke("funcParam", funcParam)

logger.debug(xmlDoc.getText("//Channel"))

assert xmlDoc.getText("//Channel") == "TEST"

That wasn't obvious to me while building tests and using the funcParam and funcResult, but it seems to work.

So, I hope that helps someone.

Thanks

Mark

There are no replies made for this post yet.
Be one of the first to reply to this post!

Q&A Forum - Tips

The purpose of the Temenos Journey Manager platform (TJM) Q&A forum is for all clients and partners to seek help...

Read More

Not a member?

Register to ask a question and access to more content.

Join now

Looking for something else?

You can request access to:

  • Courses
  • Full Release Notes
  • Product Downloads
  • SDK

Request access

Leader Board

1
Mark Murray
User's Points: 1360
2
Lin Vanoevelen
User's Points: 1046
3
Julio Berrueco Pinto
User's Points: 715
4
Matthew White
User's Points: 386
5
Chad Thomas
User's Points: 300