Search in sources :

Example 1 with V4RoomCreated

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

the class RoomWelcomeEventConsumer method accept.

@Override
public void accept(V4Event t) {
    V4RoomCreated roomCreated = t.getPayload().getRoomCreated();
    V4UserJoinedRoom userJoined = t.getPayload().getUserJoinedRoom();
    String streamId;
    EntityJson json = new EntityJson();
    json.put("bot", u);
    if (roomCreated != null) {
        json.put("room", roomCreated.getRoomProperties());
        json.put("stream", roomCreated.getStream());
        streamId = roomCreated.getStream().getStreamId();
    } else if (userJoined != null) {
        json.put("user", userJoined.getAffectedUser());
        json.put("stream", userJoined.getStream());
        streamId = userJoined.getStream().getStreamId();
    } else {
        // doesn't need a welcome message
        return;
    }
    String jsonStr;
    try {
        jsonStr = om.writeValueAsString(json);
        messagesApi.v4StreamSidMessageCreatePost(null, streamId, welcomeMessageML, jsonStr, null, null, null, null);
    } catch (Exception e) {
        LOG.error("Couldn't send welcome message: ", e);
    }
}
Also used : EntityJson(org.finos.symphony.toolkit.json.EntityJson) V4RoomCreated(com.symphony.api.model.V4RoomCreated) V4UserJoinedRoom(com.symphony.api.model.V4UserJoinedRoom)

Example 2 with V4RoomCreated

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

the class RoomWelcomeEventConsumerIT method testRoomCreated.

@Test
public void testRoomCreated() {
    RoomWelcomeEventConsumer rwec = new RoomWelcomeEventConsumer(messages, users, bot);
    V4Event event = new V4Event().payload(new V4Payload().roomCreated(new V4RoomCreated().roomProperties(new V4RoomProperties().name("Big Room")).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.isNotNull(), Mockito.isNotNull(), Mockito.isNull(), Mockito.isNull(), Mockito.isNull(), Mockito.isNull());
    Mockito.clearInvocations(messages);
}
Also used : V4RoomCreated(com.symphony.api.model.V4RoomCreated) V4Event(com.symphony.api.model.V4Event) V4Stream(com.symphony.api.model.V4Stream) V4Payload(com.symphony.api.model.V4Payload) V4RoomProperties(com.symphony.api.model.V4RoomProperties) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

V4RoomCreated (com.symphony.api.model.V4RoomCreated)2 V4Event (com.symphony.api.model.V4Event)1 V4Payload (com.symphony.api.model.V4Payload)1 V4RoomProperties (com.symphony.api.model.V4RoomProperties)1 V4Stream (com.symphony.api.model.V4Stream)1 V4UserJoinedRoom (com.symphony.api.model.V4UserJoinedRoom)1 EntityJson (org.finos.symphony.toolkit.json.EntityJson)1 Test (org.junit.jupiter.api.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1