Search in sources :

Example 1 with MessagesApi

use of com.symphony.api.agent.MessagesApi in project spring-bot by finos.

the class TestOboCall method doSomethingOBORSA.

@Test
public void doSomethingOBORSA() throws Exception {
    ApiInstance ai = oboInstanceFactory.createApiInstance(1234l, "1000");
    MessagesApi messagesApi = ai.getAgentApi(MessagesApi.class);
    messagesApi.v4MessageBlastPost(STREAM_IDS, MESSAGE_CONTENT, null, null, null, null, null, null);
}
Also used : MessagesApi(com.symphony.api.agent.MessagesApi) ApiInstance(org.finos.symphony.toolkit.spring.api.factories.ApiInstance) Test(org.junit.jupiter.api.Test) AbstractTest(org.finos.symphony.toolkit.spring.app.AbstractTest)

Example 2 with MessagesApi

use of com.symphony.api.agent.MessagesApi 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 3 with MessagesApi

use of com.symphony.api.agent.MessagesApi in project spring-bot by finos.

the class TokenIT method checkTokenCreation.

@ParameterizedTest
@MethodSource("setupConfigurations")
public void checkTokenCreation(TestClientStrategy s) throws Exception {
    TokenManager tm = s.getTokenManager();
    MessagesApi messagesApi = s.getAgentApi(MessagesApi.class);
    // pull some messages back: look - no tokens are set
    V4MessageList msg = messagesApi.v4StreamSidMessageGet(ROOM, 0l, null, null, 0, 5);
    Assertions.assertTrue(msg.size() > 4);
    String originalSessionToken = tm.getSessionToken().getToken();
    String originalKeyManagerToken = tm.getKeyManagerToken().getToken();
    // expire the session token
    try {
        s.getSessionAuthApi().v1LogoutPost(tm.getSessionToken().getToken());
    } catch (Exception e) {
    // doesn't return what symphony says it will
    }
    // this will perform a retry, since the original tokens are invalid.
    messagesApi.v4StreamSidMessageGet(ROOM, 0l, null, null, 0, 5);
    // check that tokens actually did get refreshed
    Assertions.assertNotEquals(originalSessionToken, tm.getSessionToken());
    Assertions.assertNotEquals(originalKeyManagerToken, tm.getKeyManagerToken());
}
Also used : MessagesApi(com.symphony.api.agent.MessagesApi) V4MessageList(com.symphony.api.model.V4MessageList) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 4 with MessagesApi

use of com.symphony.api.agent.MessagesApi 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 5 with MessagesApi

use of com.symphony.api.agent.MessagesApi in project spring-bot by finos.

the class AgentIT method testStreamsV4.

@ParameterizedTest
@MethodSource("setupConfigurations")
public void testStreamsV4(TestClientStrategy s) throws Exception {
    DatafeedApi dfApi = s.getAgentApi(DatafeedApi.class);
    MessagesApi messageAPi = s.getAgentApi(MessagesApi.class);
    Datafeed datafeed = dfApi.v4DatafeedCreatePost(null, null);
    System.out.println("Datafeed ID: " + datafeed.getId());
    Supplier<List<V4Event>> supplier = () -> dfApi.v4DatafeedIdReadGet(datafeed.getId(), null, null, 100);
    final int[] count = { 0 };
    final Worker<V4Event> w = Streams.createWorker(supplier, e -> e.printStackTrace());
    Thread t = new Thread(() -> {
        w.stream().forEach(e -> count[0]++);
    });
    t.setDaemon(true);
    t.start();
    String toSend = "Trigger Listener." + new Random().nextInt();
    messageAPi.v4StreamSidMessageCreatePost(null, ROOM, "<messageML>" + toSend + "</messageML>", null, null, null, null, null);
    // wait for roundtrip
    while (count[0] == 0) {
        Thread.yield();
    }
}
Also used : MessagesApi(com.symphony.api.agent.MessagesApi) Random(java.util.Random) DatafeedApi(com.symphony.api.agent.DatafeedApi) V5EventList(com.symphony.api.model.V5EventList) List(java.util.List) V4Event(com.symphony.api.model.V4Event) V5Datafeed(com.symphony.api.model.V5Datafeed) Datafeed(com.symphony.api.model.Datafeed) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

MessagesApi (com.symphony.api.agent.MessagesApi)13 Test (org.junit.jupiter.api.Test)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)6 MethodSource (org.junit.jupiter.params.provider.MethodSource)6 V4Event (com.symphony.api.model.V4Event)4 ApiInstance (org.finos.symphony.toolkit.spring.api.factories.ApiInstance)4 DatafeedApi (com.symphony.api.agent.DatafeedApi)3 V4Message (com.symphony.api.model.V4Message)3 V5Datafeed (com.symphony.api.model.V5Datafeed)3 List (java.util.List)3 Random (java.util.Random)3 Datafeed (com.symphony.api.model.Datafeed)2 V4MessageList (com.symphony.api.model.V4MessageList)2 V5EventList (com.symphony.api.model.V5EventList)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 AbstractTest (org.finos.symphony.toolkit.spring.app.AbstractTest)2 V2Error (com.symphony.api.model.V2Error)1 V5DatafeedCreateBody (com.symphony.api.model.V5DatafeedCreateBody)1 IOException (java.io.IOException)1