-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(rabbitmq): Add to template generator (#2246)
* feat(rabbitmq): Add to template generator * feat(rabbitmq): Move pattern constraint in the right place * feat(rabbitmq): Refactor RabbitMq E2E tests * feat(rabbitmq): Add missing annotations to some fields * feat(rabbitmq): Refactor existing RabbitMq tests * Outbound GitLab Connector enhancements (#2214) * feat(gitlab): list repository branches * feat(gitlab): create repository branch * feat(gitlab): create repository file * feat(gitlab): create merge request * chore(gitlab): review feedback * fix(rest): more meaningful error message on invalid host (#2245) * fix(deps): update aws-java-sdk monorepo to v1.12.688 (#2253) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * fix(deps): update dependency com.google.apis:google-api-services-sheets to v4-rev20240319-2.0.0 (#2254) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * fix(sendgrid): capitalize sender group name in the template (#2252) * chore(deps): update dependency org.cyclonedx:cyclonedx-maven-plugin to v2.8.0 (#2256) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * fix(deps): update dependency com.microsoft.graph:microsoft-graph to v6.5.0 (#2258) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * feat(rabbitmq): Add RabbitMq InbC E2E tests * feat(rabbitmq): Add URI Pattern validation * feat(rabbitmq): Add missing $ to the URI Pattern * feat(rabbitmq): Revert BpmnFile debug change * feat(rabbitmq): Use the existing secrets Pattern for consistency * bug(inboundc): Fix potential infinite retries on message idempotency check fails (#2281) * ci: fix integration test GHA (#2274) * fix(generator): FEEL mode = disabled not applied in some cases (#2286) * feat(template generator): set default value feel = false for all inbound connectors (#2264) * fix(generator): standardize line endings in generated element templates (#2288) * chore(sns): migrate to element template generator (#2266) * chore(slack): migrate slack inbound to generator (#2279) * chore(inbound,sqs): move to generator (#2249) * chore(inbound,sqs): move to generator * fix(sqs): fixed correct template overrides Co-authored-by: Oleksii Ivanov <108869886+Oleksiivanov@users.noreply.github.com> * chore(inbound,sqs): corrected generator props --------- Co-authored-by: Oleksii Ivanov <108869886+Oleksiivanov@users.noreply.github.com> * feat(rabbitmq): Rebase main + re generate all templates --------- Co-authored-by: Wolfgang Amann <8766375+wollefitz@users.noreply.github.com> Co-authored-by: Igor Petrov <108870003+igpetrov@users.noreply.github.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Pavel Kotelevsky <38818382+chillleader@users.noreply.github.com> Co-authored-by: Oleksii Ivanov <108869886+Oleksiivanov@users.noreply.github.com> Co-authored-by: Mark Farkas <119574841+markfarkas-camunda@users.noreply.github.com>
- Loading branch information
1 parent
165d915
commit 61c7bef
Showing
16 changed files
with
1,578 additions
and
1,256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
168 changes: 168 additions & 0 deletions
168
...-test-rabbitmq/src/test/java/io/camunda/connector/e2e/RabbitMqInboundStartEventTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH | ||
* under one or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information regarding copyright | ||
* ownership. Camunda licenses this file to you under the Apache License, | ||
* Version 2.0; you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package io.camunda.connector.e2e; | ||
|
||
import static io.camunda.connector.e2e.BpmnFile.replace; | ||
import static org.mockito.Mockito.when; | ||
|
||
import com.rabbitmq.client.Channel; | ||
import com.rabbitmq.client.Connection; | ||
import com.rabbitmq.client.ConnectionFactory; | ||
import io.camunda.connector.api.json.ConnectorsObjectMapperSupplier; | ||
import io.camunda.connector.e2e.app.TestConnectorRuntimeApplication; | ||
import io.camunda.connector.runtime.inbound.lifecycle.InboundConnectorManager; | ||
import io.camunda.operate.exception.OperateException; | ||
import io.camunda.operate.model.ProcessDefinition; | ||
import io.camunda.zeebe.model.bpmn.BpmnModelInstance; | ||
import io.camunda.zeebe.model.bpmn.instance.Process; | ||
import io.camunda.zeebe.process.test.assertions.BpmnAssert; | ||
import io.camunda.zeebe.spring.test.ZeebeSpringTest; | ||
import java.io.IOException; | ||
import java.util.Set; | ||
import java.util.concurrent.TimeoutException; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.testcontainers.containers.RabbitMQContainer; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
@SpringBootTest( | ||
classes = {TestConnectorRuntimeApplication.class}, | ||
properties = { | ||
"spring.main.allow-bean-definition-overriding=true", | ||
"camunda.connector.webhook.enabled=false", | ||
"camunda.connector.polling.enabled=true" | ||
}, | ||
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@ZeebeSpringTest | ||
@ExtendWith(MockitoExtension.class) | ||
public class RabbitMqInboundStartEventTests extends BaseRabbitMqTest { | ||
|
||
private static final String QUEUE_NAME = "testQueue"; | ||
private static final String EXCHANGE_NAME = "testExchange"; | ||
private static final String ROUTING_KEY = "testRoutingKey"; | ||
private static String PORT; | ||
private static RabbitMQContainer rabbitMQContainer; | ||
private static ConnectionFactory factory; | ||
|
||
@Autowired InboundConnectorManager inboundManager; | ||
@Mock private ProcessDefinition processDef; | ||
|
||
@BeforeAll | ||
public static void setup() throws IOException, TimeoutException { | ||
rabbitMQContainer = | ||
new RabbitMQContainer(DockerImageName.parse("rabbitmq:3.7.25-management-alpine")); | ||
rabbitMQContainer.start(); | ||
PORT = String.valueOf(rabbitMQContainer.getAmqpPort()); | ||
factory = new ConnectionFactory(); | ||
factory.setHost(rabbitMQContainer.getHost()); | ||
factory.setPort(rabbitMQContainer.getAmqpPort()); | ||
factory.setUsername(rabbitMQContainer.getAdminUsername()); | ||
factory.setPassword(rabbitMQContainer.getAdminPassword()); | ||
|
||
try (Connection connection = factory.newConnection(); | ||
Channel channel = connection.createChannel()) { | ||
channel.queueDeclare(QUEUE_NAME, true, false, false, null); | ||
channel.exchangeDeclare(EXCHANGE_NAME, "direct", true); | ||
channel.queueBind(QUEUE_NAME, EXCHANGE_NAME, ROUTING_KEY); | ||
} | ||
} | ||
|
||
@AfterAll | ||
public static void tearDown() { | ||
rabbitMQContainer.stop(); | ||
} | ||
|
||
@BeforeEach | ||
public void cleanQueue() throws IOException, TimeoutException { | ||
try (Connection connection = factory.newConnection(); | ||
Channel channel = connection.createChannel()) { | ||
// Purge the queue to ensure it is empty before conducting the test | ||
channel.queuePurge(QUEUE_NAME); | ||
} | ||
} | ||
|
||
@Test | ||
public void credentialsAuthenticationReceiveMessageTest() throws Exception { | ||
var model = | ||
replace( | ||
INTERMEDIATE_CATCH_EVENT_BPMN, | ||
BpmnFile.Replace.replace("rabbitMqAuthType", "credentials"), | ||
BpmnFile.Replace.replace("rabbitMqUserName", rabbitMQContainer.getAdminUsername()), | ||
BpmnFile.Replace.replace("rabbitMqPassword", rabbitMQContainer.getAdminPassword()), | ||
BpmnFile.Replace.replace("rabbitMqPort", PORT)); | ||
assertIntermediateCatchEventUsingModel(model); | ||
} | ||
|
||
@Test | ||
public void uriAuthenticationReceiveMessageTest() throws Exception { | ||
String uri = | ||
String.format( | ||
"amqp://%s:%s@localhost:%s/%%2f", | ||
rabbitMQContainer.getAdminUsername(), rabbitMQContainer.getAdminPassword(), PORT); | ||
|
||
var model = | ||
replace( | ||
INTERMEDIATE_CATCH_EVENT_BPMN, | ||
BpmnFile.Replace.replace("rabbitMqAuthType", "uri"), | ||
BpmnFile.Replace.replace("rabbitMqUri", uri)); | ||
|
||
assertIntermediateCatchEventUsingModel(model); | ||
} | ||
|
||
private void assertIntermediateCatchEventUsingModel(BpmnModelInstance model) throws Exception { | ||
Object expectedJsonResponse = | ||
ConnectorsObjectMapperSupplier.DEFAULT_MAPPER.readValue( | ||
"{\"message\":{\"consumerTag\":\"myConsumerTag\",\"body\":{\"foo\": {\"bar\": \"barValue\"}},\"properties\":{}}}", | ||
Object.class); | ||
|
||
mockProcessDefinition(model); | ||
inboundManager.handleNewProcessDefinitions(Set.of(processDef)); | ||
|
||
var bpmnTest = getZeebeTest(model); | ||
postMessage(); | ||
bpmnTest = bpmnTest.waitForProcessCompletion(); | ||
|
||
BpmnAssert.assertThat(bpmnTest.getProcessInstanceEvent()) | ||
.hasVariableWithValue("allResult", expectedJsonResponse); | ||
|
||
BpmnAssert.assertThat(bpmnTest.getProcessInstanceEvent()) | ||
.hasVariableWithValue("partialResult", "barValue"); | ||
} | ||
|
||
private void postMessage() throws Exception { | ||
try (Connection connection = factory.newConnection(); | ||
Channel channel = connection.createChannel()) { | ||
byte[] messageBodyBytes = "{\"foo\": {\"bar\": \"barValue\"}}".getBytes(); | ||
channel.basicPublish(EXCHANGE_NAME, ROUTING_KEY, null, messageBodyBytes); | ||
} | ||
} | ||
|
||
private void mockProcessDefinition(BpmnModelInstance model) throws OperateException { | ||
when(camundaOperateClient.getProcessDefinitionModel(1L)).thenReturn(model); | ||
when(processDef.getKey()).thenReturn(1L); | ||
when(processDef.getTenantId()).thenReturn(zeebeClient.getConfiguration().getDefaultTenantId()); | ||
when(processDef.getBpmnProcessId()) | ||
.thenReturn(model.getModelElementsByType(Process.class).stream().findFirst().get().getId()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.