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.
This PR is to fix a flaky test
io.github.dddplus.runtime.registry.IntegrationTest#exportDomainArtifacts
in moduledddplus-test
.Setup:
Test failure Reproduction:
Test
io.github.dddplus.runtime.registry.IntegrationTest.exportDomainArtifacts
can fail as the underlying code uses aHashMap
and assumes the order of values returned by the.values()
function. This issue was verified using the NonDex plugin.Steps:
NonDex test failure:
The tool flags the test as failed even in the
ONE
mode, which means that the map's keys are shuffled only once and every call to the map produces the same shuffled order.Root cause and fix:
The test has been setup to register 4 submit activities with codes
Bar
,Baz
,Foo
andHam
as indicated by debug logs:Only Foo and Bar steps have a
goodsValidation
tag.The
DomainArtifacts.Step
objects for a specific activity (Steps.Submit.Activity
in this case), are added as a list of values to a map, with key as activity here. The 1st element of this list is asserted to have agoodsValidation
tag in the test here. This expectation fails when the first element of the list is neitherFoo
norBar
.The list will not guarantee any ordering, as it is being populated in the order returned by
.values()
here, of aHashMap
here, which itself makes no guarentees on order.To fix the test expectation, we only filter for steps that have a non empty tag and assert that any of these steps tags have a value of
goodsValidation
, instead of the first one. This removes test flakiness with minimal changes.The latest test expectation does not look at: a) which specific step has this tag and b) how many steps have the tag, as the original test does not have any expectation/assertions for these. The change continues to maintain this test logic.
The test was rerun using the NonDex plugin and passes after the fix.