Search in sources :

Example 1 with CallFieldValue

use of org.drools.workbench.models.testscenarios.shared.CallFieldValue in project drools by kiegroup.

the class MethodExecutorTest method testCallMethodOnStandardArgumentOnFact.

@Test
public void testCallMethodOnStandardArgumentOnFact() throws Exception {
    HashMap<String, Object> populatedData = new HashMap<String, Object>();
    MethodExecutor methodExecutor = new MethodExecutor(populatedData);
    Cheesery listChesse = new Cheesery();
    listChesse.setTotalAmount(1000);
    populatedData.put("cheese", listChesse);
    CallMethod mCall = new CallMethod();
    mCall.setVariable("cheese");
    mCall.setMethodName("setTotalAmount");
    CallFieldValue field = new CallFieldValue();
    field.value = "1005";
    mCall.addFieldValue(field);
    methodExecutor.executeMethod(mCall);
    assertTrue(listChesse.getTotalAmount() == 1005);
}
Also used : HashMap(java.util.HashMap) Cheesery(org.drools.workbench.models.testscenarios.backend.Cheesery) CallMethod(org.drools.workbench.models.testscenarios.shared.CallMethod) CallFieldValue(org.drools.workbench.models.testscenarios.shared.CallFieldValue) Test(org.junit.Test)

Example 2 with CallFieldValue

use of org.drools.workbench.models.testscenarios.shared.CallFieldValue in project drools by kiegroup.

the class MethodExecutorTest method testCallMethodOnClassArgumentOnFact.

@Test
public void testCallMethodOnClassArgumentOnFact() throws Exception {
    HashMap<String, Object> populatedData = new HashMap<String, Object>();
    MethodExecutor methodExecutor = new MethodExecutor(populatedData);
    Cheesery listChesse = new Cheesery();
    listChesse.setTotalAmount(1000);
    populatedData.put("cheese", listChesse);
    Cheesery.Maturity m = Cheesery.Maturity.OLD;
    populatedData.put("m", m);
    CallMethod mCall = new CallMethod();
    mCall.setVariable("cheese");
    mCall.setMethodName("setMaturity");
    CallFieldValue field = new CallFieldValue();
    field.value = "=m";
    mCall.addFieldValue(field);
    methodExecutor.executeMethod(mCall);
    assertTrue(listChesse.getMaturity().equals(m));
    assertTrue(listChesse.getMaturity() == m);
}
Also used : HashMap(java.util.HashMap) Cheesery(org.drools.workbench.models.testscenarios.backend.Cheesery) CallMethod(org.drools.workbench.models.testscenarios.shared.CallMethod) CallFieldValue(org.drools.workbench.models.testscenarios.shared.CallFieldValue) Test(org.junit.Test)

Example 3 with CallFieldValue

use of org.drools.workbench.models.testscenarios.shared.CallFieldValue in project drools by kiegroup.

the class MethodExecutor method build.

private String build(CallMethod callMethod, Map<String, Object> vars) {
    StringBuilder methodCallAsSting = new StringBuilder();
    methodCallAsSting.append("__fact__." + callMethod.getMethodName());
    methodCallAsSting.append("(");
    for (int i = 0; i < callMethod.getCallFieldValues().length; i++) {
        CallFieldValue field = callMethod.getCallFieldValues()[i];
        if (field.hasValue()) {
            String variableId = String.format("__val%d__", i);
            vars.put(variableId, getFieldValue(field));
            methodCallAsSting.append(variableId);
            if (isThisTheLastVariable(callMethod, i)) {
                methodCallAsSting.append(",");
            }
        }
    }
    methodCallAsSting.append(")");
    return methodCallAsSting.toString();
}
Also used : CallFieldValue(org.drools.workbench.models.testscenarios.shared.CallFieldValue)

Example 4 with CallFieldValue

use of org.drools.workbench.models.testscenarios.shared.CallFieldValue in project drools by kiegroup.

the class MethodExecutorTest method testCallMethodOnClassArgumentAndOnArgumentStandardOnFact.

@Test
public void testCallMethodOnClassArgumentAndOnArgumentStandardOnFact() throws Exception {
    HashMap<String, Object> populatedData = new HashMap<String, Object>();
    MethodExecutor methodExecutor = new MethodExecutor(populatedData);
    Cheesery listCheese = new Cheesery();
    listCheese.setTotalAmount(1000);
    populatedData.put("cheese", listCheese);
    Cheesery.Maturity m = Cheesery.Maturity.YOUNG;
    populatedData.put("m", m);
    CallMethod mCall = new CallMethod();
    mCall.setVariable("cheese");
    mCall.setMethodName("setMaturityAndStatus");
    CallFieldValue field = new CallFieldValue();
    field.value = "=m";
    mCall.addFieldValue(field);
    CallFieldValue field2 = new CallFieldValue();
    field2.value = "1";
    mCall.addFieldValue(field2);
    methodExecutor.executeMethod(mCall);
    assertEquals(m, listCheese.getMaturity());
    assertEquals(1, listCheese.getStatus());
}
Also used : HashMap(java.util.HashMap) Cheesery(org.drools.workbench.models.testscenarios.backend.Cheesery) CallMethod(org.drools.workbench.models.testscenarios.shared.CallMethod) CallFieldValue(org.drools.workbench.models.testscenarios.shared.CallFieldValue) Test(org.junit.Test)

Example 5 with CallFieldValue

use of org.drools.workbench.models.testscenarios.shared.CallFieldValue in project drools-wb by kiegroup.

the class CallMethodWidget method doLayout.

private void doLayout() {
    layout.clear();
    layout.setWidget(0, 0, getSetterLabel());
    FlexTable inner = new FlexTable();
    int i = 0;
    for (CallFieldValue val : mCall.getCallFieldValues()) {
        inner.setWidget(i, 0, fieldSelector(val));
        inner.setWidget(i, 1, valueEditor(val));
        i++;
    }
    layout.setWidget(0, 1, inner);
    layout.setWidget(0, 2, new DeleteCallMethodButton());
    ScenarioUtils.addBottomAndRightPaddingToTableCells(inner);
}
Also used : FlexTable(com.google.gwt.user.client.ui.FlexTable) CallFieldValue(org.drools.workbench.models.testscenarios.shared.CallFieldValue)

Aggregations

CallFieldValue (org.drools.workbench.models.testscenarios.shared.CallFieldValue)6 HashMap (java.util.HashMap)3 Cheesery (org.drools.workbench.models.testscenarios.backend.Cheesery)3 CallMethod (org.drools.workbench.models.testscenarios.shared.CallMethod)3 Test (org.junit.Test)3 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 FlexTable (com.google.gwt.user.client.ui.FlexTable)1 List (java.util.List)1 ListBox (org.gwtbootstrap3.client.ui.ListBox)1 Callback (org.uberfire.client.callbacks.Callback)1 FormStylePopup (org.uberfire.ext.widgets.common.client.common.popups.FormStylePopup)1