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

Fix bug form replied and if condition #155

Conversation

symphony-soufiane
Copy link
Contributor

@symphony-soufiane symphony-soufiane commented Sep 29, 2022

Description

close #162
close #163

Dependencies

List the other pull requests that should be merged before/along this one.

Checklist

  • Referenced a ticket in the PR title or description
  • Filled properly the description and dependencies, if any
  • Unit/Integration tests updated or added
  • Javadoc added or updated
  • Updated the documentation in docs folder

@yinan-symphony yinan-symphony force-pushed the fix-bug-form-replied-and-if-conditio branch from 6e1d7b4 to 822cacf Compare October 3, 2022 09:03
@@ -67,6 +75,24 @@ void branching(String workflowFile, List<String> activities) throws IOException,
assertThat(workflow).isExecutedWithProcessAndActivities(lastProcess(), activities);
}

@Test
void branching_intermediate() throws IOException, ProcessingException, InterruptedException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

isn't this test similar to the one done here?
test:

arguments("/branching/if-else-if.swadl.yaml", List.of("act1", "act3")),

swadl: https://github.com/finos/symphony-wdk/blob/822cacf4b162055880dd89fe1c1c8afb98b728e6/workflow-bot-app/src/test/resources/branching/if-else-if.swadl.yaml

We would prefer to test with an unsatisfied condition (if: variables.foo != "foo") rather than (.. == "foo") to verify the condition works. (or both cases actually)

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 new test is removed, it is indeed kinda duplicated, so keep the existing test only.

engine.onEvent(form("msgId", "testForm", Collections.singletonMap("action", "create")));
return true;
});
verify(messageService, timeout(5000)).send(anyString(), contains("Create"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure this verifies what you think.
In line 337, we verify that we sent the form (content contains the word form).
In line 343, we want to verify that we sent a the message "Create". I don't know why Mockito.verify does not get updated, and it gets applied on the first one. So both Mockito.verify applies on the first messageService.send(..), which contains both "form" and "Create" words.

If you change the activity "resCreate" in swadl to send something else than "Create", let's say "CreateABC", and you change the test with (contains("CreateABC")), the test will fail.. One way to force Mockito.verify to apply to the new sendMessage call, is to change the to.streamId="" to a different one and replace anyString() in verify(..).

verify(messageService, timeout(5000)).send("ANOTHER_STREAM_ID", contains("SOMETHING_DIFF_FROM_CREATE"));

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, i see your point, i add then the Mockito.clearInvocations(T mock) to clear the invocations on messageService mock after each verify, so that we are sure we have the right verification.

engine.onEvent(form("msgId", "testForm", Collections.singletonMap("action", "menu")));
return true;
});
verify(messageService, timeout(5000)).send(anyString(), contains("Menu"));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same here

@yinan-symphony yinan-symphony self-requested a review October 4, 2022 20:06
@yinan-symphony yinan-symphony force-pushed the fix-bug-form-replied-and-if-conditio branch from 822cacf to 648d969 Compare October 4, 2022 20:12
@yinan-symphony yinan-symphony force-pushed the fix-bug-form-replied-and-if-conditio branch from 5929b52 to c8205c0 Compare October 6, 2022 09:22
@yinan-symphony yinan-symphony merged commit 16487fc into finos:master Oct 6, 2022
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