Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion symphony-bdk-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ dependencies {
}

// OpenAPI code generation
def apiBaseUrl = "https://raw.githubusercontent.com/finos/symphony-api-spec/5526c5e81cb2313c4aab18119b526534652ba98e"
def apiBaseUrl = "https://raw.githubusercontent.com/finos/symphony-api-spec/fc80c3204d8a92a0b82d3c951eab7f5cb78a7c53"
def generatedFolder = "$buildDir/generated/openapi"
def apisToGenerate = [
Agent: 'agent/agent-api-public-deprecated.yaml',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ public List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant s
return listMessages(stream.getStreamId(), since, pagination);
}

@Override
public List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant since, Instant until,
@Nonnull PaginationAttribute pagination) {
return listMessages(stream.getStreamId(), since, until, pagination);
}

/**
* {@inheritDoc}
*/
Expand All @@ -151,14 +157,26 @@ public List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant s
return listMessages(stream.getStreamId(), since);
}

@Override
public List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant since, Instant until) {
return listMessages(stream.getStreamId(), since, until);
}

/**
* {@inheritDoc}
*/
@Override
public List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since,
@Nonnull PaginationAttribute pagination) {
return listMessages(streamId, since, null, pagination);
}

@Override
public List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since, Instant until,
@Nonnull PaginationAttribute pagination) {
return executeAndRetry("getMessages", messageApi.getApiClient().getBasePath(),
() -> messagesApi.v4StreamSidMessageGet(toUrlSafeIdIfNeeded(streamId), getEpochMillis(since),
getEpochMillis(until),
pagination.getSkip(),
pagination.getLimit(),
authSession.getSessionToken(),
Expand All @@ -170,8 +188,13 @@ public List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant s
*/
@Override
public List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since) {
return listMessages(streamId, since, (Instant) null);
}

@Override
public List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since, Instant until) {
return executeAndRetry("getMessages", messageApi.getApiClient().getBasePath(),
() -> messagesApi.v4StreamSidMessageGet(toUrlSafeIdIfNeeded(streamId), getEpochMillis(since), null, null,
() -> messagesApi.v4StreamSidMessageGet(toUrlSafeIdIfNeeded(streamId), getEpochMillis(since), getEpochMillis(until),null, null,
authSession.getSessionToken(), authSession.getKeyManagerToken()));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ public interface OboMessageService {
*/
List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant since, @Nonnull PaginationAttribute pagination);

/**
* Get messages from an existing stream. Additionally returns any attachments associated with the message.
*
* @param stream the stream where to look for messages
* @param since instant of the earliest possible date of the first message returned.
* @param until instant of the last possible date of the last message returned.
* @param pagination The skip and limit for pagination.
* @return the list of matching messages in the stream.
* @see <a href="https://developers.symphony.com/restapi/reference/messages-v4">Messages</a>
*/
List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant since, Instant until, @Nonnull PaginationAttribute pagination);

/**
* Get messages from an existing stream with default limit equals 50.
* Additionally returns any attachments associated with the message.
Expand All @@ -52,6 +64,19 @@ public interface OboMessageService {
*/
List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant since);

/**
* Get messages from an existing stream with default limit equals 50.
* Additionally returns any attachments associated with the message.
*
* @param stream the stream where to look for messages
* @param since instant of the earliest possible date of the first message returned.
* @param until instant of the last possible date of the last message returned.
* @return the list of matching messages in the stream.
* @see <a href="https://developers.symphony.com/restapi/reference/messages-v4">Messages</a>
*/
List<V4Message> listMessages(@Nonnull V4Stream stream, @Nonnull Instant since, Instant until);


/**
* Get messages from an existing stream. Additionally returns any attachments associated with the message.
*
Expand All @@ -63,6 +88,18 @@ public interface OboMessageService {
*/
List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since, @Nonnull PaginationAttribute pagination);

/**
* Get messages from an existing stream. Additionally returns any attachments associated with the message.
*
* @param streamId the streamID where to look for messages
* @param since instant of the earliest possible date of the first message returned.
* @param until instant of the last possible date of the last message returned.
* @param pagination The skip and limit for pagination.
* @return the list of matching messages in the stream.
* @see <a href="https://developers.symphony.com/restapi/reference/messages-v4">Messages</a>
*/
List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since, Instant until, @Nonnull PaginationAttribute pagination);

