Search in sources :

Example 21 with EntityJson

use of org.finos.symphony.toolkit.json.EntityJson in project spring-bot by finos.

the class TestHandlerMapping method getMappingsFor.

private List<ChatMapping<ChatRequest>> getMappingsFor(String s) throws Exception {
    EntityJson jsonObjects = new EntityJson();
    Message m = smp.parse("<messageML>" + s + "</messageML>", jsonObjects);
    Action a = new SimpleMessageAction(null, null, m, jsonObjects);
    return hm.getHandlers(a);
}
Also used : Action(org.finos.symphony.toolkit.workflow.actions.Action) SimpleMessageAction(org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction) FormAction(org.finos.symphony.toolkit.workflow.actions.FormAction) EntityJson(org.finos.symphony.toolkit.json.EntityJson) Message(org.finos.symphony.toolkit.workflow.content.Message) SimpleMessageAction(org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction)

Example 22 with EntityJson

use of org.finos.symphony.toolkit.json.EntityJson in project spring-bot by finos.

the class TestMessageMLParser method testTaggedMessage.

@Test
public void testTaggedMessage() throws Exception {
    EntityJson ej = entityJsonConverter.readValue("{\"0\":{\"id\":[{\"type\":\"com.symphony.user.userId\",\"value\":\"347583113331315\"}],\"type\":\"com.symphony.user.mention\"},\"1\":{\"id\":[{\"type\":\"com.symphony.user.userId\",\"value\":\"345315370604167\"}],\"type\":\"com.symphony.user.mention\"},\"2\":{\"id\":[{\"type\":\"com.symphony.user.userId\",\"value\":\"345315370598706\"}],\"type\":\"com.symphony.user.mention\"}}");
    Message actual = smp.parse("<div data-format=\"PresentationML\" data-version=\"2.0\" class=\"wysiwyg\"><p> </p><p>/help <span class=\"entity\" data-entity-id=\"0\">@Rob Moffat</span> <span class=\"entity\" data-entity-id=\"1\">@Mark Mainwood</span> <span class=\"entity\" data-entity-id=\"2\">@James Tan</span> </p></div>", ej);
    Message expected = Message.of(Arrays.asList(Paragraph.of(Collections.emptyList()), Paragraph.of(Arrays.asList(Word.of("/help"), new SymphonyUser(347583113331315l, "Rob Moffat", null), new SymphonyUser(345315370604167l, "Mark Mainwood", null), new SymphonyUser(345315370598706l, "James Tan", null)))));
    Assertions.assertEquals(expected, actual);
}
Also used : EntityJson(org.finos.symphony.toolkit.json.EntityJson) Message(org.finos.symphony.toolkit.workflow.content.Message) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) Test(org.junit.jupiter.api.Test)

Example 23 with EntityJson

use of org.finos.symphony.toolkit.json.EntityJson 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)

Example 24 with EntityJson

use of org.finos.symphony.toolkit.json.EntityJson in project spring-bot by finos.

the class TestTableEdit method editRow.

protected void editRow(String testStem, Object toChange, Object newRow, String spel) throws Exception {
    EntityJson ej = new EntityJson();
    ej.put(WorkResponse.OBJECT_KEY, toChange);
    FormAction ea = new FormAction(room, u, toChange, spel + TableEditRow.EDIT_SUFFIX, ej);
    editRow.accept(ea);
    // should get a new form back.
    String jsonStr = testTemplating("abc123", testStem + "1.ml", testStem + "1.json");
    EntityJson json = ejc.readValue(jsonStr);
    ea = new FormAction(room, u, newRow, spel + TableEditRow.UPDATE_SUFFIX, json);
    Mockito.reset(messagesApi);
    editRow.accept(ea);
    testTemplating("abc123", testStem + "2.ml", testStem + "2.json");
}
Also used : EntityJson(org.finos.symphony.toolkit.json.EntityJson) FormAction(org.finos.symphony.toolkit.workflow.actions.FormAction)

Example 25 with EntityJson

use of org.finos.symphony.toolkit.json.EntityJson in project spring-bot by finos.

the class TestHistory method makeMessage.

protected V4Message makeMessage(TestObjects one) {
    EntityJson out = new EntityJson();
    out.put("1", one);
    return new V4Message().message("some stuff").data(ejc.writeValue(out));
}
Also used : EntityJson(org.finos.symphony.toolkit.json.EntityJson) V4Message(com.symphony.api.model.V4Message)

Aggregations

EntityJson (org.finos.symphony.toolkit.json.EntityJson)26 FormAction (org.finos.symphony.toolkit.workflow.actions.FormAction)7 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)5 HashTag (org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag)5 SymphonyUser (org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser)5 Test (org.junit.jupiter.api.Test)5 V4Message (com.symphony.api.model.V4Message)4 SimpleMessageAction (org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction)4 Addressable (org.finos.symphony.toolkit.workflow.content.Addressable)4 Message (org.finos.symphony.toolkit.workflow.content.Message)4 MessagesApi (com.symphony.api.agent.MessagesApi)3 V4MessageSent (com.symphony.api.model.V4MessageSent)3 Action (org.finos.symphony.toolkit.workflow.actions.Action)3 User (org.finos.symphony.toolkit.workflow.content.User)3 MessageSearchQuery (com.symphony.api.model.MessageSearchQuery)2 V4MessageList (com.symphony.api.model.V4MessageList)2 V4Stream (com.symphony.api.model.V4Stream)2 V4SymphonyElementsAction (com.symphony.api.model.V4SymphonyElementsAction)2 V4User (com.symphony.api.model.V4User)2 StreamsApi (com.symphony.api.pod.StreamsApi)2