use of org.finos.symphony.toolkit.workflow.content.Content 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.Content in project spring-bot by finos.
the class TestMessageMLParser method testMessageMatcherMore.
@Test
public void testMessageMatcherMore() throws Exception {
Content pattern = smp.parse("hello some words");
Content c2 = smp.parse("hello some words and some more words");
MessageMatcher m1 = new MessageMatcher(pattern);
Assertions.assertTrue(m1.consume(c2, new HashMap<ChatVariable, Object>()));
Content c3 = smp.parse("hello some different words");
Assertions.assertFalse(m1.consume(c3, new HashMap<ChatVariable, Object>()));
}
use of org.finos.symphony.toolkit.workflow.content.Content in project spring-bot by finos.
the class TestMessageMLParser method testRemoveSlash.
@Test
public void testRemoveSlash() throws Exception {
Content pattern = smp.parse("/hello some words");
Content c2 = smp.parse("bob some words");
Assertions.assertEquals(c2, pattern.replace(Word.of("/hello"), Word.of("bob")));
}
use of org.finos.symphony.toolkit.workflow.content.Content in project spring-bot by finos.
the class TestMessageMLParser method testMessageMatcherExact.
@Test
public void testMessageMatcherExact() throws Exception {
Content c = smp.parse("hello some words");
MessageMatcher m1 = new MessageMatcher(c);
Assertions.assertTrue(m1.consume(c, new HashMap<ChatVariable, Object>()));
}
use of org.finos.symphony.toolkit.workflow.content.Content 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