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);
}
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);
}
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();
}
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());
}
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);
}
Aggregations