Skip to content
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

[JBPM-9969] failure to create AsyncSignalEventCommand through REST API #2074

Merged
merged 1 commit into from Dec 14, 2021

Conversation

elguardian
Copy link
Member

Copy link
Member

@gmunozfe gmunozfe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just minor comments in the test and a proposal for making more robust the code (proper IllegalArgumentException thrown) in case processInstanceId is not present.

It could potentially fail in other points (with REST and json, as it is not type-safe when obtaining the processInstanceId):

@@ -48,10 +48,9 @@ public ExecutionResults execute(CommandContext ctx) throws Exception {
if (runtimeManager == null) {
throw new IllegalArgumentException("No runtime manager found for deployment id " + deploymentId);
}
RuntimeEngine engine = runtimeManager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
RuntimeEngine engine = runtimeManager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId.longValue()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the context doesn't contain processInstanceId, it will throw a NPE.
Could the code be protected including also the processInstanceId as required, same as deploymentId and signal in the previous "if" comparison, wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

public void testAsyncSignalEventInteger1Command() throws Exception {
AsyncSignalEventCommand command = new AsyncSignalEventCommand();
CommandContext ctx = new CommandContext();
ctx.setData("processInstanceId", new Integer(2));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deprecated constructor

Suggested change
ctx.setData("processInstanceId", new Integer(2));
ctx.setData("processInstanceId", Integer.valueOf(2));

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

public void testAsyncSignalEventInteger2Command() throws Exception {
AsyncSignalEventCommand command = new AsyncSignalEventCommand();
CommandContext ctx = new CommandContext();
ctx.setData("ProcessInstanceId", new Integer(2));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

public void testAsyncSignalEventLong1Command() throws Exception {
AsyncSignalEventCommand command = new AsyncSignalEventCommand();
CommandContext ctx = new CommandContext();
ctx.setData("processInstanceId", new Long(2L));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

public void testAsyncSignalEventLong2Command() throws Exception {
AsyncSignalEventCommand command = new AsyncSignalEventCommand();
CommandContext ctx = new CommandContext();
ctx.setData("ProcessInstanceId", new Long(2L));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


public class AsyncSignalEventCommandTest {

// check we don't get NullPointer
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClassCastException, and you could add for clarification "when processInstanceId comes from a REST call with json (non type-safe)"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@gmunozfe gmunozfe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, awesome work @elguardian !
Just waiting for CI to be green

@sonarcloud
Copy link

sonarcloud bot commented Dec 14, 2021

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

77.8% 77.8% Coverage
0.0% 0.0% Duplication

@elguardian elguardian merged commit aa0ded6 into kiegroup:main Dec 14, 2021
@elguardian elguardian deleted the JBPM-9969 branch December 14, 2021 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants