use of org.apache.ofbiz.minilang.method.MethodContext in project ofbiz-framework by apache.
the class MiniLangTests method testFieldToResultOperation.
public void testFieldToResultOperation() throws Exception {
String simpleMethodXml = "<simple-method name=\"testFieldToResult\">" + " <set field=\"resultValue\" value=\"someResultValue\"/>" + " <set field=\"result1\" value=\"dynamicResultName\"/>" + " <field-to-result field=\"resultValue\" result-name=\"constantResultName\"/>" + " <field-to-result field=\"resultValue\" result-name=\"${result1}\"/>" + "</simple-method>";
SimpleMethod methodToTest = createSimpleMethod(simpleMethodXml);
MethodContext context = createServiceMethodContext();
String result = methodToTest.exec(context);
assertEquals("testFieldToResult success result", methodToTest.getDefaultSuccessCode(), result);
assertEquals("Plain expression result name set", "someResultValue", context.getResult("constantResultName"));
assertEquals("Nested expression result name set", "someResultValue", context.getResult("dynamicResultName"));
}
use of org.apache.ofbiz.minilang.method.MethodContext in project ofbiz-framework by apache.
the class SimpleMethod method runSimpleService.
public static Map<String, Object> runSimpleService(String xmlResource, String methodName, DispatchContext ctx, Map<String, ? extends Object> context, ClassLoader loader) throws MiniLangException {
MethodContext methodContext = new MethodContext(ctx, context, loader);
runSimpleMethod(xmlResource, methodName, methodContext);
return methodContext.getResults();
}
Aggregations