This repository has been archived by the owner on Oct 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor and remove code duplicates. Add tests for configs.
- Loading branch information
Showing
14 changed files
with
271 additions
and
38 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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
29 changes: 29 additions & 0 deletions
29
src/test/java/com/github/rosolko/wdm4j/config/CommonConfigTest.java
This file contains 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,29 @@ | ||
package com.github.rosolko.wdm4j.config; | ||
|
||
import com.github.rosolko.wdm4j.config.impl.ChromeConfig; | ||
import com.github.rosolko.wdm4j.enums.Extension; | ||
import com.github.rosolko.wdm4j.enums.Os; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.EnumSource; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
@DisplayName("Default config test") | ||
class CommonConfigTest { | ||
|
||
@ParameterizedTest | ||
@EnumSource(Os.class) | ||
@DisplayName("Get binary name based on os") | ||
void ableToGetBinaryName(final Os os) { | ||
final ChromeConfig config = new ChromeConfig(); | ||
final String binaryName = config.getBinaryName(); | ||
final String extension = os == Os.WINDOWS ? Extension.EXE.getValue() : ""; | ||
final String binaryNameWithExtension = config.getBinaryNameWithExtension(os); | ||
assertThat(binaryNameWithExtension) | ||
.startsWith(binaryName) | ||
.endsWith(extension); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/test/java/com/github/rosolko/wdm4j/config/impl/ChromeConfigTest.java
This file contains 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,45 @@ | ||
package com.github.rosolko.wdm4j.config.impl; | ||
|
||
import com.github.rosolko.wdm4j.enums.Architecture; | ||
import com.github.rosolko.wdm4j.enums.Os; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.EnumSource; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
@DisplayName("Default chrome config test") | ||
class ChromeConfigTest { | ||
private ChromeConfig config; | ||
private Architecture architecture; | ||
|
||
@BeforeAll | ||
@DisplayName("Create default chrome config") | ||
void setUp() { | ||
config = new ChromeConfig(); | ||
architecture = Architecture.detect(); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(Os.class) | ||
@DisplayName("Get platform based on os") | ||
void ableToGetPlatform(final Os os) { | ||
final Architecture outArchitecture = os == Os.WINDOWS ? Architecture.X_86_32 : Architecture.X_86_64; | ||
final String platform = config.getPlatform(os, architecture); | ||
assertThat(platform) | ||
.startsWith(os.getValue()) | ||
.endsWith(outArchitecture.getValue()); | ||
} | ||
|
||
@Test | ||
@DisplayName("Get latest version") | ||
void ableToGetLatestVersion() { | ||
final String latestVersion = config.getLatestVersion(); | ||
assertThat(latestVersion).isNotBlank(); | ||
assertThat(latestVersion).matches("^\\d+\\.\\d+$"); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/test/java/com/github/rosolko/wdm4j/config/impl/FirefoxConfigTest.java
This file contains 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,55 @@ | ||
package com.github.rosolko.wdm4j.config.impl; | ||
|
||
import com.github.rosolko.wdm4j.enums.Architecture; | ||
import com.github.rosolko.wdm4j.enums.Extension; | ||
import com.github.rosolko.wdm4j.enums.Os; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.EnumSource; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
@DisplayName("Default firefox config test") | ||
class FirefoxConfigTest { | ||
private FirefoxConfig config; | ||
private Architecture architecture; | ||
|
||
@BeforeAll | ||
@DisplayName("Create default firefox config") | ||
void setUp() { | ||
config = new FirefoxConfig(); | ||
architecture = Architecture.detect(); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(Os.class) | ||
@DisplayName("Get platform based on os") | ||
void ableToGetPlatform(final Os os) { | ||
final String expectedArchitecture = os == Os.OSX ? "" : architecture.getValue(); | ||
final String platform = config.getPlatform(os, architecture); | ||
assertThat(platform) | ||
.startsWith(os.getValue()) | ||
.endsWith(expectedArchitecture); | ||
} | ||
|
||
@Test | ||
@DisplayName("Get latest version") | ||
void ableToGetLatestVersion() { | ||
final String latestVersion = config.getLatestVersion(); | ||
assertThat(latestVersion).isNotBlank(); | ||
assertThat(latestVersion).matches("^v\\d+\\.\\d+\\.\\d+$"); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(Os.class) | ||
@DisplayName("Get archive extension") | ||
void ableToGetArchiveExtension(final Os os) { | ||
final Extension extension = os == Os.WINDOWS ? Extension.ZIP : Extension.TAR_GZ; | ||
final Extension archiveExtension = config.getArchiveExtension(os); | ||
assertThat(archiveExtension).isEqualTo(extension); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/test/java/com/github/rosolko/wdm4j/config/impl/OperaConfigTest.java
This file contains 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,45 @@ | ||
package com.github.rosolko.wdm4j.config.impl; | ||
|
||
import com.github.rosolko.wdm4j.enums.Architecture; | ||
import com.github.rosolko.wdm4j.enums.Os; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.EnumSource; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
@DisplayName("Default opera config test") | ||
class OperaConfigTest { | ||
private OperaConfig config; | ||
private Architecture architecture; | ||
|
||
@BeforeAll | ||
@DisplayName("Create default opera config") | ||
void setUp() { | ||
config = new OperaConfig(); | ||
architecture = Architecture.detect(); | ||
} | ||
|
||
@ParameterizedTest | ||
@EnumSource(Os.class) | ||
@DisplayName("Get platform based on os") | ||
void ableToGetPlatform(final Os os) { | ||
final Architecture expectedArchitecture = os == Os.WINDOWS ? Architecture.X_86_32 : architecture; | ||
final String platform = config.getPlatform(os, architecture); | ||
assertThat(platform) | ||
.startsWith(os.getValue()) | ||
.endsWith(expectedArchitecture.getValue()); | ||
} | ||
|
||
@Test | ||
@DisplayName("Get latest version") | ||
void ableToGetLatestVersion() { | ||
final String latestVersion = config.getLatestVersion(); | ||
assertThat(latestVersion).isNotBlank(); | ||
assertThat(latestVersion).matches("^\\d+\\.\\d+$"); | ||
} | ||
} |
Oops, something went wrong.