-
Notifications
You must be signed in to change notification settings - Fork 4
Extracted configurations #21
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
Merged
Merged
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
1278a63
extracted ISettingsFile and added tests
knysh 3cd01b3
Merge branch 'master' into Feature/10-implement-SettingsFile
knysh 1c72731
added documentation for ISettingsFile
knysh 1f0602a
extracted ILoggerConfiguration
knysh aee9151
extracted ITimeoutConfiguration
knysh 3ede916
extracted IRetryConfiguration
knysh 4e2b14f
renamed one test
knysh d4ec648
added empty end line and
knysh 5dd1015
renamed constants to upper case
knysh b7c5b5f
removed redundant method from ISettingsFile
knysh 0e62ec6
Merge remote-tracking branch 'origin/Feature/10-implement-SettingsFil…
knysh 890314e
fixed naming and added empty line at the end of files
knysh 5b47103
Merge branch 'Feature/11-LoggerConfiguration' into Feature/11-Timeout…
knysh 5ad2519
fixed naming and added empty line at the end of files
knysh fc6cfdb
Merge branch 'Feature/11-TimeoutConfiguration' into Feature/11-IRetry…
knysh b2f48c8
fixed naming and added empty line at the end of files
knysh 88b025a
Merge branch 'master' into Feature/10-implement-SettingsFile
knysh 4619ac0
merged with master and added test for CustomSettingsFile
knysh ccac733
fix for the tests
knysh 1abd298
Merge branch 'Feature/10-implement-SettingsFile' into Feature/11-Logg…
knysh d58605f
merge and small refactoring of tests
knysh 4983e88
Merge branch 'Feature/11-LoggerConfiguration' into Feature/11-Timeout…
knysh 7513559
merge from master
knysh cd4d3ed
Merge branch 'Feature/11-TimeoutConfiguration' into Feature/11-IRetry…
knysh a968e5c
merge from master
knysh 792cda2
extracted IElementCacheConfiguration
knysh bd4b4fa
Merge branch 'master' into Feature/11-IRetryConfiguration
knysh a9ee1f3
merge and test fix
knysh 6266fd3
removed SupportedLanguaged and added default language if configuratio…
knysh ee3383c
register configuration as singleton
knysh 4244600
fixed comments
knysh 327a682
moved SettingsFileUtil to ISettingsFile
knysh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/aquality/selenium/core/configurations/ElementCacheConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package aquality.selenium.core.configurations; | ||
|
||
import aquality.selenium.core.utilities.ISettingsFile; | ||
import com.google.inject.Inject; | ||
|
||
public class ElementCacheConfiguration implements IElementCacheConfiguration{ | ||
|
||
private static final String IS_ENABLED_PATH = "/elementCache/isEnabled"; | ||
private boolean isEnabled; | ||
|
||
@Inject | ||
public ElementCacheConfiguration(ISettingsFile settingsFile){ | ||
isEnabled = settingsFile.isValuePresent(IS_ENABLED_PATH) && Boolean.valueOf(settingsFile.getValue(IS_ENABLED_PATH).toString()); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return isEnabled; | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/aquality/selenium/core/configurations/IElementCacheConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package aquality.selenium.core.configurations; | ||
|
||
/** | ||
* Provides element's cache configuration. | ||
*/ | ||
public interface IElementCacheConfiguration { | ||
|
||
/** | ||
* @return Is element caching allowed or not. | ||
*/ | ||
boolean isEnabled(); | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/java/aquality/selenium/core/configurations/ILoggerConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package aquality.selenium.core.configurations; | ||
|
||
/** | ||
* Describes logger configuration. | ||
*/ | ||
public interface ILoggerConfiguration { | ||
|
||
/** | ||
* Gets language used inside the library for logging. | ||
* @return language used for logging. | ||
*/ | ||
String getLanguage(); | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/aquality/selenium/core/configurations/IRetryConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package aquality.selenium.core.configurations; | ||
|
||
/** | ||
* Describes retry configuration. | ||
*/ | ||
public interface IRetryConfiguration { | ||
|
||
/** | ||
* Gets the number of attempts during retry. | ||
* | ||
* @return Number of retry attempts. | ||
*/ | ||
int getNumber(); | ||
|
||
/** | ||
* Gets the polling interval used in retry. | ||
* | ||
* @return Polling interval for retry. | ||
*/ | ||
long getPollingInterval(); | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/aquality/selenium/core/configurations/ITimeoutConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package aquality.selenium.core.configurations; | ||
|
||
/** | ||
* Provides timeouts configuration. | ||
*/ | ||
public interface ITimeoutConfiguration { | ||
|
||
/** | ||
* Gets WedDriver ImplicitWait timeout. | ||
* | ||
* @return ImplicitWait timeout. | ||
*/ | ||
long getImplicit(); | ||
|
||
/** | ||
* Gets default ConditionalWait timeout. | ||
* | ||
* @return ConditionalWait timeout. | ||
*/ | ||
long getCondition(); | ||
|
||
/** | ||
* Gets ConditionalWait polling interval. | ||
* | ||
* @return polling interval. | ||
*/ | ||
long getPollingInterval(); | ||
|
||
/** | ||
* Gets Command timeout. | ||
* | ||
* @return Command timeout. | ||
*/ | ||
long getCommand(); | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/aquality/selenium/core/configurations/LoggerConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package aquality.selenium.core.configurations; | ||
|
||
import aquality.selenium.core.utilities.ISettingsFile; | ||
import com.google.inject.Inject; | ||
|
||
public class LoggerConfiguration implements ILoggerConfiguration { | ||
|
||
private static final String DEFAULT_LANGUAGE = "en"; | ||
private final ISettingsFile settingsFile; | ||
|
||
@Inject | ||
public LoggerConfiguration(ISettingsFile settingsFile){ | ||
this.settingsFile = settingsFile; | ||
} | ||
|
||
@Override | ||
public String getLanguage() { | ||
return settingsFile.getValueOrDefault("/logger/language", DEFAULT_LANGUAGE).toString(); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/aquality/selenium/core/configurations/RetryConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package aquality.selenium.core.configurations; | ||
|
||
import aquality.selenium.core.utilities.ISettingsFile; | ||
import com.google.inject.Inject; | ||
|
||
public class RetryConfiguration implements IRetryConfiguration { | ||
private final int number; | ||
private final long pollingInterval; | ||
|
||
@Inject | ||
public RetryConfiguration(ISettingsFile settingsFile) { | ||
this.number = Integer.parseInt(settingsFile.getValue("/retry/number").toString()); | ||
this.pollingInterval = Long.parseLong(settingsFile.getValue("/retry/pollingInterval").toString()); | ||
} | ||
|
||
@Override | ||
public int getNumber() { | ||
return number; | ||
} | ||
|
||
@Override | ||
public long getPollingInterval() { | ||
return pollingInterval; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/main/java/aquality/selenium/core/configurations/TimeoutConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package aquality.selenium.core.configurations; | ||
|
||
import aquality.selenium.core.utilities.ISettingsFile; | ||
import com.google.inject.Inject; | ||
|
||
public class TimeoutConfiguration implements ITimeoutConfiguration{ | ||
|
||
private final ISettingsFile settingsFile; | ||
private final long condition; | ||
private final long pollInterval; | ||
private final long implicit; | ||
private final long command; | ||
|
||
@Inject | ||
public TimeoutConfiguration(ISettingsFile settingsFile) { | ||
this.settingsFile = settingsFile; | ||
condition = getTimeout(TIMEOUT.CONDITION); | ||
pollInterval = getTimeout(TIMEOUT.POLL_INTERVAL); | ||
implicit = getTimeout(TIMEOUT.IMPLICIT); | ||
command = getTimeout(TIMEOUT.COMMAND); | ||
} | ||
|
||
private long getTimeout(TIMEOUT timeout){ | ||
return Long.valueOf(settingsFile.getValue(timeout.getKey()).toString()); | ||
} | ||
|
||
public long getImplicit(){ | ||
return implicit; | ||
} | ||
|
||
public long getCondition(){ | ||
return condition; | ||
} | ||
|
||
public long getPollingInterval(){ | ||
return pollInterval; | ||
} | ||
|
||
public long getCommand(){ | ||
return command; | ||
} | ||
|
||
private enum TIMEOUT { | ||
IMPLICIT("/timeouts/timeoutImplicit"), | ||
CONDITION("/timeouts/timeoutCondition"), | ||
POLL_INTERVAL("/timeouts/timeoutPollingInterval"), | ||
COMMAND("/timeouts/timeoutCommand"); | ||
|
||
private String key; | ||
TIMEOUT(String key){ | ||
this.key = key; | ||
} | ||
|
||
private String getKey(){ | ||
return key; | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,18 @@ | ||
{ | ||
"timeouts": { | ||
"timeoutImplicit": 0, | ||
"timeoutCondition": 30, | ||
"timeoutPollingInterval": 300, | ||
"timeoutCommand": 60 | ||
}, | ||
"retry": { | ||
"number": 2, | ||
"pollingInterval": 300 | ||
}, | ||
"logger": { | ||
"language": "en" | ||
}, | ||
"elementCache": { | ||
"isEnabled": false | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package tests.configurations; | ||
|
||
import org.testng.annotations.AfterMethod; | ||
import org.testng.annotations.BeforeMethod; | ||
|
||
public class BaseProfileTest { | ||
|
||
protected static final String PROFILE_KEY = "profile"; | ||
private String previousProfile; | ||
|
||
@BeforeMethod | ||
public void saveProfile() { | ||
previousProfile = System.getProperty(PROFILE_KEY); | ||
} | ||
|
||
@AfterMethod | ||
public void restoreProfile() { | ||
if (previousProfile == null) { | ||
System.clearProperty(PROFILE_KEY); | ||
} else { | ||
System.setProperty(PROFILE_KEY, previousProfile); | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
src/test/java/tests/configurations/ElementCacheConfigurationTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package tests.configurations; | ||
|
||
import aquality.selenium.core.configurations.IElementCacheConfiguration; | ||
import org.testng.annotations.Test; | ||
import tests.application.CustomAqualityServices; | ||
|
||
import static org.testng.Assert.assertFalse; | ||
|
||
public class ElementCacheConfigurationTests { | ||
|
||
@Test | ||
public void testShouldBePossibleCheckIsEnableElementCache() { | ||
boolean isEnable = CustomAqualityServices.getServiceProvider().getInstance(IElementCacheConfiguration.class).isEnabled(); | ||
assertFalse(isEnable, "Element cache is disabled by default"); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.