Skip to content

Commit

Permalink
use the uploaded apk name in the mobilab_capabilities file
Browse files Browse the repository at this point in the history
  • Loading branch information
anandbagmar committed Mar 17, 2021
1 parent 4b8433d commit 7ce1db0
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/com/znsio/e2e/runner/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -489,10 +489,10 @@ private void uploadAPKTopCloudy (String emailID, String authenticationKey) {
String deviceLabURL = configs.get(DEVICE_LAB_URL);

String authToken = getpCloudyAuthToken(emailID, authenticationKey, appPath, deviceLabURL);
uploadAPKToPCloudy(appPath, deviceLabURL, authToken);
configs.put(APP_PATH, uploadAPKToPCloudy(appPath, deviceLabURL, authToken));
}

private void uploadAPKToPCloudy (String appPath, String deviceLabURL, String authToken) {
private String uploadAPKToPCloudy (String appPath, String deviceLabURL, String authToken) {
System.out.println("uploadAPKTopCloudy: Start: " + appPath);
String[] listOfDevices = new String[]{
"curl",
Expand All @@ -505,17 +505,20 @@ private void uploadAPKToPCloudy (String appPath, String deviceLabURL, String aut
"-F",
"\"token=" + authToken + "\"",
"-F",
"\"filter=all\"",
"\"filter=apk\"",
deviceLabURL + "/api/upload_file"};

CommandLineResponse uploadResponse = CommandLineExecutor.execCommand(listOfDevices);
System.out.println("uploadResponse: " + uploadResponse.getStdOut());
int uploadStatus = JsonFile.convertToMap(uploadResponse.getStdOut()).getAsJsonObject("result").get("code").getAsInt();
JsonObject result = JsonFile.convertToMap(uploadResponse.getStdOut()).getAsJsonObject("result");
int uploadStatus = result.get("code").getAsInt();
System.out.println("uploadResponse code: " + uploadStatus);
if (200 != uploadStatus) {
throw new EnvironmentSetupException(String.format("Unable to upload app: '%s' to '%s'%n%s", appPath, deviceLabURL, uploadResponse));
}
System.out.println("uploadAPKTopCloudy: Uploaded: " + appPath);
String uploadedFileName = result.get("file").getAsString();
System.out.println("uploadAPKTopCloudy: Uploaded: " + uploadedFileName);
return uploadedFileName;
}

private String getpCloudyAuthToken (String emailID, String authenticationKey, String appPath, String deviceLabURL) {
Expand Down

0 comments on commit 7ce1db0

Please sign in to comment.