Search in sources :

Example 6 with MethodContext

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"));
}
Also used : SimpleMethod(org.apache.ofbiz.minilang.SimpleMethod) MethodContext(org.apache.ofbiz.minilang.method.MethodContext)

Example 7 with MethodContext

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();
}
Also used : MethodContext(org.apache.ofbiz.minilang.method.MethodContext)

Aggregations

MethodContext (org.apache.ofbiz.minilang.method.MethodContext)7 SimpleMethod (org.apache.ofbiz.minilang.SimpleMethod)3 HashMap (java.util.HashMap)1 MiniLangRuntimeException (org.apache.ofbiz.minilang.MiniLangRuntimeException)1