-
Notifications
You must be signed in to change notification settings - Fork 12
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
Conversation
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.
@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 |
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.
Please fix the alignment.
following their contract
…ment' into command-handler-contract-enforcement
Codecov Report
@@ 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
model/model-verifier/src/test/java/io/spine/model/verify/ModelVerifierTest.java
Outdated
Show resolved
Hide resolved
model/model-verifier/src/test/java/io/spine/model/verify/ModelVerifierTest.java
Show resolved
Hide resolved
model/model-verifier/src/test/java/io/spine/model/verify/given/InvalidRestoreAggregate.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/spine/server/model/declare/MethodSignature.java
Outdated
Show resolved
Hide resolved
server/src/main/java/io/spine/server/model/declare/MethodSignature.java
Outdated
Show resolved
Hide resolved
@dmdashenkov, PTAL again. |
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.
@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 |
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.
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); |
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.
Please format the call chain.
return true; | ||
} | ||
|
||
private static boolean isWarning(SignatureMismatch mismatch){ | ||
return mismatch.getSeverity() == WARN; |
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.
Looks like a method of SignatureMismatch
. Together with isError()
, this should enable us to delete getSeverity()
.
This PR enables
ModelVerifier
to throw aSignatureMismatchException
when trying to verify a model that containsAggregates
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.