Search in sources :

Example 1 with V4User

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

the class RoomWelcomeEventConsumerIT method testUserAdded.

@Test
public void testUserAdded() {
    RoomWelcomeEventConsumer rwec = new RoomWelcomeEventConsumer(messages, users, bot, WELCOME_MESSAGE);
    V4Event event = new V4Event().payload(new V4Payload().userJoinedRoom(new V4UserJoinedRoom().affectedUser(new V4User().displayName("Gordon Bennett")).stream(new V4Stream().streamId(NEW_ROOM_STREAM_ID))));
    rwec.accept(event);
    Mockito.verify(messages, Mockito.times(1)).v4StreamSidMessageCreatePost(Mockito.isNull(), Mockito.matches(Pattern.quote(NEW_ROOM_STREAM_ID)), Mockito.matches(Pattern.quote(WELCOME_MESSAGE)), Mockito.isNotNull(), Mockito.isNull(), Mockito.isNull(), Mockito.isNull(), Mockito.isNull());
    Mockito.clearInvocations(messages);
}
Also used : V4Event(com.symphony.api.model.V4Event) V4UserJoinedRoom(com.symphony.api.model.V4UserJoinedRoom) V4User(com.symphony.api.model.V4User) V4Stream(com.symphony.api.model.V4Stream) V4Payload(com.symphony.api.model.V4Payload) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 2 with V4User

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

the class BotIT method testPressButton.

/**
 * When the user presses a button, we return a response.
 */
@Test
public void testPressButton() {
    V4Event in = new V4Event().initiator(new V4Initiator().user(new V4User().email("rob@example.com").displayName("Rob Example").userId(2438923l))).payload(new V4Payload().symphonyElementsAction(new V4SymphonyElementsAction().formId("koreai-choice").formValues(Collections.singletonMap("action", "some button")).stream(new V4Stream().streamId("ABC123"))));
    getPublicBot().sendToConsumer(in);
    littleSleep();
    wireMockRule.verify(1, WireMock.postRequestedFor(urlPathMatching("/agent/v4/stream/ABC123/message/create")));
}
Also used : V4SymphonyElementsAction(com.symphony.api.model.V4SymphonyElementsAction) V4Initiator(com.symphony.api.model.V4Initiator) V4Event(com.symphony.api.model.V4Event) V4User(com.symphony.api.model.V4User) V4Stream(com.symphony.api.model.V4Stream) V4Payload(com.symphony.api.model.V4Payload) Test(org.junit.jupiter.api.Test)

Example 3 with V4User

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

the class BotIT method testSendMessageRoomWithMention.

@Test
public void testSendMessageRoomWithMention() throws JsonProcessingException {
    Mention m = new Mention();
    m.setId(new ArrayList<>());
    m.getId().add(new UserId("1234"));
    EntityJson ej = new EntityJson();
    ej.put("m1", m);
    String data = symphonyObjectMapper.writeValueAsString(ej);
    V4Event in = new V4Event().initiator(new V4Initiator().user(new V4User().email("rob@example.com").displayName("Rob Example").userId(2438923l))).payload(new V4Payload().messageSent(new V4MessageSent().message(new V4Message().message("<div>hello</div>").stream(new V4Stream().streamId("ABC123").streamType("ROOM")).data(data))));
    getPublicBot().sendToConsumer(in);
    littleSleep();
    wireMockRule.verify(1, WireMock.postRequestedFor(urlPathMatching("/agent/v4/stream/ABC123/message/create")));
}
Also used : EntityJson(org.finos.symphony.toolkit.json.EntityJson) V4Message(com.symphony.api.model.V4Message) UserId(com.symphony.user.UserId) Mention(com.symphony.user.Mention) V4Initiator(com.symphony.api.model.V4Initiator) V4MessageSent(com.symphony.api.model.V4MessageSent) V4Event(com.symphony.api.model.V4Event) V4User(com.symphony.api.model.V4User) V4Stream(com.symphony.api.model.V4Stream) V4Payload(com.symphony.api.model.V4Payload) Test(org.junit.jupiter.api.Test)

Example 4 with V4User

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

the class BotIT method testSendMessageIM.

@Test
public void testSendMessageIM() {
    V4Event in = new V4Event().initiator(new V4Initiator().user(new V4User().email("rob@example.com").displayName("Rob Example").userId(2438923l))).payload(new V4Payload().messageSent(new V4MessageSent().message(new V4Message().message("<div>hello</div>").data("{}").stream(new V4Stream().streamId("ABC123").streamType("IM")))));
    getPublicBot().sendToConsumer(in);
    littleSleep();
    wireMockRule.verify(1, WireMock.postRequestedFor(urlPathMatching("/agent/v4/stream/ABC123/message/create")));
}
Also used : V4Message(com.symphony.api.model.V4Message) V4Initiator(com.symphony.api.model.V4Initiator) V4MessageSent(com.symphony.api.model.V4MessageSent) V4Event(com.symphony.api.model.V4Event) V4User(com.symphony.api.model.V4User) V4Stream(com.symphony.api.model.V4Stream) V4Payload(com.symphony.api.model.V4Payload) Test(org.junit.jupiter.api.Test)

Example 5 with V4User

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

the class BotIT method testSendMessageRoomWithoutSlash.

@Test
public void testSendMessageRoomWithoutSlash() {
    V4Event in = new V4Event().initiator(new V4Initiator().user(new V4User().email("rob@example.com").displayName("Rob Example").userId(2438923l))).payload(new V4Payload().messageSent(new V4MessageSent().message(new V4Message().message("<div>hello</div>").data("{}").stream(new V4Stream().streamId("ABC123").streamType("ROOM")))));
    getPublicBot().sendToConsumer(in);
    littleSleep();
    // we shouldn't see a message sent
    wireMockRule.verify(0, WireMock.postRequestedFor(urlPathMatching("/agent/v4/stream/ABC123/message/create")));
}
Also used : V4Message(com.symphony.api.model.V4Message) V4Initiator(com.symphony.api.model.V4Initiator) V4MessageSent(com.symphony.api.model.V4MessageSent) V4Event(com.symphony.api.model.V4Event) V4User(com.symphony.api.model.V4User) V4Stream(com.symphony.api.model.V4Stream) V4Payload(com.symphony.api.model.V4Payload) Test(org.junit.jupiter.api.Test)

Aggregations

V4Stream (com.symphony.api.model.V4Stream)9 V4User (com.symphony.api.model.V4User)9 V4Event (com.symphony.api.model.V4Event)8 V4Payload (com.symphony.api.model.V4Payload)8 Test (org.junit.jupiter.api.Test)8 V4Initiator (com.symphony.api.model.V4Initiator)7 V4MessageSent (com.symphony.api.model.V4MessageSent)7 V4Message (com.symphony.api.model.V4Message)6 V4SymphonyElementsAction (com.symphony.api.model.V4SymphonyElementsAction)2 EntityJson (org.finos.symphony.toolkit.json.EntityJson)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 V4UserJoinedRoom (com.symphony.api.model.V4UserJoinedRoom)1 Mention (com.symphony.user.Mention)1 UserId (com.symphony.user.UserId)1 IOException (java.io.IOException)1 Map (java.util.Map)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 Address (org.finos.symphony.toolkit.koreai.Address)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 SAXException (org.xml.sax.SAXException)1