Search in sources :

Example 1 with Content

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);
}
Also used : Paragraph(org.finos.symphony.toolkit.workflow.content.Paragraph) Arrays(java.util.Arrays) UnorderedList(org.finos.symphony.toolkit.workflow.content.UnorderedList) Table(org.finos.symphony.toolkit.workflow.content.Table) User(org.finos.symphony.toolkit.workflow.content.User) Word(org.finos.symphony.toolkit.workflow.content.Word) WorkMode(org.finos.symphony.toolkit.workflow.annotations.WorkMode) Autowired(org.springframework.beans.factory.annotation.Autowired) Response(org.finos.symphony.toolkit.workflow.response.Response) ChatVariable(org.finos.symphony.toolkit.workflow.annotations.ChatVariable) Controller(org.springframework.stereotype.Controller) Collectors(java.util.stream.Collectors) ZoneId(java.time.ZoneId) History(org.finos.symphony.toolkit.workflow.history.History) List(java.util.List) Addressable(org.finos.symphony.toolkit.workflow.content.Addressable) MessageResponse(org.finos.symphony.toolkit.workflow.response.MessageResponse) Map(java.util.Map) ChatRequest(org.finos.symphony.toolkit.workflow.annotations.ChatRequest) Optional(java.util.Optional) ChatButton(org.finos.symphony.toolkit.workflow.annotations.ChatButton) ChatResponseBody(org.finos.symphony.toolkit.workflow.annotations.ChatResponseBody) Content(org.finos.symphony.toolkit.workflow.content.Content) Table(org.finos.symphony.toolkit.workflow.content.Table) Content(org.finos.symphony.toolkit.workflow.content.Content) MessageResponse(org.finos.symphony.toolkit.workflow.response.MessageResponse) UnorderedList(org.finos.symphony.toolkit.workflow.content.UnorderedList) List(java.util.List) ChatRequest(org.finos.symphony.toolkit.workflow.annotations.ChatRequest)

Example 2 with Content

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>()));
}
Also used : MessageMatcher(org.finos.symphony.toolkit.workflow.java.mapping.MessageMatcher) HashMap(java.util.HashMap) Content(org.finos.symphony.toolkit.workflow.content.Content) Test(org.junit.jupiter.api.Test)

Example 3 with Content

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")));
}
Also used : Content(org.finos.symphony.toolkit.workflow.content.Content) Test(org.junit.jupiter.api.Test)

Example 4 with Content

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>()));
}
Also used : MessageMatcher(org.finos.symphony.toolkit.workflow.java.mapping.MessageMatcher) HashMap(java.util.HashMap) Content(org.finos.symphony.toolkit.workflow.content.Content) Test(org.junit.jupiter.api.Test)

Example 5 with Content

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));
}
Also used : EntityJson(org.finos.symphony.toolkit.json.EntityJson) Table(org.finos.symphony.toolkit.workflow.content.Table) Content(org.finos.symphony.toolkit.workflow.content.Content) Test(org.junit.jupiter.api.Test)

Aggregations

Content (org.finos.symphony.toolkit.workflow.content.Content)6 Test (org.junit.jupiter.api.Test)4 HashMap (java.util.HashMap)2 Table (org.finos.symphony.toolkit.workflow.content.Table)2 MessageMatcher (org.finos.symphony.toolkit.workflow.java.mapping.MessageMatcher)2 StringReader (java.io.StringReader)1 ZoneId (java.time.ZoneId)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Collectors (java.util.stream.Collectors)1 SAXParser (javax.xml.parsers.SAXParser)1 EntityJson (org.finos.symphony.toolkit.json.EntityJson)1 ChatButton (org.finos.symphony.toolkit.workflow.annotations.ChatButton)1 ChatRequest (org.finos.symphony.toolkit.workflow.annotations.ChatRequest)1 ChatResponseBody (org.finos.symphony.toolkit.workflow.annotations.ChatResponseBody)1 ChatVariable (org.finos.symphony.toolkit.workflow.annotations.ChatVariable)1 WorkMode (org.finos.symphony.toolkit.workflow.annotations.WorkMode)1 Addressable (org.finos.symphony.toolkit.workflow.content.Addressable)1