Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add silent flag to update message activity #116

Merged
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
10 changes: 8 additions & 2 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,8 @@ Update an existing message into a stream. Returns the new updated message.
Key | Type | Required |
------------ | -------| --- |
[message-id](#update-message-id) | String | Yes |
[content](#content) | String/Object| Yes |
[content](#content) | String/Object | Yes |
[silent](#silent) | Boolean | No |

Output | Type |
----|----|
Expand All @@ -870,7 +871,12 @@ msgId | String

#### <a name="update-message-id"></a> message-id

Message id of the message to be updated. Both url safe and base64 encoded urls are accepted
Message id of the message to be updated. Both url safe and base64 encoded urls are accepted.

#### <a name="silent"></a> silent

Silent flag in the update message activity. The new updated message will be marked as read when the flag is set to true, unread otherwise.
The default value is true.

### pin-message

Expand Down
2 changes: 1 addition & 1 deletion workflow-bot-app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ javadoc {
dependencies {
implementation project(':workflow-language')

implementation platform('org.finos.symphony.bdk:symphony-bdk-bom:2.7.0')
implementation platform('org.finos.symphony.bdk:symphony-bdk-bom:2.9.0')
implementation platform('com.fasterxml.jackson:jackson-bom:2.13.2.20220328')
implementation platform('org.springframework.boot:spring-boot-dependencies:2.6.6')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public void execute(ActivityExecutorContext<UpdateMessage> execution) throws IOE
String messageId = execution.getActivity().getMessageId();
V4Message messageToUpdate = execution.bdk().messages().getMessage(messageId);
String content = extractContent(execution);
Message message = Message.builder().content(content).build();
Boolean silent = execution.getActivity().getSilent();
Message message = Message.builder().silent(silent).content(content).build();
V4Message updatedMessage = execution.bdk().messages().update(messageToUpdate, message);

Map<String, Object> outputs = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ void sendFormOutputsArePreserved() throws Exception {
return true;
});


assertThat(workflow)
.executed("init", "check");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

import com.github.fge.jsonschema.core.exceptions.ProcessingException;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.MethodSource;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this import is not used

import org.mockito.ArgumentCaptor;

import java.io.IOException;
Expand All @@ -27,10 +30,11 @@ public class UpdateMessageIntegrationTest extends IntegrationTest {
private static final String OUTPUT_MESSAGE_ID_KEY = "%s.outputs.msgId";
private static final String OUTPUT_MESSAGE_KEY = "%s.outputs.message";

@Test
void updateMessageSuccessfull() throws IOException, ProcessingException {
@ParameterizedTest
@CsvSource({"update-message.swadl.yaml, true", "update-notsilent-message.swadl.yaml, false"})
void updateMessageSuccessfully(String workflowFile, Boolean silent) throws IOException, ProcessingException {
final Workflow workflow =
SwadlParser.fromYaml(getClass().getResourceAsStream("/message/update-message.swadl.yaml"));
SwadlParser.fromYaml(getClass().getResourceAsStream("/message/" + workflowFile));
final String msgId = "MSG_ID";
final String content = "<messageML>Message Updated</messageML>";
final V4Message message = message(msgId);
Expand All @@ -49,10 +53,11 @@ void updateMessageSuccessfull() throws IOException, ProcessingException {
ArgumentCaptor<Message> messageArgumentCaptor = ArgumentCaptor.forClass(Message.class);
verify(messageService, times(1)).update(eq(message), messageArgumentCaptor.capture());
assertThat(messageArgumentCaptor.getValue().getContent()).isEqualTo(content);
assertThat(messageArgumentCaptor.getValue().getSilent()).isEqualTo(silent);
}

@Test
void updateMessageWithTemplateSuccessfull() throws IOException, ProcessingException {
void updateMessageWithTemplateSuccessfully() throws IOException, ProcessingException {
final Workflow workflow =
SwadlParser.fromYaml(getClass().getResourceAsStream("/message/update-message-template.swadl.yaml"));
final String msgId = "MSG_ID";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
id: update-message
activities:
- update-message:
id: updateMessage
on:
message-received:
content: /update-valid-message
message-id: MSG_ID
silent: false
content: Message Updated
2 changes: 1 addition & 1 deletion workflow-language/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ javadoc {
}

dependencies {
api platform('org.finos.symphony.bdk:symphony-bdk-bom:2.7.0')
api platform('org.finos.symphony.bdk:symphony-bdk-bom:2.9.0')

api 'org.finos.symphony.bdk:symphony-bdk-core'
api 'org.finos.symphony.bdk.ext:symphony-group-extension'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class UpdateMessage extends BaseActivity {
private String messageId;
@Nullable private String template;
@Nullable private String content;
private Boolean silent = Boolean.TRUE;

@SuppressWarnings("unchecked")
public void setContent(Object content) {
Expand Down
8 changes: 8 additions & 0 deletions workflow-language/src/main/resources/swadl-schema-1.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -1605,6 +1605,14 @@
},
"message-id": {
"$ref": "#/definitions/message-id-inner"
},
"silent": {
"type": [
"boolean",
"string"
],
"description": "If enabled, the new updated message is marked as read, otherwise is unread",
"default": true
}
},
"required": [
Expand Down