How to use scanAppForBuild method of com.qaprosoft.appcenter.AppCenterManager class

Best Carina code snippet using com.qaprosoft.appcenter.AppCenterManager.scanAppForBuild

Source:AppCenterManager.java Github

copy

Full Screen

...74 * build.75 * @return download url for build artifact.76 */77 public String getDownloadUrl(String appName, String platformName, String buildType, String version) {78 return scanAppForBuild(getAppId(appName, platformName), buildType, version);79 } 80 /**81 *82 * @param folder to which upload build artifact.83 * @param appName takes in the AppCenter Name to look for.84 * @param platformName takes in the platform we wish to download for.85 * @param buildType takes in the particular build to download (i.e. Prod.AdHoc, QA.Debug, Prod-Release, QA-Internal etc...)86 * @param version takes in either "latest" to take the first build that matches the criteria or allows to consume a version to download that87 * build.88 * @return file to the downloaded build artifact89 */90 public File getBuild(String folder, String appName, String platformName, String buildType, String version) {91 String buildToDownload = getDownloadUrl(appName, platformName, buildType, version);92 //TODO: wrap below code into the public download method93 String fileName = folder + "/" + createFileName(appName, buildType, platformName);94 File fileToLocate = null;95 try {96 File file = new File(folder);97 File[] listOfFiles = file.listFiles();98 if (file.list() != null) {99 for (int i = 0; i < listOfFiles.length; ++i) {100 if (listOfFiles[i].isFile() && fileName.contains(listOfFiles[i].getName())) {101 LOGGER.info("File has been Located Locally. File path is: " + listOfFiles[i].getAbsolutePath());102 fileToLocate = listOfFiles[i];103 }104 }105 }106 } catch (Exception ex) {107 LOGGER.error("Error Attempting to Look for Existing File!", ex);108 }109 if (fileToLocate == null) {110 try {111 LOGGER.debug("Beginning Transfer of AppCenter Build");112 URL downloadLink = new URL(buildToDownload);113 int retryCount = 0;114 boolean retry = true;115 while (retry && retryCount <= 5) {116 retry = downloadBuild(fileName, downloadLink);117 retryCount = retryCount + 1;118 }119 LOGGER.debug(String.format("AppCenter Build (%s) was retrieved", fileName));120 } catch (Exception ex) {121 LOGGER.error("Error Thrown When Attempting to Transfer AppCenter Build!", ex);122 }123 } else {124 LOGGER.info("Preparing to use local version of AppCenter Build...");125 }126 return new File(fileName);127 }128 /**129 *130 * @param fileName will be the name of the downloaded file.131 * @param downloadLink will be the URL to retrieve the build from.132 * @return brings back a true/false on whether or not the build was successfully downloaded.133 * @throws IOException throws a non Interruption Exception up.134 */135 private boolean downloadBuild(String fileName, URL downloadLink) throws IOException {136 try (ReadableByteChannel readableByteChannel = Channels.newChannel(downloadLink.openStream());137 FileOutputStream fos = new FileOutputStream(fileName)) {138 if (Thread.currentThread().isInterrupted()) {139 LOGGER.debug(String.format("Current Thread (%s) is interrupted, clearing interruption.", Thread.currentThread().getId()));140 Thread.interrupted();141 }142 fos.getChannel().transferFrom(readableByteChannel, 0, Long.MAX_VALUE);143 LOGGER.info("Successfully Transferred...");144 return false;145 } catch (ClosedByInterruptException ie1) {146 LOGGER.info("Retrying....");147 LOGGER.error("Getting Error!", ie1);148 return true;149 }150 }151 /**152 *153 * @param appName takes in the AppCenter Name to look for.154 * @param platformName takes in the platform we wish to download for.155 * @return Map&lt;String, String&gt;156 */157 private Map<String, String> getAppId(String appName, String platformName) {158 Map<String, String> appMap = new HashMap<>();159 RequestEntity<String> retrieveApps = buildRequestEntity(160 HOST_URL,161 API_APPS,162 HttpMethod.GET);163 JsonNode appResults = restTemplate.exchange(retrieveApps, JsonNode.class).getBody();164 LOGGER.info("AppCenter Searching For App: " + appName);165 LOGGER.debug("AppCenter JSON Response: " + appResults);166 for (JsonNode node : appResults) {167 if (platformName.equalsIgnoreCase(node.get("os").asText()) && node.get("name").asText().toLowerCase().contains(appName.toLowerCase())) {168 ownerName = node.get("owner").get("name").asText();169 String app = node.get("name").asText();170 LOGGER.info(String.format("Found Owner: %s App: %s", ownerName, app));171 appMap.put(app, getLatestBuildDate(app, node.get("updated_at").asText()));172 }173 }174 if (!appMap.isEmpty()) {175 return appMap.entrySet()176 .stream()177 .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))178 .collect(Collectors.toMap(179 Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));180 }181 throw new RuntimeException(String.format("Application Not Found in AppCenter for Organization (%s) Name (%s), Platform (%s)", ownerName, appName, platformName));182 }183 /**184 *185 * @param apps takes in the application Ids186 * @param buildType takes in the particular build to download (i.e. Prod.AdHoc, QA.Debug, Prod-Release, QA-Internal etc...)187 * @param version takes in either "latest" to take the first build that matches the criteria or allows to consume a version to download that188 * build.189 * @return String190 */191 private String scanAppForBuild(Map<String, String> apps, String buildType, String version) {192 for (String currentApp : apps.keySet()) {193 LOGGER.info("Scanning App " + currentApp);194 MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();195 queryParams.add("published_only", "true");196 queryParams.add("scope", "tester");197 RequestEntity<String> retrieveList = buildRequestEntity(198 HOST_URL,199 String.format("%s/%s/%s/releases", API_APPS, ownerName, currentApp),200 queryParams,201 HttpMethod.GET);202 JsonNode buildList = restTemplate.exchange(retrieveList, JsonNode.class).getBody();203 LOGGER.debug("Available Builds JSON: " + buildList);204 if (buildList.size() > 0) {205 int buildLimiter = 0;...

Full Screen

Full Screen

scanAppForBuild

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.appcenter.AppCenterManager2import com.qaprosoft.appcenter.AppCenterManager.scanAppForBuild3def appCenterManager = new AppCenterManager()4def build = appCenterManager.scanAppForBuild('qaprosoft', 'appium-uiautomator2-driver')5pipeline {6 stages {7 stage('Scan App for Build') {8 steps {9 script {10 def appCenterManager = new com.qaprosoft.appcenter.AppCenterManager()11 def build = appCenterManager.scanAppForBuild('qaprosoft', 'appium-uiautomator2-driver')12 }13 }14 }15 }16}17@Library('appcenter') _18@Grab(group='org.apache.httpcomponents', module='httpclient', version='4.5.2')19@Grab(group='com.fasterxml.jackson.core', module='jackson-databind', version='2.8.8')20@Grab(group='com.fasterxml.jackson.core', module='jackson-core', version='2.8.8')21@Grab(group='com.fasterxml.jackson.core', module='jackson-annotations', version='2.8.8')22@Grab(group='com.fasterxml.jackson.dataformat', module='jackson-dataformat-yaml', version='2.8.8')23@Grab(group='com.fasterxml.jackson.dataformat', module='jackson-dataformat-xml', version='2.8.8')24@Grab(group='com.fasterxml.jackson.module', module='jackson-module-jaxb-annotations', version='2.8.8')25@Grab(group='com.fasterxml.jackson.datatype', module='jackson-datatype-jdk8', version='2.8.8')26@Grab(group='com.fasterxml.jackson.datatype', module='jackson-datatype-jsr310', version='2.8.8')27@Grab(group='com.fasterxml.jackson.dataformat', module='jackson-dataformat-properties', version='2.8.8')28@Grab(group='com.fasterxml.jackson.datatype', module='jackson-datatype-guava', version='2.8.8')29@Grab(group='com.fasterxml.jackson.datatype', module='jackson-datatype-joda', version='2.8

Full Screen

Full Screen

scanAppForBuild

Using AI Code Generation

copy

Full Screen

1def appCenterManager = new com.qaprosoft.appcenter.AppCenterManager()2def build = appCenterManager.scanAppForBuild(appName, buildVersion, buildNumber)3def buildTestersCount = buildTesters.size()4def buildDevicesCount = buildDevices.size()5for (int i = 0; i < buildTestersCount; i++) {6 def buildTesterStr = "Build tester: ${buildTesterName} (${buildTesterEmail}) [${buildTesterId}]"7}8for (int i = 0; i < buildDevicesCount; i++) {9 def buildDeviceStr = "Build device: ${buildDeviceModel} (${buildDeviceOsVersion}, ${buildDeviceOs}) [${buildDeviceId}]"10}11def buildStr = "Build: ${buildId} (${buildStatus}) ${buildUrl}12${buildDownloadUrl}13${buildInstallUrl}14${buildReleaseNotes}15${buildShortVersion}16${buildVersion}17${buildUploadedAt}18${buildMinOsVersion}19${buildIconUrl}20${buildUploadedAt}21${buildTestersStr}22${buildDevicesStr}"

Full Screen

Full Screen

scanAppForBuild

Using AI Code Generation

copy

Full Screen

1import com.qaprosoft.appcenter.AppCenterManager2import com.qaprosoft.appcenter.Build3import com.qaprosoft.appcenter.BuildStatus4def appCenterManager = new AppCenterManager()5def builds = appCenterManager.scanAppForBuild("my-app-name", BuildStatus.Failed)6def json = new groovy.json.JsonBuilder()7json.builds {8 builds.each { build ->9 build(build.id, build.status, build.result, build.sourceVersion)10 }11}12println json.toPrettyString()13import com.qaprosoft.appcenter.AppCenterManager14import com.qaprosoft.appcenter.Build15import com.qaprosoft.appcenter.BuildStatus16def appCenterManager = new AppCenterManager()17def build = appCenterManager.getBuildInfo("my-app-name", "1")18def json = new groovy.json.JsonBuilder()19json.build {20 build(build.id, build.status, build.result, build.sourceVersion)21}22println json.toPrettyString()23import com.qaprosoft.appcenter.AppCenterManager24import com.qaprosoft.appcenter.Build25import

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful