use of com.symphony.api.model.V4Message in project spring-bot by finos.
the class CXFMultipartIT method testAttachmentPosting.
@Test
public void testAttachmentPosting() throws Exception {
TestClientStrategy strategy = TestPodConfig.CXF_RSA;
MessagesApi messagesApi = strategy.getAgentApi(MessagesApi.class);
// pull some messages back
V4MessageList msg = messagesApi.v4StreamSidMessageGet(AbstractIT.ROOM, 0l, null, null, 0, 100);
Assertions.assertTrue(msg.size() > 4);
// post a message
String message = "<messageML>Hello Java Java World!</messageML>";
File f = new File(this.getClass().getResource("/walker.jpeg").getFile());
Attachment a = new Attachment("attachment", "image/jpeg", f);
V4Message response = messagesApi.v4StreamSidMessageCreatePost(null, AbstractIT.ROOM, message, null, null, f, null, null);
messagesApi.v4StreamSidMessageCreatePost(null, AbstractIT.ROOM, message, null, null, a, null, null);
System.out.println(response.toString());
}
use of com.symphony.api.model.V4Message in project spring-bot by finos.
the class AgentIT method testDataPost.
@ParameterizedTest
@MethodSource("setupConfigurations")
public void testDataPost(TestClientStrategy s) throws Exception {
MessagesApi messageAPi = s.getAgentApi(MessagesApi.class);
String in = asString(this.getClass().getResourceAsStream("/pizza.json"));
V4Message done = messageAPi.v4StreamSidMessageCreatePost(null, ROOM, "<messageML>" + " Hello. Here is an important message with an" + " <div class=\"entity\" data-entity-id=\"object001\" />" + " included." + "</messageML>", in, null, null, null, null);
// updating messages currently not supported on develop pod
// // try updating the message
// V4Message second = messageAPi.v4StreamSidMessageMidUpdatePost(null, ROOM, done.getMessageId(), "<messageML>This is updated</messageML>", in, null, null);
//
// // read the message back
// V4Message third = messageAPi.v1MessageIdGet(null, null, done.getMessageId());
//
// Assertions.assertEquals(second.getMessage(), third.getMessage());
}
use of com.symphony.api.model.V4Message in project spring-bot by finos.
the class LogMessageHandlerImpl method handleEvent.
@Override
public Optional<LogMessage> handleEvent(V4Event e) {
V4MessageSent messageSent = e.getPayload().getMessageSent();
if (messageSent != null) {
V4Message m = messageSent.getMessage();
String messageML = m.getMessage();
if (messageML.contains(getHashTagId())) {
Optional<LogMessage> lm = readMessage(m);
if ((lm.isPresent()) && (lm.get().getCluster().equals(clusterName))) {
return lm;
}
}
}
return Optional.empty();
}
use of com.symphony.api.model.V4Message 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")));
}
use of com.symphony.api.model.V4Message 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")));
}
Aggregations