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);
}
}
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);
}
Aggregations