use of org.finos.symphony.toolkit.workflow.content.Table in project spring-bot by finos.
the class TestHandlerMapping method testTableMapping.
@Test
public void testTableMapping() throws Exception {
execute("process-table <table>\n" + " <tr>\n" + " <th>Thing</th><th>Thang</th>\n" + " </tr>\n" + " <tr>\n" + " <td>1</td><td>2</td>\n" + " </tr>\n" + " <tr>\n" + " <td>3</td><td>4</td>\n" + " </tr>\n" + " </table> <span class=\"entity\" data-entity-id=\"1\">@gaurav</span>");
Assertions.assertEquals("process-table", oc.lastMethod);
Assertions.assertEquals(2, oc.lastArguments.size());
Table firstArgument = (Table) oc.lastArguments.get(0);
List<Paragraph> expected = Arrays.asList(Paragraph.of(Arrays.asList(Word.of("thing"))), Paragraph.of(Arrays.asList(Word.of("thang"))));
Assertions.assertEquals(expected, firstArgument.getColumnNames());
Assertions.assertEquals(2, firstArgument.getData().size());
}
use of org.finos.symphony.toolkit.workflow.content.Table in project spring-bot by finos.
the class ReminderController method timezones.
@ChatRequest(value = "timezones", description = "List Time Zones")
public Response timezones(Addressable a) {
Map<String, List<String>> zoneMap = ZoneId.getAvailableZoneIds().stream().sorted().collect(Collectors.groupingBy(k -> {
int slashIndex = k.indexOf("/");
if (slashIndex == -1) {
return "none";
} else {
return k.substring(0, slashIndex);
}
}));
List<? extends Content> headers = Word.build("Region Zone");
List<List<? extends Content>> tableCells = zoneMap.keySet().stream().map(m -> Arrays.asList(Word.of(m), bulletsOf(zoneMap.get(m)))).collect(Collectors.toList());
Table t = Table.of(headers, tableCells);
return new MessageResponse(a, t);
}
use of org.finos.symphony.toolkit.workflow.content.Table in project spring-bot by finos.
the class TestMessageMLParser method testMessageWithTable.
@Test
public void testMessageWithTable() throws Exception {
Content c = smp.parse("<div data-format=\"PresentationML\" data-version=\"2.0\" class=\"wysiwyg\"><p><table class=\"pasted-table\"><thead><tr><th>Name</th><th>Age</th><th>Alive</th></tr></thead><tbody><tr><td>Jim</td><td>5</td><td>FALSE</td></tr><tr><td>James</td><td>7</td><td>TRUE</td></tr></tbody></table></p></div>", new EntityJson());
Assertions.assertEquals(Paragraph.of(Arrays.asList(Word.of("Age"))), c.getNth(Table.class, 0).get().getColumnNames().get(1));
Assertions.assertEquals(Paragraph.of(Arrays.asList(Word.of("TRUE"))), c.getNth(Table.class, 0).get().getData().get(1).get(2));
}
Aggregations