Search in sources :

Example 1 with MembershipList

use of com.symphony.api.model.MembershipList in project spring-bot by finos.

the class AbstractMockSymphonyTest method setupMembershipMock.

@BeforeEach
public void setupMembershipMock() {
    MembershipList out = new MembershipList();
    out.add(new MemberInfo().id(BOT_ID).owner(false));
    out.add(new MemberInfo().id(ROB_EXAMPLE_ID).owner(true));
    Mockito.when(rmApi.v2RoomIdMembershipListGet(Mockito.anyString(), Mockito.isNull())).thenReturn(out);
}
Also used : MembershipList(com.symphony.api.model.MembershipList) MemberInfo(com.symphony.api.model.MemberInfo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with MembershipList

use of com.symphony.api.model.MembershipList 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)

Aggregations

MemberInfo (com.symphony.api.model.MemberInfo)2 MembershipList (com.symphony.api.model.MembershipList)2 ConversationSpecificStreamAttributes (com.symphony.api.model.ConversationSpecificStreamAttributes)1 RoomSpecificStreamAttributes (com.symphony.api.model.RoomSpecificStreamAttributes)1 RoomSystemInfo (com.symphony.api.model.RoomSystemInfo)1 StreamAttributes (com.symphony.api.model.StreamAttributes)1 StreamList (com.symphony.api.model.StreamList)1 StreamType (com.symphony.api.model.StreamType)1 UserIdList (com.symphony.api.model.UserIdList)1 V3RoomAttributes (com.symphony.api.model.V3RoomAttributes)1 V3RoomDetail (com.symphony.api.model.V3RoomDetail)1 V3RoomSearchResults (com.symphony.api.model.V3RoomSearchResults)1 User (org.finos.symphony.toolkit.workflow.content.User)1 SymphonyRoom (org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyRoom)1 SymphonyUser (org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1 Test (org.junit.jupiter.api.Test)1