-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed missing subscriptions after migration of an active embedded non…
… interrupting event sub process (#3928) (#3929) * Fixed missing subscriptions after migration of an active non interrupting event sub process (#3928) * Added missing package import * In case of a timer event, only process event sub process when no timer job is present * Added testcases and fix when migrating an event sub process with two started sub processes * Fixed imports
- Loading branch information
1 parent
600d013
commit b89cad9
Showing
6 changed files
with
1,119 additions
and
4 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
122 changes: 122 additions & 0 deletions
122
...test/api/runtime/migration/AbstractProcessInstanceMigrationEventRegistryConsumerTest.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,122 @@ | ||
/* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* 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 org.flowable.engine.test.api.runtime.migration; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import org.flowable.common.engine.impl.interceptor.EngineConfigurationConstants; | ||
import org.flowable.eventregistry.api.EventDeployment; | ||
import org.flowable.eventregistry.api.EventRegistry; | ||
import org.flowable.eventregistry.api.EventRepositoryService; | ||
import org.flowable.eventregistry.api.InboundEventChannelAdapter; | ||
import org.flowable.eventregistry.impl.EventRegistryEngineConfiguration; | ||
import org.flowable.eventregistry.model.InboundChannelModel; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
|
||
/** | ||
* Provides a test channel and test events. | ||
* | ||
* @author Bas Claessen | ||
*/ | ||
public abstract class AbstractProcessInstanceMigrationEventRegistryConsumerTest extends AbstractProcessInstanceMigrationTest { | ||
|
||
protected TestInboundEventChannelAdapter inboundEventChannelAdapter; | ||
|
||
@BeforeEach | ||
public void setUp() throws Exception { | ||
inboundEventChannelAdapter = setupTestChannel(); | ||
|
||
getEventRepositoryService().createEventModelBuilder() | ||
.key("myEvent") | ||
.resourceName("myEvent.event") | ||
.deploy(); | ||
} | ||
|
||
@AfterEach | ||
public void tearDown() throws Exception { | ||
EventRepositoryService eventRepositoryService = getEventRepositoryService(); | ||
List<EventDeployment> deployments = eventRepositoryService.createDeploymentQuery().list(); | ||
for (EventDeployment eventDeployment : deployments) { | ||
eventRepositoryService.deleteDeployment(eventDeployment.getId()); | ||
} | ||
deleteDeployments(); | ||
} | ||
|
||
protected TestInboundEventChannelAdapter setupTestChannel() { | ||
TestInboundEventChannelAdapter inboundEventChannelAdapter = new TestInboundEventChannelAdapter(); | ||
Map<Object, Object> beans = getEventRegistryEngineConfiguration().getExpressionManager().getBeans(); | ||
beans.put("inboundEventChannelAdapter", inboundEventChannelAdapter); | ||
|
||
getEventRepositoryService().createInboundChannelModelBuilder() | ||
.key("test-channel") | ||
.resourceName("testChannel.channel") | ||
.channelAdapter("${inboundEventChannelAdapter}") | ||
.jsonDeserializer() | ||
.detectEventKeyUsingJsonField("type") | ||
.jsonFieldsMapDirectlyToPayload() | ||
.deploy(); | ||
|
||
return inboundEventChannelAdapter; | ||
} | ||
|
||
protected EventRepositoryService getEventRepositoryService() { | ||
return getEventRegistryEngineConfiguration().getEventRepositoryService(); | ||
} | ||
|
||
protected EventRegistryEngineConfiguration getEventRegistryEngineConfiguration() { | ||
return (EventRegistryEngineConfiguration) processEngineConfiguration.getEngineConfigurations() | ||
.get(EngineConfigurationConstants.KEY_EVENT_REGISTRY_CONFIG); | ||
} | ||
|
||
protected static class TestInboundEventChannelAdapter implements InboundEventChannelAdapter { | ||
|
||
public InboundChannelModel inboundChannelModel; | ||
public EventRegistry eventRegistry; | ||
protected ObjectMapper objectMapper = new ObjectMapper(); | ||
|
||
@Override | ||
public void setInboundChannelModel(InboundChannelModel inboundChannelModel) { | ||
this.inboundChannelModel = inboundChannelModel; | ||
} | ||
|
||
@Override | ||
public void setEventRegistry(EventRegistry eventRegistry) { | ||
this.eventRegistry = eventRegistry; | ||
} | ||
|
||
public void triggerTestEvent() { | ||
ObjectNode eventNode = createTestEventNode(); | ||
triggerTestEvent(eventNode); | ||
} | ||
|
||
public void triggerTestEvent(ObjectNode eventNode) { | ||
try { | ||
eventRegistry.eventReceived(inboundChannelModel, objectMapper.writeValueAsString(eventNode)); | ||
} catch (JsonProcessingException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
protected ObjectNode createTestEventNode() { | ||
ObjectNode json = objectMapper.createObjectNode(); | ||
json.put("type", "myEvent"); | ||
return json; | ||
} | ||
} | ||
} |
Oops, something went wrong.