Search in sources :

Example 1 with V4MessageList

use of com.symphony.api.model.V4MessageList 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 V4MessageList

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

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

the class SymphonyHistoryImpl method getEntityJsonFromHistory.

@Override
public List<EntityJson> getEntityJsonFromHistory(Tag t, Addressable address, Instant since) {
    MessageSearchQuery msq = createMessageSearchQuery(null, address, since, t);
    V4MessageList out = messageApi.v1MessageSearchPost(msq, null, null, 0, 50, null, null);
    return out.stream().map(msg -> getEntityJson(msg)).filter(e -> e != null).collect(Collectors.toList());
}
Also used : Tag(org.finos.symphony.toolkit.workflow.content.Tag) UsersApi(com.symphony.api.pod.UsersApi) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) AbstractStreamResolving(org.finos.symphony.toolkit.workflow.sources.symphony.streams.AbstractStreamResolving) SymphonyApiProperties(org.finos.symphony.toolkit.spring.api.properties.SymphonyApiProperties) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) V4MessageList(com.symphony.api.model.V4MessageList) StreamsApi(com.symphony.api.pod.StreamsApi) SymphonyAddressable(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyAddressable) CashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.CashTag) MessagesApi(com.symphony.api.agent.MessagesApi) List(java.util.List) Addressable(org.finos.symphony.toolkit.workflow.content.Addressable) V4Message(com.symphony.api.model.V4Message) EntityJson(org.finos.symphony.toolkit.json.EntityJson) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) TagSupport(org.finos.symphony.toolkit.workflow.sources.symphony.TagSupport) Entry(java.util.Map.Entry) Optional(java.util.Optional) EntityJsonConverter(org.finos.symphony.toolkit.workflow.sources.symphony.json.EntityJsonConverter) MessageSearchQuery(com.symphony.api.model.MessageSearchQuery) V4MessageList(com.symphony.api.model.V4MessageList) MessageSearchQuery(com.symphony.api.model.MessageSearchQuery)

Example 4 with V4MessageList

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

the class SymphonyHistoryImpl method getEntityJsonFromHistory.

@Override
public <X> List<EntityJson> getEntityJsonFromHistory(Class<X> type, Addressable address, Instant since) {
    MessageSearchQuery msq = createMessageSearchQuery(type, address, since, null);
    V4MessageList out = messageApi.v1MessageSearchPost(msq, null, null, 0, 50, null, null);
    return out.stream().map(msg -> getEntityJson(msg)).filter(e -> e != null).collect(Collectors.toList());
}
Also used : Tag(org.finos.symphony.toolkit.workflow.content.Tag) UsersApi(com.symphony.api.pod.UsersApi) SymphonyUser(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyUser) AbstractStreamResolving(org.finos.symphony.toolkit.workflow.sources.symphony.streams.AbstractStreamResolving) SymphonyApiProperties(org.finos.symphony.toolkit.spring.api.properties.SymphonyApiProperties) Instant(java.time.Instant) Collectors(java.util.stream.Collectors) V4MessageList(com.symphony.api.model.V4MessageList) StreamsApi(com.symphony.api.pod.StreamsApi) SymphonyAddressable(org.finos.symphony.toolkit.workflow.sources.symphony.content.SymphonyAddressable) CashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.CashTag) MessagesApi(com.symphony.api.agent.MessagesApi) List(java.util.List) Addressable(org.finos.symphony.toolkit.workflow.content.Addressable) V4Message(com.symphony.api.model.V4Message) EntityJson(org.finos.symphony.toolkit.json.EntityJson) HashTag(org.finos.symphony.toolkit.workflow.sources.symphony.content.HashTag) TagSupport(org.finos.symphony.toolkit.workflow.sources.symphony.TagSupport) Entry(java.util.Map.Entry) Optional(java.util.Optional) EntityJsonConverter(org.finos.symphony.toolkit.workflow.sources.symphony.json.EntityJsonConverter) MessageSearchQuery(com.symphony.api.model.MessageSearchQuery) V4MessageList(com.symphony.api.model.V4MessageList) MessageSearchQuery(com.symphony.api.model.MessageSearchQuery)

Example 5 with V4MessageList

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

the class SymphonyHistoryImpl method getLastEntityJsonFromHistory.

@Override
public <X> Optional<EntityJson> getLastEntityJsonFromHistory(Class<X> type, Addressable address) {
    MessageSearchQuery msq = createMessageSearchQuery(type, address, null, null);
    V4MessageList out = messageApi.v1MessageSearchPost(msq, null, null, 0, 1, null, null);
    return convertToOptionalEntityJson(out);
}
Also used : V4MessageList(com.symphony.api.model.V4MessageList) MessageSearchQuery(com.symphony.api.model.MessageSearchQuery)

Aggregations

V4MessageList (com.symphony.api.model.V4MessageList)8 MessageSearchQuery (com.symphony.api.model.MessageSearchQuery)5 MessagesApi (com.symphony.api.agent.MessagesApi)4 V4Message (com.symphony.api.model.V4Message)4 Instant (java.time.Instant)3 List (java.util.List)3 EntityJson (org.finos.symphony.toolkit.json.EntityJson)3 EntityJsonConverter (org.finos.symphony.toolkit.workflow.sources.symphony.json.EntityJsonConverter)3 Test (org.junit.jupiter.api.Test)3 StreamsApi (com.symphony.api.pod.StreamsApi)2 UsersApi (com.symphony.api.pod.UsersApi)2 Entry (java.util.Map.Entry)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 SymphonyApiProperties (org.finos.symphony.toolkit.spring.api.properties.SymphonyApiProperties)2 Addressable (org.finos.symphony.toolkit.workflow.content.Addressable)2 Tag (org.finos.symphony.toolkit.workflow.content.Tag)2 TestObjects (org.finos.symphony.toolkit.workflow.fixture.TestObjects)2 TagSupport (org.finos.symphony.toolkit.workflow.sources.symphony.TagSupport)2 CashTag (org.finos.symphony.toolkit.workflow.sources.symphony.content.CashTag)2