-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
259 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
version=5.11.0 | ||
lombokVersion=1.18.34 | ||
testsEnabled=false |
16 changes: 16 additions & 0 deletions
16
src/main/java/com/epam/reportportal/saucelabs/client/RestClientBuilder.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
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
20 changes: 20 additions & 0 deletions
20
src/test/java/com/epam/reportportal/saucelabs/command/AssetsCommandTest.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,20 @@ | ||
package com.epam.reportportal.saucelabs.command; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import com.epam.reportportal.saucelabs.client.RestClientBuilder; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledIf; | ||
|
||
class AssetsCommandTest extends BaseCommandTest { | ||
|
||
@Test | ||
@DisabledIf("disabled") | ||
void getJobAssets() { | ||
AssetsCommand command = new AssetsCommand( | ||
new RestClientBuilder(basicTextEncryptor)); | ||
Object response = command.executeCommand(INTEGRATION, VDC_COMMAND_PARAMS); | ||
|
||
assertNotNull(response); | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
src/test/java/com/epam/reportportal/saucelabs/command/BaseCommandTest.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,66 @@ | ||
/* | ||
* Copyright 2024 EPAM Systems | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.epam.reportportal.saucelabs.command; | ||
|
||
import static com.epam.reportportal.saucelabs.model.Constants.JOB_ID; | ||
import static com.epam.reportportal.saucelabs.utils.TestProperties.getTestProperties; | ||
|
||
import com.epam.ta.reportportal.entity.integration.Integration; | ||
import com.epam.ta.reportportal.entity.integration.IntegrationParams; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
import org.apache.commons.lang3.StringUtils; | ||
import org.jasypt.util.text.BasicTextEncryptor; | ||
import org.junit.jupiter.api.BeforeAll; | ||
|
||
// set values in 'integration.properties' to enable the tests | ||
public abstract class BaseCommandTest { | ||
|
||
|
||
public static final Map<String, Object> VDC_COMMAND_PARAMS = new HashMap<>(); | ||
public static final Map<String, Object> RDC_COMMAND_PARAMS = new HashMap<>(); | ||
public static final String VDC_JOB_ID = "vdcJobId"; | ||
public static final String RDC_JOB_ID = "rdcJobId"; | ||
public static final Integration INTEGRATION = new Integration(); | ||
|
||
BasicTextEncryptor basicTextEncryptor = new BasicTextEncryptor(); | ||
|
||
@BeforeAll | ||
protected static void before() { | ||
Properties integrationProps = getTestProperties("integration.properties"); | ||
Map<String, Object> params = new HashMap<>(); | ||
integrationProps.keySet() | ||
.stream() | ||
.map(String::valueOf) | ||
.forEach(key -> params.put(key, integrationProps.getProperty(key))); | ||
INTEGRATION.setParams(new IntegrationParams(params)); | ||
|
||
Properties jobProps = getTestProperties("jobs.properties"); | ||
VDC_COMMAND_PARAMS.put(JOB_ID, jobProps.get(VDC_JOB_ID)); | ||
RDC_COMMAND_PARAMS.put(JOB_ID, jobProps.get(RDC_JOB_ID)); | ||
|
||
} | ||
|
||
protected boolean disabled() { | ||
return INTEGRATION.getParams().getParams().values() | ||
.stream() | ||
.map(String::valueOf) | ||
.anyMatch(StringUtils::isEmpty); | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
src/test/java/com/epam/reportportal/saucelabs/command/GetLogsCommandTest.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,20 @@ | ||
package com.epam.reportportal.saucelabs.command; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import com.epam.reportportal.saucelabs.client.RestClientBuilder; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledIf; | ||
|
||
class GetLogsCommandTest extends BaseCommandTest { | ||
|
||
@Test | ||
@DisabledIf("disabled") | ||
void getVirtualDeviceLogs() { | ||
GetLogsCommand command = new GetLogsCommand( | ||
new RestClientBuilder(basicTextEncryptor)); | ||
Object response = command.executeCommand(INTEGRATION, VDC_COMMAND_PARAMS); | ||
|
||
assertNotNull(response); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/test/java/com/epam/reportportal/saucelabs/command/GetRealDeviceJobCommandTest.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,20 @@ | ||
package com.epam.reportportal.saucelabs.command; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import com.epam.reportportal.saucelabs.client.RestClientBuilder; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledIf; | ||
|
||
class GetRealDeviceJobCommandTest extends BaseCommandTest { | ||
|
||
@Test | ||
@DisabledIf("disabled") | ||
void getRealDeviceJob() { | ||
GetRealDeviceJobCommand command = new GetRealDeviceJobCommand( | ||
new RestClientBuilder(basicTextEncryptor)); | ||
Object response = command.executeCommand(INTEGRATION, RDC_COMMAND_PARAMS); | ||
|
||
assertNotNull(response); | ||
} | ||
} |
63 changes: 42 additions & 21 deletions
63
src/test/java/com/epam/reportportal/saucelabs/command/GetVirtualDeviceJobCommandTest.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 |
---|---|---|
@@ -1,45 +1,66 @@ | ||
/* | ||
* Copyright 2024 EPAM Systems | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.epam.reportportal.saucelabs.command; | ||
|
||
|
||
import static com.epam.reportportal.saucelabs.model.Constants.JOB_ID; | ||
import static com.epam.reportportal.saucelabs.model.IntegrationParametersNames.ACCESS_TOKEN; | ||
import static com.epam.reportportal.saucelabs.model.IntegrationParametersNames.DATA_CENTER; | ||
import static com.epam.reportportal.saucelabs.model.IntegrationParametersNames.USERNAME; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import com.epam.reportportal.rules.exception.ReportPortalException; | ||
import com.epam.reportportal.saucelabs.client.RestClientBuilder; | ||
import com.epam.ta.reportportal.entity.integration.Integration; | ||
import com.epam.ta.reportportal.entity.integration.IntegrationParams; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.jasypt.util.text.BasicTextEncryptor; | ||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledIf; | ||
|
||
public class GetVirtualDeviceJobCommandTest { | ||
public class GetVirtualDeviceJobCommandTest extends BaseCommandTest { | ||
|
||
private static final Map<String, Object> COMMAND_PARAMS = new HashMap<>(); | ||
private static final Map<String, Object> INTEGRATION_PARAMS = new HashMap<>(); | ||
@Test | ||
@DisabledIf("disabled") | ||
void getVirtualDeviceJob() { | ||
GetVirtualDeviceJobCommand command = new GetVirtualDeviceJobCommand( | ||
new RestClientBuilder(basicTextEncryptor)); | ||
Object response = command.executeCommand(INTEGRATION, VDC_COMMAND_PARAMS); | ||
|
||
static { | ||
INTEGRATION_PARAMS.put(USERNAME.getName(), ""); | ||
INTEGRATION_PARAMS.put(ACCESS_TOKEN.getName(), ""); | ||
INTEGRATION_PARAMS.put(DATA_CENTER.getName(), "EU"); | ||
assertNotNull(response); | ||
} | ||
|
||
COMMAND_PARAMS.put(JOB_ID, "03afb43944b849e1a9cf68989222037c"); | ||
@Test | ||
@DisabledIf("disabled") | ||
void getVirtualDeviceJobLogs() { | ||
GetLogsCommand command = new GetLogsCommand(new RestClientBuilder(basicTextEncryptor)); | ||
Object response = command.executeCommand(INTEGRATION, VDC_COMMAND_PARAMS); | ||
|
||
assertNotNull(response); | ||
} | ||
|
||
@Test | ||
void executeCommand() { | ||
BasicTextEncryptor basicTextEncryptor = new BasicTextEncryptor(); | ||
Integration integration = new Integration(); | ||
@DisabledIf("disabled") | ||
void getVirtualDeviceJobNotExists() { | ||
Map<String, Object> params = new HashMap<>(); | ||
params.put(JOB_ID, "not-exists-job-id"); | ||
|
||
integration.setParams(new IntegrationParams(INTEGRATION_PARAMS)); | ||
BasicTextEncryptor basicTextEncryptor = new BasicTextEncryptor(); | ||
|
||
GetVirtualDeviceJobCommand command = new GetVirtualDeviceJobCommand( | ||
new RestClientBuilder(basicTextEncryptor)); | ||
Object o = command.executeCommand(integration, COMMAND_PARAMS); | ||
GetLogsCommand command = new GetLogsCommand(new RestClientBuilder(basicTextEncryptor)); | ||
Assertions.assertThrows(ReportPortalException.class, | ||
() -> command.executeCommand(INTEGRATION, params)); | ||
|
||
assertNotNull(o); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/test/java/com/epam/reportportal/saucelabs/command/TestConnectionCommandTest.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,19 @@ | ||
package com.epam.reportportal.saucelabs.command; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import com.epam.reportportal.saucelabs.client.RestClientBuilder; | ||
import java.util.HashMap; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.condition.DisabledIf; | ||
|
||
class TestConnectionCommandTest extends BaseCommandTest { | ||
|
||
@Test | ||
@DisabledIf("disabled") | ||
void testConnection() { | ||
TestConnectionCommand command = new TestConnectionCommand( | ||
new RestClientBuilder(basicTextEncryptor)); | ||
assertTrue(command.executeCommand(INTEGRATION, new HashMap<String, Object>())); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
src/test/java/com/epam/reportportal/saucelabs/utils/TestProperties.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 @@ | ||
/* | ||
* Copyright 2024 EPAM Systems | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.epam.reportportal.saucelabs.utils; | ||
|
||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.util.Properties; | ||
import lombok.SneakyThrows; | ||
|
||
public class TestProperties { | ||
|
||
private TestProperties() { | ||
} | ||
|
||
@SneakyThrows | ||
public static Properties getTestProperties(String path) { | ||
Properties properties = new Properties(); | ||
try (var inputStream = TestProperties.class.getClassLoader() | ||
.getResourceAsStream(path)) { | ||
if (inputStream == null) { | ||
throw new FileNotFoundException(path); | ||
} | ||
properties.load(inputStream); | ||
} catch (IOException e) { | ||
throw new RuntimeException( | ||
"Could not read resource file: " + e); | ||
} | ||
return properties; | ||
} | ||
|
||
} |
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,4 @@ | ||
# populate properties to run the tests | ||
username= | ||
accessToken= | ||
dataCenter= |
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,2 @@ | ||
vdcJobId= | ||
rdcJobId= |