21
Views
2
Comments
Solved
[Testing Framework] MockQueryResults with JOIN's
testing-framework
Reactive icon
Forge asset by Leonardo Fernandes
Application Type
Reactive

Hi,

Can you explain on how to use the MockQueryResults action with multiple aggregate sources?

For example: 


the JSON Deserialize only allows selection of 1 Entity:

A list of Record is not possible here. 

When creating a Structure:

and deserialize to that:

it does not seem to map the values to the aggregate. 


Stack

[1] Exception has been thrown by the target of an invocation.   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)   at OutSystems.NssTestingInstrumentation.CodeInstrumentation.ArgumentMapper.InvokeMappingArguments(MethodBase from, MethodBase to, Object[] fromArgs)   at OutSystems.NssTestingInstrumentation.CodeInstrumentation.Instrumentation.Prefix_ServerAction(MethodBase __originalMethod, Object[] __args)   at ssPDCZorg_TestSuite.Actions.ActionProxyToGetSQAPIByZorgProductCodeAndVersion_Patch1(HeContext heContext, String inParamZorgProductCode, Int32 inParamVersie, Boolean& outParamIsLoketInschrijvingViaSQAPI, STStr_SQAPIStructure& outParamSQAPI)   at ssPDCZorg_TestSuite.CsRESTExpose.CsDemo_PDCZorg_SQAPI.CsDemo_PDCZorg_SQAPIControllerFlows.FlowDemo_PDCZorg_SQAPIActionSQAPI_GetSQAPIByZorgProductCodeAndVersion(HeContext heContext)


[2] Sequence contains more than one element   at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)   at OutSystems.NssTestingInstrumentation.CodeInstrumentation.ArgumentMapper.CastSimpleRecordToRecord(IRecord simpleRecord, Type recordType)   at OutSystems.NssTestingInstrumentation.CodeInstrumentation.ArgumentMapper.CastList(IOSList value, Type type)   at OutSystems.NssTestingInstrumentation.CodeInstrumentation.Instrumentation.Prefix_Query(MethodInfo __originalMethod, Object[] __args, Object& __result)   at ssPDCZorg_BL.Actions+FuncActionGetSQAPIByZorgProductCodeAndVersion.datasetGetZorgproductLoketAndSQAPI_Patch1(HeContext heContext, Int32 maxRecords, IterationMultiplicity multiplicity, Int64& outParamCount, Int32 qpinZorgproduct_Versie, String qpstZorgproduct_Code)   at ssPDCZorg_BL.Actions.ActionGetSQAPIByZorgProductCodeAndVersion(HeContext heContext, String inParamZorgProductCode, Int32 inParamVersie, Boolean& outParamIsLoketInschrijvingViaSQAPI, STStr_SQAPIStructure& outParamSQAPI)

2023-04-19 18-38-51
Bas de Jong
Solution

Update: We managed to fix this by creating a local variable of type Record List with the aggregates in the correct order (and case sensitive names). By using ListAppend it works! 

2019-07-08 11-04-35
Leonardo Fernandes
 
MVP

Hi Bas.

This is indeed a limitation of the JSON deserialization, that you cannot create a record list type. But you can create a structure and use it in the JSON Deserialize.

For example, this query:


Can be mocked with a JSON node like the following:


Provided the FindEntityQueryResults is a structure you define in your test module.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.