Search in sources :

Example 6 with SymphonyUser

use of org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser in project spring-bot by finos.

the class TestHandlerMapping method execute.

private void execute(String s) throws Exception {
    EntityJson jsonObjects = new EntityJson();
    jsonObjects.put("1", new SymphonyUser(123l, "gaurav", "gaurav@example.com"));
    jsonObjects.put("2", new Taxonomy(Arrays.asList(new HashTag("SomeTopic"))));
    Message m = smp.parse("<messageML>/" + s + "</messageML>", jsonObjects);
    Chat r = new SymphonyRoom("The Room Where It Happened", "abc123");
    User author = new SymphonyUser(ROB_EXAMPLE_ID, ROB_NAME, ROB_EXAMPLE_EMAIL);
    Action a = new SimpleMessageAction(r, author, m, jsonObjects);
    Action.CURRENT_ACTION.set(a);
    mc.accept(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) User(org.finos.symphony.toolkit.workflow.content.User) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) Message(org.finos.symphony.toolkit.workflow.content.Message) Taxonomy(org.symphonyoss.Taxonomy) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) Chat(org.finos.symphony.toolkit.workflow.content.Chat) SimpleMessageAction(org.finos.symphony.toolkit.workflow.actions.SimpleMessageAction) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)

Example 7 with SymphonyUser

use of org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser 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 8 with SymphonyUser

use of org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser in project spring-bot by finos.

the class AbstractStreamResolving method getStreamIdForUser.

protected String getStreamIdForUser(SymphonyUser a) {
    if (((SymphonyUser) a).getStreamId() != null) {
        return ((SymphonyUser) a).getStreamId();
    } else {
        long userId = getUserIdForUser(a);
        Stream s = streamsApi.v1ImCreatePost(Collections.singletonList(userId), null);
        a.getId().add(new StreamID(s.getId()));
        return s.getId();
    }
}
Also used : StreamID(com.symphony.user.StreamID) Stream(com.symphony.api.model.Stream) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser)

Example 9 with SymphonyUser

use of org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser in project spring-bot by finos.

the class TestRoomAndUsersBuilder method testEnsureRoom.

@Test
public void testEnsureRoom() {
    ruBuilder.setDefaultAdministrators(Collections.singletonList(new SymphonyUser(1111l)));
    // create room
    when(streamsApi.v1StreamsListPost(Mockito.isNull(), Mockito.any(), Mockito.eq(0), Mockito.eq(50))).thenAnswer(c -> {
        StreamList out = new StreamList();
        out.add(new StreamAttributes().roomAttributes(new RoomSpecificStreamAttributes().name("Some Test Room")).id("abc123").streamType(new StreamType().type(TypeEnum.ROOM)));
        UserIdList l = new UserIdList();
        // robski
        l.add(765l);
        // the bot
        l.add(654321l);
        out.add(new StreamAttributes().streamAttributes(new ConversationSpecificStreamAttributes().members(l)).id("283746").streamType(new StreamType().type(TypeEnum.IM)));
        return out;
    });
    when(streamsApi.v3RoomCreatePost(any(), isNull())).then(a -> new V3RoomDetail().roomSystemInfo(new RoomSystemInfo().id("456")).roomAttributes(new V3RoomAttributes()._public(false).name("Some Test Room").description("Still Bogus")));
    when(streamsApi.v3RoomSearchPost(Mockito.any(), Mockito.isNull(), Mockito.isNull(), Mockito.isNull())).then(a -> new V3RoomSearchResults().rooms(Collections.emptyList()));
    SymphonyRoom rd = new SymphonyRoom("Some Test Room", null);
    SymphonyUser su = new SymphonyUser(2342l);
    SymphonyRoom out = ruBuilder.ensureChat(rd, Collections.singletonList(su), SymphonyConversations.simpleMeta("Automated Test Room Created", true));
    assertEquals("Some Test Room", out.getName());
    assertEquals(2, ruBuilder.getAllConversations().size());
    assertEquals("456", out.getStreamId());
    // return members
    MembershipList ml = new MembershipList();
    ml.add(new MemberInfo().id(123l).owner(true));
    when(rmApi.v2RoomIdMembershipListGet(Mockito.anyString(), Mockito.isNull())).thenReturn(ml);
    List<User> chatMembers = ruBuilder.getChatMembers(out);
    Assertions.assertEquals(Collections.singletonList(new SymphonyUser(123l, ROB_NAME, ROB_EXAMPLE_EMAIL)), chatMembers);
}
Also used : MembershipList(com.symphony.api.model.MembershipList) StreamType(com.symphony.api.model.StreamType) V3RoomDetail(com.symphony.api.model.V3RoomDetail) User(org.finos.symphony.toolkit.workflow.content.User) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) RoomSystemInfo(com.symphony.api.model.RoomSystemInfo) StreamList(com.symphony.api.model.StreamList) ConversationSpecificStreamAttributes(com.symphony.api.model.ConversationSpecificStreamAttributes) RoomSpecificStreamAttributes(com.symphony.api.model.RoomSpecificStreamAttributes) StreamAttributes(com.symphony.api.model.StreamAttributes) RoomSpecificStreamAttributes(com.symphony.api.model.RoomSpecificStreamAttributes) SymphonyRoom(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom) UserIdList(com.symphony.api.model.UserIdList) ConversationSpecificStreamAttributes(com.symphony.api.model.ConversationSpecificStreamAttributes) MemberInfo(com.symphony.api.model.MemberInfo) V3RoomAttributes(com.symphony.api.model.V3RoomAttributes) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) V3RoomSearchResults(com.symphony.api.model.V3RoomSearchResults) Test(org.junit.jupiter.api.Test)

Example 10 with SymphonyUser

use of org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser in project spring-bot by finos.

the class TestRoomAndUsersBuilder method testGetUserStream.

@Test
public void testGetUserStream() {
    when(streamsApi.v1ImCreatePost(Mockito.any(), Mockito.isNull())).thenAnswer(c -> new Stream().id("123"));
    SymphonyUser rd = new SymphonyUser("Robski mo", "rob@example.com");
    String someStream = ruBuilder.getStreamFor(rd);
    Assertions.assertEquals("123", someStream);
}
Also used : Stream(com.symphony.api.model.Stream) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) Test(org.junit.jupiter.api.Test)

Aggregations

SymphonyUser (org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser)15 SymphonyRoom (org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)7 HashTag (org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag)6 Test (org.junit.jupiter.api.Test)5 Message (org.finos.symphony.toolkit.workflow.content.Message)4 User (org.finos.symphony.toolkit.workflow.content.User)4 StreamID (com.symphony.user.StreamID)3 EntityJson (org.finos.symphony.toolkit.json.EntityJson)3 Chat (org.finos.symphony.toolkit.workflow.content.Chat)3 CashTag (org.finos.symphony.toolkit.workflow.sources.symphony.content.CashTag)3 MembershipList (com.symphony.api.model.MembershipList)2 Stream (com.symphony.api.model.Stream)2 StreamAttributes (com.symphony.api.model.StreamAttributes)2 StreamList (com.symphony.api.model.StreamList)2 StreamType (com.symphony.api.model.StreamType)2 UserV2 (com.symphony.api.model.UserV2)2 V3RoomAttributes (com.symphony.api.model.V3RoomAttributes)2 V3RoomDetail (com.symphony.api.model.V3RoomDetail)2 V3RoomSearchResults (com.symphony.api.model.V3RoomSearchResults)2 Action (org.finos.symphony.toolkit.workflow.actions.Action)2