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

Command handler contract enforcement #930

Merged
merged 24 commits into from
Jan 4, 2019

Conversation

serhii-lekariev
Copy link
Contributor

@serhii-lekariev serhii-lekariev commented Dec 26, 2018

This PR enables ModelVerifier to throw a SignatureMismatchException when trying to verify a model that contains Aggregates that declare command handlers that don't match the contract.

Before, ModelVerifier threw an error upon finding a duplicate command handler (i.e. a handler that handles a command that is already handled), ignoring other invalid handlers.

This PR also addresses existing warnings that are produced by the ModelVerifier, by changing all existing subscriber method declarations to match the @Subscribe contract.

Copy link
Contributor

@dmdashenkov dmdashenkov left a comment

Choose a reason for hiding this comment

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

@serhii-lekariev, please see if we could get rid of the extra check.

DuplicateHandlerCheck.newInstance()
.check(classSet.elements());
}

@SuppressWarnings("ResultOfMethodCallIgnored")
// `matches` either produces an exception, in which case return value can be ignored,
// or doesn't, in which case the execution continues
Copy link
Contributor

Choose a reason for hiding this comment

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

Please fix the alignment.

@codecov
Copy link

codecov bot commented Jan 4, 2019

Codecov Report

Merging #930 into master will increase coverage by 0.03%.
The diff coverage is 100%.

@@             Coverage Diff              @@
##             master     #930      +/-   ##
============================================
+ Coverage     93.02%   93.05%   +0.03%     
- Complexity     3711     3715       +4     
============================================
  Files           508      508              
  Lines         12135    12143       +8     
  Branches        675      676       +1     
============================================
+ Hits          11288    11300      +12     
+ Misses          623      621       -2     
+ Partials        224      222       -2

…tract-enforcement

# Conflicts:
#	model/model-verifier/src/test/resources/build.gradle
@serhii-lekariev
Copy link
Contributor Author

@dmdashenkov, PTAL again.

Copy link
Contributor

@dmdashenkov dmdashenkov left a comment

Choose a reason for hiding this comment

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

@serhii-lekariev, LGTM after a few comments are addressed.

zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
Copy link
Contributor

Choose a reason for hiding this comment

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

Please revert this change. We do not use all distributions as they slow down the CI builds.

if (hasErrors) {
throw new SignatureMismatchException(mismatches);
}
if (!warnings.isEmpty()) {
warnings.stream().map(SignatureMismatch::toString).forEach(this::_warn);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please format the call chain.

return true;
}

private static boolean isWarning(SignatureMismatch mismatch){
return mismatch.getSeverity() == WARN;
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like a method of SignatureMismatch. Together with isError(), this should enable us to delete getSeverity().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants