Add conditional workflow for test-poc#31406
Conversation
f43629e to
80e5949
Compare
lhanusov
left a comment
There was a problem hiding this comment.
here are few suggestions, otherwise it looks good to me 👍
|
|
||
| @Override | ||
| public WebDriver getWebDriver() { | ||
| return new ChromeDriver(); |
There was a problem hiding this comment.
This will help to find Selenium Web elements properly:
ChromeOptions options = new ChromeOptions();
options.setImplicitWaitTimeout(Duration.ofMillis(1000));
options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
return new ChromeDriver(options);
There was a problem hiding this comment.
Added to AbstractWebDriverSupplier
| public String getAlias() { | ||
| return "firefox"; | ||
| public WebDriver getWebDriver() { | ||
| return new FirefoxDriver(); |
There was a problem hiding this comment.
Same as for chrome:
FirefoxOptions options = new FirefoxOptions();
options.setImplicitWaitTimeout(Duration.ofMillis(1000));
options.setPageLoadStrategy(PageLoadStrategy.NORMAL);
return new `FirefoxDriver(options);
There was a problem hiding this comment.
Added to AbstractWebDriverSupplier
| public class ChromeWebDriverSupplier extends AbstractWebDriverSupplier { | ||
|
|
||
| @Override | ||
| public String getAlias() { |
There was a problem hiding this comment.
this should be also defined as abstract in AbstractWebDriverSupplier
There was a problem hiding this comment.
No, alias is optional, the default name for a supplier will be class.getSimpleName
| @Override | ||
| public void close(WebDriver instance) { | ||
| instance.quit(); | ||
| public String getAlias() { |
There was a problem hiding this comment.
this should be also defined as abstract in AbstractWebDriverSupplier
There was a problem hiding this comment.
No, alias is optional, the default name for a supplier will be class.getSimpleName
| } catch (InterruptedException e) { | ||
| throw new RuntimeException(e); | ||
| } | ||
| Thread.sleep(1000); |
There was a problem hiding this comment.
Once Chrome and Firefox options are in place this can be removed.
| return getValue(registry, annotation); | ||
| void initValue(InstanceContext<T, S> instanceContext); | ||
|
|
||
| default LifeCycle lifeCycle(S annotation) { |
There was a problem hiding this comment.
What is the difference between lifecycle and getDefaultLifecycle? In AbstractWebDriverSupplier is lifecycle and in AbstractKeycloakServerSupplier only getDefaultLifecycle.
There was a problem hiding this comment.
Registry calls getLifeCycle(annotation) to get the life cycle a given instance should have, by default that will look for a method lifecycle on the annotation and use that value if present, otherwise it will call getDefaultLifeCycle. That basically means we can have a consistent approach to the lifecycle in annotations.
An alternative approach would just be to let the suppliers handle it all; and return the lifecycle from the annotation if present, or the default lifecycle. Then we'd only have getLifeCycle (without a default implementation) and remove getDefaultLifecycle.
80e5949 to
6d6de67
Compare
Signed-off-by: stianst <[email protected]>
6d6de67 to
abdc736
Compare
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - id: integration-test-setup |
There was a problem hiding this comment.
You can omit the id if you are not referencing it anywhere.
There was a problem hiding this comment.
Yup, just copy/paste from elsewhere though. Having id/name makes the run a bit more readable though as the output with reusable actions is not very elegant without it.
There was a problem hiding this comment.
Yeah, I'd just add a human readable name to it and call it a day
| public class NoAdminUserKeycloakTestServerConfig implements KeycloakTestServerConfig { | ||
|
|
||
| @Override | ||
| public Optional<String> adminUserName() { |
There was a problem hiding this comment.
Not a fan of my optionals? 😢
There was a problem hiding this comment.
They have their place, but found it easier to not have it in this case, as it's both simpler to just return null, and found the checks when setting the values simpler without optional stuff ;)
There was a problem hiding this comment.
Well, it's a matter of personal preference I guess. However using optionals forces you to handle nullability, whereas nulls do not. Also:
serverConfig.adminUserName().ifPresentOrElse(
username -> System.setProperty("keycloakAdmin", username),
() -> System.getProperties().remove("keycloakAdmin")
);| return getValue(registry, annotation); | ||
| T getValue(InstanceContext<T, S> instanceContext); | ||
|
|
||
| default LifeCycle getLifeCycle(S annotation) { |
There was a problem hiding this comment.
I'd do:
if (annotation == null) {
return getDefaultLifecycle();
}
// The restThere was a problem hiding this comment.
Don't think it matters too much - down to personal preference I guess ;)
There was a problem hiding this comment.
Oh for sure, you know how much I hate nesting, this is just a prime example of an early return pattern.
Signed-off-by: stianst <[email protected]>
Signed-off-by: stianst [email protected]