Skip to content
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

Merged
merged 1 commit into from
Jan 14, 2022
Merged

Conversation

valfirst
Copy link
Collaborator

No description provided.

@valfirst valfirst marked this pull request as draft January 13, 2022 11:33
String getValue();
Optional<String> calculateValue();

String getMissingValueErrorMessage();
Copy link
Member

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;
    }

Copy link
Member

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we don't

Copy link
Member

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";
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return "application is not started";
return "session is not started";

Copy link
Collaborator Author

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

@valfirst valfirst force-pushed the standardize-dynamic-variables-api branch from eef69ea to 56d8261 Compare January 13, 2022 13:08
@codecov
Copy link

codecov bot commented Jan 13, 2022

Codecov Report

Merging #2376 (0165d01) into master (870cf69) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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           
Impacted Files Coverage Δ
.../main/java/org/vividus/steps/VariableResolver.java 100.00% <100.00%> (ø)
...dus/variable/DynamicVariableCalculationResult.java 100.00% <100.00%> (ø)
...AbstractSearchContextRectangleDynamicVariable.java 100.00% <100.00%> (ø)
.../ui/variable/AbstractWebDriverDynamicVariable.java 100.00% <100.00%> (ø)
...i/variable/SearchContextHeightDynamicVariable.java 100.00% <100.00%> (ø)
...ui/variable/SearchContextWidthDynamicVariable.java 100.00% <100.00%> (ø)
...iable/SearchContextXCoordinateDynamicVariable.java 100.00% <100.00%> (ø)
...iable/SearchContextYCoordinateDynamicVariable.java 100.00% <100.00%> (ø)
...vividus/ui/variable/SourceCodeDynamicVariable.java 100.00% <100.00%> (ø)
...bileapp/variable/ClipboardTextDynamicVariable.java 100.00% <100.00%> (ø)
... and 23 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 870cf69...0165d01. Read the comment docs.

@valfirst valfirst force-pushed the standardize-dynamic-variables-api branch 3 times, most recently from 73c2f6a to d7d42cf Compare January 13, 2022 16:21
@valfirst valfirst force-pushed the standardize-dynamic-variables-api branch 5 times, most recently from 429e2df to 8e60db9 Compare January 14, 2022 08:36
@valfirst valfirst marked this pull request as ready for review January 14, 2022 08:36
return new DynamicVariableCalculationResult(Optional.empty(), Optional.of(error));
}

public static DynamicVariableCalculationResult withValueAndError(Optional<String> value,
Copy link
Member

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

Copy link
Collaborator Author

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

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

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)

Copy link
Member

@uarlouski uarlouski Jan 14, 2022

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())
Copy link
Member

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 :)

@valfirst valfirst force-pushed the standardize-dynamic-variables-api branch from 8e60db9 to fee259e Compare January 14, 2022 10:00
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`:
Copy link
Member

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?

Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment on lines +35 to +49
public static DynamicVariableCalculationResult withValue(String value)
{
return new DynamicVariableCalculationResult(Optional.of(value), Optional.empty());
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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());
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it could be ambiguous

@valfirst valfirst force-pushed the standardize-dynamic-variables-api branch from fee259e to 0165d01 Compare January 14, 2022 12:43
@valfirst valfirst requested a review from uarlouski January 14, 2022 12:45
@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@valfirst valfirst merged commit 0a3bedb into master Jan 14, 2022
@valfirst valfirst deleted the standardize-dynamic-variables-api branch January 14, 2022 13:43
VitaliaPiliuhina pushed a commit to VitaliaPiliuhina/vividus that referenced this pull request Apr 8, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants