-
Notifications
You must be signed in to change notification settings - Fork 209
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
[incubator-kie-issues#1497] Using the getSerializableNodeInstances inside ProtobufProcessInstanceWriter #3707
Merged
Merged
Changes from 5 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7685790
[incubator-kie-issues#1497] Using the getSerializableNodeInstances in…
f710fe4
[incubator-kie-issues#1497] Overriding getSerializableNodeInstances …
d4824d7
[incubator-kie-issues#1497] Implementing getNotSerializableClasses i…
38ff992
Merge remote-tracking branch 'origin/main' into incubator-kie-issues#…
7ff4011
[incubator-kie-issues#1497] Unit-testing ForEachNodeInstance
509c8a6
[incubator-kie-issues#1497] Improving Serializable Nodes management -…
51e9ff0
[incubator-kie-issues#1497] Fix formatting
814c298
[incubator-kie-issues#1497] Fix imports
d02eb8a
[incubator-kie-issues#1497] Implemented ProtobufProcessInstanceWriter…
56ceb16
Merge remote-tracking branch 'origin/main' into incubator-kie-issues#…
e3d5766
Merge remote-tracking branch 'origin/main' into incubator-kie-issues#…
f06b4ab
[incubator-kie-issues#1497] Removing serializableNodes list
1dafeaf
Merge remote-tracking branch 'origin/main' into incubator-kie-issues#…
754e967
[incubator-kie-issues#1497] Reverting to modification only in ForEach…
ef1b5ac
[incubator-kie-issues#1497] Fix format/imports
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,9 +25,11 @@ | |
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
import java.util.function.Function; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Collectors; | ||
|
||
import org.jbpm.workflow.core.Node; | ||
import org.jbpm.workflow.core.node.CompositeNode; | ||
|
@@ -54,7 +56,6 @@ | |
|
||
/** | ||
* Runtime counterpart of a composite node. | ||
* | ||
*/ | ||
public class CompositeNodeInstance extends StateBasedNodeInstance implements NodeInstanceContainer, EventNodeInstanceInterface, EventBasedNodeInstanceInterface { | ||
|
||
|
@@ -204,7 +205,12 @@ public void removeNodeInstance(final NodeInstance nodeInstance) { | |
|
||
@Override | ||
public Collection<org.kie.api.runtime.process.NodeInstance> getNodeInstances() { | ||
return new ArrayList<>(getNodeInstances(false)); | ||
return Collections.unmodifiableCollection(nodeInstances); | ||
} | ||
|
||
@Override | ||
public Collection<org.kie.api.runtime.process.NodeInstance> getSerializableNodeInstances() { | ||
return nodeInstances.stream().filter(this::isSerializable).collect(Collectors.toUnmodifiableList()); | ||
} | ||
|
||
@Override | ||
|
@@ -473,4 +479,24 @@ public Map<String, Integer> getIterationLevels() { | |
return iterationLevels; | ||
} | ||
|
||
/** | ||
* Return a Set of classes that are not serializable | ||
* Every subclass should override it, if needed, to avoid polluting the parent one (this) with children details | ||
* | ||
* @return | ||
*/ | ||
protected Set<Class<? extends org.kie.api.runtime.process.NodeInstance>> getNotSerializableClasses() { | ||
return Collections.emptySet(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not required. |
||
} | ||
|
||
/** | ||
* Check if the given <code>org.kie.api.runtime.process.NodeInstance</code> is serializable. | ||
* | ||
* @param toCheck | ||
* @return | ||
*/ | ||
private boolean isSerializable(org.kie.api.runtime.process.NodeInstance toCheck) { | ||
return !getNotSerializableClasses().contains(toCheck.getClass()); | ||
} | ||
|
||
} |
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
76 changes: 76 additions & 0 deletions
76
jbpm/jbpm-flow/src/test/java/org/jbpm/workflow/instance/node/ForEachNodeInstanceTest.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,76 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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.jbpm.workflow.instance.node; | ||
|
||
import java.util.Collection; | ||
import java.util.Set; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.kie.api.runtime.process.NodeInstance; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class ForEachNodeInstanceTest { | ||
|
||
@Test | ||
void getNodeInstances() { | ||
ForEachNodeInstance toTest = new ForEachNodeInstance(); | ||
CompositeNodeInstance compositeNodeInstance = new CompositeNodeInstance(); | ||
toTest.addNodeInstance(compositeNodeInstance); | ||
Collection<NodeInstance> nodeInstances = toTest.getNodeInstances(); | ||
assertThat(nodeInstances) | ||
.isNotNull() | ||
.hasSize(1) | ||
.contains(compositeNodeInstance); | ||
ForEachNodeInstance.ForEachJoinNodeInstance forEachJoinNodeInstance = toTest.new ForEachJoinNodeInstance(); | ||
toTest.addNodeInstance(forEachJoinNodeInstance); | ||
nodeInstances = toTest.getNodeInstances(); | ||
assertThat(nodeInstances) | ||
.isNotNull() | ||
.hasSize(2) | ||
.contains(compositeNodeInstance, forEachJoinNodeInstance); | ||
} | ||
|
||
@Test | ||
void getSerializableNodeInstances() { | ||
ForEachNodeInstance toTest = new ForEachNodeInstance(); | ||
CompositeNodeInstance compositeNodeInstance = new CompositeNodeInstance(); | ||
toTest.addNodeInstance(compositeNodeInstance); | ||
Collection<NodeInstance> serializableNodeInstances = toTest.getSerializableNodeInstances(); | ||
assertThat(serializableNodeInstances) | ||
.isNotNull() | ||
.hasSize(1) | ||
.contains(compositeNodeInstance); | ||
ForEachNodeInstance.ForEachJoinNodeInstance forEachJoinNodeInstance = toTest.new ForEachJoinNodeInstance(); | ||
toTest.addNodeInstance(forEachJoinNodeInstance); | ||
serializableNodeInstances = toTest.getSerializableNodeInstances(); | ||
assertThat(serializableNodeInstances) | ||
.isNotNull() | ||
.hasSize(1) | ||
.contains(compositeNodeInstance); | ||
} | ||
|
||
@Test | ||
void getNotSerializableClasses() { | ||
Set<Class<? extends NodeInstance>> retrieved = new ForEachNodeInstance().getNotSerializableClasses(); | ||
assertThat(retrieved).isNotNull() | ||
.hasSize(1) | ||
.allMatch(cls -> cls.equals(ForEachNodeInstance.ForEachJoinNodeInstance.class)); | ||
} | ||
} |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change not required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above