Skip to content

Commit

Permalink
fix(email-connector): now the runtime is backcompatible with all ET (#…
Browse files Browse the repository at this point in the history
…3876)

* fix(email-connector): now the runtime is backcompatible with all ET

* fix(email-connector): ådd integration test to ensure back compatiblity

* fix(email-connector): formatting
  • Loading branch information
mathias-vandaele authored Jan 27, 2025
1 parent eed10c7 commit aba5e76
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public class ConnectorsObjectMapperSupplier {
.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
.disable(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS)
.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)
.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE)
.build();

private ConnectorsObjectMapperSupplier() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected static String getHtmlBody(Message message) {
if (message.getContent() instanceof Multipart multipart) {
for (int i = 0; i < multipart.getCount(); i++) {
MimeBodyPart bodyPart = (MimeBodyPart) multipart.getBodyPart(i);
if (bodyPart.isMimeType("text/html")) {
if (bodyPart.isMimeType("text/html") || bodyPart.isMimeType("text/plain")) {
return (String) bodyPart.getContent();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*/
package io.camunda.connector.e2e;

import static io.camunda.connector.e2e.BpmnFile.replace;
import static io.camunda.process.test.api.CamundaAssert.assertThat;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;
Expand Down Expand Up @@ -363,6 +364,27 @@ public void shouldMoveImapEmail() {
assertThat(result.getProcessInstanceEvent()).hasVariable("to", "TEST");
}

@Test
public void shouldSendEmailVersion1() {
var model =
replace(
"email-outbound-connector-send-email-v1.bpmn",
BpmnFile.Replace.replace("55555", super.getUnsecureSmtpPort()));

var result = getZeebeTest(model);

assertThat(result).isNotNull();
assertThat(result.getProcessInstanceEvent()).hasVariable("sent", true);

assertTrue(super.waitForNewEmails(5000, 1));
List<Message> message = List.of(super.getLastReceivedEmails());
assertThat(message).isNotNull();
assertThat(getSenders(message.getFirst())).hasSize(1).first().isEqualTo("test@camunda.com");
assertThat(getReceivers(message.getFirst())).hasSize(1).first().isEqualTo("receiver@test.com");
assertThat(getSubject(message.getFirst())).isEqualTo("Hello");
assertThat(getHtmlBody(message.getFirst())).isEqualTo("This is a test");
}

private BpmnModelInstance getBpmnModelInstance(
final BpmnModelInstance model, final File elementTemplate, final String taskName) {
return new BpmnFile(model)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI"
xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI"
xmlns:zeebe="http://camunda.org/schema/zeebe/1.0"
xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_0i0443o"
targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.24.0"
modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.5.0">
<bpmn:process id="Process_1rzjwzi" isExecutable="true">
<bpmn:startEvent id="StartEvent_1">
<bpmn:outgoing>Flow_1krhvnz</bpmn:outgoing>
</bpmn:startEvent>
<bpmn:sequenceFlow id="Flow_1krhvnz" sourceRef="StartEvent_1" targetRef="Activity_1audidp"/>
<bpmn:endEvent id="Event_0zvpod7">
<bpmn:incoming>Flow_0g2casz</bpmn:incoming>
</bpmn:endEvent>
<bpmn:sequenceFlow id="Flow_0g2casz" sourceRef="Activity_1audidp" targetRef="Event_0zvpod7"/>
<bpmn:serviceTask id="Activity_1audidp" zeebe:modelerTemplate="e2376fbe-d887-46af-8fff-b79ac081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YwNjFDMC4xMDAyMTQgMS42NzU0OSAtMC4wMjA1MDc4IDEuOTY2OTQgLTAuMDIwNTA3OCAyLjI3MDgzVjExLjQzNzVDLTAuMDIwNTA3OCAxMS43NDE0IDAuMTAwMjE0IDEyLjAzMjggMC4zMTUwOTkgMTIuMjQ3N0MwLjUyOTk4NCAxMi40NjI2IDAuODIxNDMyIDEyLjU4MzMgMS4xMjUzMyAxMi41ODMzSDMuOTcyVjExLjQzNzVaTTEzLjYxNDkgMi4yNzA4M0w4LjAwMDMyIDYuMTU1MjFMMi4zODU3NCAyLjI3MDgzSDEzLjYxNDlaIiBmaWxsPSIjRkM1RDBEIi8+CjxwYXRoIGQ9Ik00LjI4MjEgOS45NTM2NUw2LjMzMzE0IDEyLjAxMDRMNC4yNzYzNyAxNC4wNjcyTDUuMDg5OTEgMTQuODc1TDcuOTU0NDkgMTIuMDEwNEw1LjA4OTkxIDkuMTQ1ODNMNC4yODIxIDkuOTUzNjVaIiBmaWxsPSJibGFjayIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzkwXzI0MjAiPgo8cmVjdCB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIGZpbGw9IndoaXRlIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg==">
<bpmn:extensionElements>
<zeebe:taskDefinition type="io.camunda:email:1" retries="3"/>
<zeebe:ioMapping>
<zeebe:input source="simple" target="authentication.type"/>
<zeebe:input source="test@camunda.com" target="authentication.username"/>
<zeebe:input source="password" target="authentication.password"/>
<zeebe:input source="smtp" target="protocol"/>
<zeebe:input source="localhost" target="data.smtpConfig.smtpHost"/>
<zeebe:input source="55555" target="data.smtpConfig.smtpPort"/>
<zeebe:input source="NONE" target="data.smtpConfig.smtpCryptographicProtocol"/>
<zeebe:input source="sendEmailSmtp" target="data.smtpActionDiscriminator"/>
<zeebe:input source="test@camunda.com" target="data.smtpAction.from"/>
<zeebe:input source="receiver@test.com" target="data.smtpAction.to"/>
<zeebe:input source="Hello" target="data.smtpAction.subject"/>
<zeebe:input source="This is a test" target="data.smtpAction.body"/>
</zeebe:ioMapping>
<zeebe:taskHeaders>
<zeebe:header key="resultExpression" value="={sent: sent}" />
<zeebe:header key="retryBackoff" value="PT0S"/>
</zeebe:taskHeaders>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1krhvnz</bpmn:incoming>
<bpmn:outgoing>Flow_0g2casz</bpmn:outgoing>
</bpmn:serviceTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_1rzjwzi">
<bpmndi:BPMNShape id="_BPMNShape_StartEvent_2" bpmnElement="StartEvent_1">
<dc:Bounds x="179" y="99" width="36" height="36"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Event_0zvpod7_di" bpmnElement="Event_0zvpod7">
<dc:Bounds x="432" y="99" width="36" height="36"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1f3pk4v_di" bpmnElement="Activity_1audidp">
<dc:Bounds x="270" y="77" width="100" height="80"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="Flow_1krhvnz_di" bpmnElement="Flow_1krhvnz">
<di:waypoint x="215" y="117"/>
<di:waypoint x="270" y="117"/>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge id="Flow_0g2casz_di" bpmnElement="Flow_0g2casz">
<di:waypoint x="370" y="117"/>
<di:waypoint x="432" y="117"/>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
*/
package io.camunda.connector.email.outbound.protocols.actions;

import com.fasterxml.jackson.annotation.JsonEnumDefaultValue;

public enum ContentType {
@JsonEnumDefaultValue
PLAIN("text/plain; charset=utf-8"),
HTML("text/html; charset=utf-8"),
MULTIPART("multipart/mixed; charset=utf-8");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
*/
package io.camunda.connector.email.outbound.protocols.actions;

import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.Nulls;
import io.camunda.connector.generator.dsl.Property;
import io.camunda.connector.generator.java.annotation.TemplateProperty;
import io.camunda.connector.generator.java.annotation.TemplateSubType;
Expand Down Expand Up @@ -99,6 +101,7 @@ public record SmtpSendEmail(
binding = @TemplateProperty.PropertyBinding(name = "data.smtpAction.contentType"))
@Valid
@NotNull
@JsonSetter(nulls = Nulls.AS_EMPTY)
ContentType contentType,
@TemplateProperty(
label = "Email Text Content",
Expand Down

0 comments on commit aba5e76

Please sign in to comment.