use of org.finos.symphony.toolkit.workflow.form.ButtonList in project spring-bot by finos.
the class TestFormMessageML method testValidation.
@Test
public void testValidation() throws Exception {
TestObject a = new TestObject("83274239874", true, true, "rob", 234786, 2138);
SymphonyRoom theRoom = new SymphonyRoom("tesxt room", "abc123");
ButtonList bl = new ButtonList();
Button submit = new Button("submit", Type.ACTION, "GO");
bl.add(submit);
Errors eh = ErrorHelp.createErrorHolder();
validator.validate(a, eh);
WorkResponse wr = new WorkResponse(theRoom, a, WorkMode.EDIT, bl, ElementsHandler.convertErrorsToMap(eh));
testTemplating(wr, "abc123", "testValidation.ml", "testValidation.json");
}
use of org.finos.symphony.toolkit.workflow.form.ButtonList in project spring-bot by finos.
the class TestFormMessageML method createWeirdFieldsWorkResponse.
protected WorkResponse createWeirdFieldsWorkResponse(WorkMode wm) {
SymphonyRoom theRoom = new SymphonyRoom("tesxt room", "abc123");
SymphonyUser someUser = new SymphonyUser(2678l, "bob", "bob@example.com");
WeirdObject to4 = new WeirdObject();
to4.setTheId(new HashTag("adf360dd-06fe-43a4-9a62-2c17fe2deefa"));
to4.setC(Choice.C);
to4.setSomeUser(someUser);
to4.setCashTag(new CashTag("rameses"));
to4.setB(true);
to4.setC(Choice.B);
Button submit = new Button("submit", Type.ACTION, "GO");
WorkResponse wr = new WorkResponse(theRoom, to4, wm);
ButtonList bl = (ButtonList) wr.getData().get(ButtonList.KEY);
bl.add(submit);
return wr;
}
use of org.finos.symphony.toolkit.workflow.form.ButtonList in project spring-bot by finos.
the class ButtonsResponseHandler method accept.
@Override
public void accept(Response t) {
if (t instanceof WorkResponse) {
Object o = ((WorkResponse) t).getFormObject();
WorkMode wm = ((WorkResponse) t).getMode();
ButtonList obl = (ButtonList) ((WorkResponse) t).getData().get(ButtonList.KEY);
if ((obl != null) && (obl.getContents().size() > 0)) {
return;
}
obl = new ButtonList();
((WorkResponse) t).getData().put(ButtonList.KEY, obl);
final ButtonList bl = obl;
initExposedHandlerMappings();
exposedHandlerMappings.stream().flatMap(hm -> hm.getAllHandlers(t.getAddress(), null).stream()).filter(cm -> exposedMatchesObject(cm.getMapping(), o)).filter(cm -> cm.isButtonFor(o, wm)).forEach(cm -> {
ChatButton e = cm.getMapping();
String value = cm.getUniqueName();
String text = e.buttonText();
text = StringUtils.hasText(text) ? text : formatFieldName(cm.getHandlerMethod().getMethod().getName());
bl.add(new Button(value, Type.ACTION, text));
});
Collections.sort((List<Button>) bl.getContents());
}
}
Aggregations