All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.saucelabs.rdc.helper.RdcEnvironmentVariables Maven / Gradle / Ivy

Go to download

Library for running Appium test suites and updating test status on Sauce Labs Real Device Cloud (RDC)

The newest version!
package com.saucelabs.rdc.helper;

import java.util.Optional;
import java.util.OptionalLong;
import java.util.concurrent.TimeUnit;

import static java.lang.Long.parseLong;

public class RdcEnvironmentVariables {
	private static final String API_KEY = "API_KEY";
	private static final String SUITE_ID = "SUITE_ID";
	private static final String API_URL = "API_URL";
	private static final String APP_ID = "APP_ID";
	private static final String TIMEOUT = "TIMEOUT";
	private static final String TIMEOUT_UNIT = "TIMEOUT_UNIT";
	private static final String TEST_LOCALLY = "TEST_LOCALLY";

	public static Optional getApiKey() {
		return Optional.ofNullable(System.getenv(API_KEY));
	}

	public static Optional getSuiteId() {
		return Optional.ofNullable(System.getenv(SUITE_ID)).map(Long::valueOf);
	}

	public static String getApiEndpoint() {
		String apiUrl = System.getenv(API_URL);
		if (apiUrl == null) {
			return "https://app.testobject.com/api";
		} else {
			return apiUrl;
		}
	}

	public static OptionalLong getAppId() {
		String appId = System.getenv(APP_ID);
		if (appId == null) {
			return OptionalLong.empty();
		} else {
			return OptionalLong.of(parseLong(appId));
		}
	}

	public static Optional getTimeout() {
		return Optional.ofNullable(System.getenv(TIMEOUT)).map(Integer::valueOf);
	}

	public static Optional getTimeoutUnit() {
		return Optional.ofNullable(System.getenv(TIMEOUT_UNIT)).map(TimeUnit::valueOf);
	}

	public static Optional isTestingLocally() {
		return Optional.ofNullable(System.getenv(TEST_LOCALLY)).map(Boolean::valueOf);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy