-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Standardize dynamic variables API #2376
Conversation
vividus-engine/src/main/java/org/vividus/steps/VariableResolver.java
Outdated
Show resolved
Hide resolved
String getValue(); | ||
Optional<String> calculateValue(); | ||
|
||
String getMissingValueErrorMessage(); |
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.
I think this approach may limit the implementation when during variable resolution more than one error may appear, maybe we could return some pojo like
class DynamicVaruableValue
{
private final Optional<Object> value;
private final String failDetails;
}
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.
do we have examples where the first error don't stop variable resolution process? so several errors can stack up
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.
we don't
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.
It not necessarily to stack them up. What if the resolution could resolve into different errors? How to process it with the current implementation. I'll look closely, but clipboard text resolution may fail by different reasons
@Override | ||
public String getMissingValueErrorMessage() | ||
{ | ||
return "application is not started"; |
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.
return "application is not started"; | |
return "session is not started"; |
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.
users don't understand what session
is
eef69ea
to
56d8261
Compare
Codecov Report
@@ Coverage Diff @@
## master #2376 +/- ##
=========================================
Coverage 96.34% 96.35%
- Complexity 5400 5411 +11
=========================================
Files 765 769 +4
Lines 15499 15532 +33
Branches 1032 1035 +3
=========================================
+ Hits 14933 14966 +33
Misses 442 442
Partials 124 124
Continue to review full report at Codecov.
|
73c2f6a
to
d7d42cf
Compare
429e2df
to
8e60db9
Compare
return new DynamicVariableCalculationResult(Optional.empty(), Optional.of(error)); | ||
} | ||
|
||
public static DynamicVariableCalculationResult withValueAndError(Optional<String> value, |
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.
the "and" method seems a bit misleading for me because if the value is not empty the error is lost and never reachable in the code
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 propose a new name
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.
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.
or maybe like a named constructor DynamicVariableCalculationResult.error(String error)
DynamicVariableCalculationResult.value(String value)
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.
in general I'm okay with describing this behaviour in javadoc and explaining that this method exists because we don't want to use if-else construction :)
|
||
public Optional<String> getValueOrHandleError(Consumer<String> errorHandler) | ||
{ | ||
if (!value.isPresent()) |
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.
value.isEmpty() is a bit more concise :)
8e60db9
to
fee259e
Compare
In order to create and register own dynamic variable the following steps should | ||
be done. | ||
|
||
. Create a new class that implements `org.vividus.variable.DynamicVariable`: |
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.
Maybe add a link to the class on GitHub?
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.
btw can we have a crawler to ensure links in docs are not broken?
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.
public static DynamicVariableCalculationResult withValue(String value) | ||
{ | ||
return new DynamicVariableCalculationResult(Optional.of(value), Optional.empty()); | ||
} |
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.
public static DynamicVariableCalculationResult withValue(String value) | |
{ | |
return new DynamicVariableCalculationResult(Optional.of(value), Optional.empty()); | |
} | |
public static DynamicVariableCalculationResult of(String value) | |
{ | |
return new DynamicVariableCalculationResult(Optional.of(value), Optional.empty()); | |
} |
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.
it could be ambiguous
fee259e
to
0165d01
Compare
Kudos, SonarCloud Quality Gate passed! |
No description provided.