Skip to content

Commit

Permalink
fix new tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chillleader committed Dec 2, 2024
1 parent 9008ae3 commit ef3bed0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.connector.e2e.app.TestConnectorRuntimeApplication;
import io.camunda.connector.runtime.inbound.importer.ProcessDefinitionSearch;
import io.camunda.connector.runtime.inbound.search.SearchQueryClient;
import io.camunda.connector.runtime.inbound.state.ProcessImportResult;
import io.camunda.connector.runtime.inbound.state.ProcessImportResult.ProcessDefinitionIdentifier;
import io.camunda.connector.runtime.inbound.state.ProcessImportResult.ProcessDefinitionVersion;
Expand All @@ -34,10 +35,9 @@
import io.camunda.document.factory.DocumentFactoryImpl;
import io.camunda.document.reference.CamundaDocumentReferenceImpl;
import io.camunda.document.store.InMemoryDocumentStore;
import io.camunda.operate.CamundaOperateClient;
import io.camunda.operate.model.ProcessDefinition;
import io.camunda.process.test.api.CamundaSpringProcessTest;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.search.response.ProcessDefinition;
import io.camunda.zeebe.model.bpmn.instance.Process;
import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -105,7 +105,7 @@ public DocumentFactory documentFactorySpied() {

@Autowired ProcessStateStore stateStore;

@MockBean CamundaOperateClient camundaOperateClient;
@MockBean SearchQueryClient searchQueryClient;

@Autowired DocumentFactory documentFactory;

Expand All @@ -127,21 +127,21 @@ void shouldCreateDocumentsAndReturnResponse_whenMultipartRequest() throws Except
"<ACTIVATION_CONDITION>", "=request.headers.THEHEADER = &#34;THEVALUE&#34;"));

// Prepare a mocked process connectorData backed by our test model
when(camundaOperateClient.getProcessDefinitionModel(1L)).thenReturn(model);
when(searchQueryClient.getProcessModel(1L)).thenReturn(model);
var processDef = mock(ProcessDefinition.class);
when(processDef.getKey()).thenReturn(1L);
when(processDef.getProcessDefinitionKey()).thenReturn(1L);
when(processDef.getTenantId()).thenReturn(zeebeClient.getConfiguration().getDefaultTenantId());
when(processDef.getBpmnProcessId())
when(processDef.getProcessDefinitionId())
.thenReturn(model.getModelElementsByType(Process.class).stream().findFirst().get().getId());

// Deploy the webhook
stateStore.update(
new ProcessImportResult(
Map.of(
new ProcessDefinitionIdentifier(
processDef.getBpmnProcessId(), processDef.getTenantId()),
processDef.getProcessDefinitionId(), processDef.getTenantId()),
new ProcessDefinitionVersion(
processDef.getKey(), processDef.getVersion().intValue()))));
processDef.getProcessDefinitionKey(), processDef.getVersion()))));

var bpmnTest = ZeebeTest.with(zeebeClient).deploy(model).createInstance();
CompletableFuture<ResultActions> future = new CompletableFuture<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import io.camunda.connector.e2e.app.TestConnectorRuntimeApplication;
import io.camunda.connector.runtime.inbound.importer.ProcessDefinitionSearch;
import io.camunda.connector.runtime.inbound.search.SearchQueryClient;
import io.camunda.connector.runtime.inbound.state.ProcessImportResult;
import io.camunda.connector.runtime.inbound.state.ProcessImportResult.ProcessDefinitionIdentifier;
import io.camunda.connector.runtime.inbound.state.ProcessImportResult.ProcessDefinitionVersion;
import io.camunda.connector.runtime.inbound.state.ProcessStateStore;
import io.camunda.document.factory.DocumentFactory;
import io.camunda.document.factory.DocumentFactoryImpl;
import io.camunda.document.store.InMemoryDocumentStore;
import io.camunda.operate.CamundaOperateClient;
import io.camunda.operate.model.ProcessDefinition;
import io.camunda.process.test.api.CamundaSpringProcessTest;
import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.search.response.ProcessDefinition;
import io.camunda.zeebe.model.bpmn.instance.Process;
import java.util.Collections;
import java.util.Map;
Expand Down Expand Up @@ -100,7 +100,7 @@ public DocumentFactory documentFactorySpied() {

@Autowired ProcessStateStore stateStore;

@MockBean CamundaOperateClient camundaOperateClient;
@MockBean SearchQueryClient camundaOperateClient;

@Autowired DocumentFactory documentFactory;

Expand All @@ -124,21 +124,21 @@ void shouldNotCreateDocumentsAndReturnResponse_whenMultipartRequestButWontActiva
"<ACTIVATION_CONDITION>", "=request.headers.THEHEADER = &#34;INVALID_VALUE&#34;"));

// Prepare a mocked process connectorData backed by our test model
when(camundaOperateClient.getProcessDefinitionModel(2L)).thenReturn(model);
when(camundaOperateClient.getProcessModel(2L)).thenReturn(model);
var processDef = mock(ProcessDefinition.class);
when(processDef.getKey()).thenReturn(2L);
when(processDef.getProcessDefinitionKey()).thenReturn(2L);
when(processDef.getTenantId()).thenReturn(zeebeClient.getConfiguration().getDefaultTenantId());
when(processDef.getBpmnProcessId())
when(processDef.getProcessDefinitionId())
.thenReturn(model.getModelElementsByType(Process.class).stream().findFirst().get().getId());

// Deploy the webhook
stateStore.update(
new ProcessImportResult(
Map.of(
new ProcessDefinitionIdentifier(
processDef.getBpmnProcessId(), processDef.getTenantId()),
processDef.getProcessDefinitionId(), processDef.getTenantId()),
new ProcessDefinitionVersion(
processDef.getKey(), processDef.getVersion().intValue()))));
processDef.getProcessDefinitionKey(), processDef.getVersion()))));

var bpmnTest = ZeebeTest.with(zeebeClient).deploy(model).createInstance();
CompletableFuture<ResultActions> future = new CompletableFuture<>();
Expand Down

0 comments on commit ef3bed0

Please sign in to comment.