/**
* Get messages from an existing stream with default limit equals 50.
* Additionally returns any attachments associated with the message.
Expand All @@ -74,6 +111,18 @@ public interface OboMessageService {
*/
List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since);

/**
* Get messages from an existing stream with default limit equals 50.
* Additionally returns any attachments associated with the message.
*
* @param streamId the streamID where to look for messages
* @param since instant of the earliest possible date of the first message returned.
* @param until instant of the last possible date of the last message returned.
* @return the list of matching messages in the stream.
* @see <a href="https://developers.symphony.com/restapi/reference/messages-v4">Messages</a>
*/
List<V4Message> listMessages(@Nonnull String streamId, @Nonnull Instant since, Instant until);

/**
* Sends a message to the stream ID of the passed {@link V4Stream} object.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -151,18 +152,18 @@ void testSendMessageObo() throws IOException {
@Test
void testGetMessagesWithStreamObject() {
MessageService service = spy(messageService);
doReturn(Collections.emptyList()).when(service).listMessages(anyString(), any());
doReturn(Collections.emptyList()).when(service).listMessages(anyString(), any(Instant.class), any(Instant.class));

final V4Stream v4Stream = new V4Stream().streamId(STREAM_ID);
Instant now = Instant.now();
assertNotNull(service.listMessages(v4Stream, now));
verify(service).listMessages(STREAM_ID, now);
assertNotNull(service.listMessages(v4Stream, now, now.plus(10, ChronoUnit.SECONDS)));
verify(service).listMessages(STREAM_ID, now, now.plus(10, ChronoUnit.SECONDS));
}

@Test
void testGetPaginationMessagesWithStreamObject() {
MessageService service = spy(messageService);
doReturn(Collections.emptyList()).when(service).listMessages(anyString(), any(), any());
doReturn(Collections.emptyList()).when(service).listMessages(anyString(), any(Instant.class), any(PaginationAttribute.class));

final V4Stream v4Stream = new V4Stream().streamId(STREAM_ID);
Instant now = Instant.now();
Expand All @@ -171,6 +172,42 @@ void testGetPaginationMessagesWithStreamObject() {
verify(service).listMessages(STREAM_ID, now, pagination);
}

@Test
void testGetPaginationMessagesWithStreamObjectUntil() {
MessageService service = spy(messageService);
doReturn(Collections.emptyList()).when(service).listMessages(anyString(), any(Instant.class), any(Instant.class), any(PaginationAttribute.class));

final V4Stream v4Stream = new V4Stream().streamId(STREAM_ID);
Instant now = Instant.now();
PaginationAttribute pagination = new PaginationAttribute(2, 2);
assertNotNull(service.listMessages(v4Stream, now, now.plus(10, ChronoUnit.SECONDS), pagination));
verify(service).listMessages(STREAM_ID, now, now.plus(10, ChronoUnit.SECONDS), pagination);
}

@Test
void testGetMessagesUntil() throws IOException {
final String streamId = "streamid";
mockApiClient.onGet(V4_STREAM_MESSAGE.replace("{sid}", streamId),
JsonHelper.readFromClasspath("/message/get_message_stream_id.json"));

final List<V4Message> messages = messageService.listMessages(streamId, Instant.now(), Instant.now());

assertEquals(2, messages.size());
assertEquals(Arrays.asList("messageId1", "messageId2"),
messages.stream().map(V4Message::getMessageId).collect(Collectors.toList()));
}

@Test
void testGetMessagesWithStreamObjectUntil() {
MessageService service = spy(messageService);
doReturn(Collections.emptyList()).when(service).listMessages(anyString(), any(Instant.class));

final V4Stream v4Stream = new V4Stream().streamId(STREAM_ID);
Instant now = Instant.now();
assertNotNull(service.listMessages(v4Stream, now));
verify(service).listMessages(STREAM_ID, now);
}

@Test
void testGetMessages() throws IOException {
final String streamId = "streamid";
Expand Down
Loading