Search in sources :

Example 1 with V4Message

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());
}
Also used : MessagesApi(com.symphony.api.agent.MessagesApi) V4MessageList(com.symphony.api.model.V4MessageList) V4Message(com.symphony.api.model.V4Message) Attachment(org.apache.cxf.jaxrs.ext.multipart.Attachment) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 2 with V4Message

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());
}
Also used : MessagesApi(com.symphony.api.agent.MessagesApi) V4Message(com.symphony.api.model.V4Message) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 3 with V4Message

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();
}
Also used : V4Message(com.symphony.api.model.V4Message) V4MessageSent(com.symphony.api.model.V4MessageSent)

Example 4 with V4Message

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")));
}
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 5 with V4Message

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

V4Message (com.symphony.api.model.V4Message)11 Test (org.junit.jupiter.api.Test)8 V4MessageSent (com.symphony.api.model.V4MessageSent)7 V4Event (com.symphony.api.model.V4Event)6 V4Initiator (com.symphony.api.model.V4Initiator)6 V4Payload (com.symphony.api.model.V4Payload)6 V4Stream (com.symphony.api.model.V4Stream)6 V4User (com.symphony.api.model.V4User)6 MessagesApi (com.symphony.api.agent.MessagesApi)3 File (java.io.File)2 EntityJson (org.finos.symphony.toolkit.json.EntityJson)2 V4MessageList (com.symphony.api.model.V4MessageList)1 Mention (com.symphony.user.Mention)1 UserId (com.symphony.user.UserId)1 Attachment (org.apache.cxf.jaxrs.ext.multipart.Attachment)1 FileDataBodyPart (org.glassfish.jersey.media.multipart.file.FileDataBodyPart)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1