diff --git a/pom.xml b/pom.xml index 92f957ec..675454a4 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.testdroid testdroid-api - 2.58 + 2.59 jar Testdroid API v2 https://github.com/bitbar/testdroid-api @@ -122,5 +122,10 @@ jackson-databind 2.6.0 + + org.slf4j + slf4j-log4j12 + 1.7.13 + diff --git a/src/main/java/com/testdroid/api/APIEntity.java b/src/main/java/com/testdroid/api/APIEntity.java index c5b2e8e2..dbabdc51 100644 --- a/src/main/java/com/testdroid/api/APIEntity.java +++ b/src/main/java/com/testdroid/api/APIEntity.java @@ -15,8 +15,6 @@ import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.logging.Level; -import java.util.logging.Logger; /** * @author Łukasz Kajda @@ -206,12 +204,7 @@ private void checkClient(APIClient client) throws APIException { @JsonIgnore public String toJson() throws JsonProcessingException { - try { - return new ObjectMapper().writeValueAsString(this); - } catch (JsonProcessingException ex) { - Logger.getLogger(APIEntity.class.getName()).log(Level.SEVERE, null, ex); - } - return ""; + return new ObjectMapper().writeValueAsString(this); } @JsonIgnore diff --git a/src/main/java/com/testdroid/api/APIKeyClient.java b/src/main/java/com/testdroid/api/APIKeyClient.java index a1753685..7ddae8b5 100644 --- a/src/main/java/com/testdroid/api/APIKeyClient.java +++ b/src/main/java/com/testdroid/api/APIKeyClient.java @@ -3,8 +3,6 @@ import com.google.api.client.http.HttpHeaders; import com.google.api.client.http.apache.ApacheHttpTransport; import com.google.api.client.http.javanet.NetHttpTransport; -import com.testdroid.api.dto.Context; -import com.testdroid.api.model.APIDevice; import org.apache.commons.lang3.StringUtils; import org.apache.http.HttpHost; import org.apache.http.auth.AuthScope; @@ -16,16 +14,18 @@ import org.apache.http.impl.auth.BasicScheme; import org.apache.http.impl.client.BasicAuthCache; import org.apache.http.impl.client.DefaultHttpClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.security.GeneralSecurityException; -import java.util.logging.Level; -import java.util.logging.Logger; /** * @author Michał Szpruta */ public class APIKeyClient extends AbstractAPIClient { + private static final Logger LOGGER = LoggerFactory.getLogger(APIKeyClient.class); + private String apiKey; public APIKeyClient(String cloudURL, String apiKey) { @@ -38,9 +38,7 @@ public APIKeyClient(String cloudURL, String apiKey, boolean skipCheckCertificate try { netHttpBuilder = new NetHttpTransport.Builder().doNotValidateCertificate(); } catch (GeneralSecurityException ex) { - Logger.getLogger(APIKeyClient.class.getName()) - .log(Level.WARNING, "Cannot set not-validating certificate. Certificate will be validating.", - ex); + LOGGER.warn("Cannot set not-validating certificate. Certificate will be validating.", ex); netHttpBuilder = new NetHttpTransport.Builder(); } } else { @@ -57,9 +55,7 @@ public APIKeyClient(String cloudURL, String username, HttpHost proxy, boolean sk try { apacheBuilder = new ApacheHttpTransport.Builder().setProxy(proxy).doNotValidateCertificate(); } catch (GeneralSecurityException ex) { - Logger.getLogger(APIKeyClient.class.getName()) - .log(Level.WARNING, "Cannot set not-validating certificate. Certificate will be validating.", - ex); + LOGGER.warn("Cannot set not-validating certificate. Certificate will be validating.", ex); apacheBuilder = new ApacheHttpTransport.Builder().setProxy(proxy); } } else { diff --git a/src/main/java/com/testdroid/api/APISort.java b/src/main/java/com/testdroid/api/APISort.java index 473d0f5a..77a0ba0d 100644 --- a/src/main/java/com/testdroid/api/APISort.java +++ b/src/main/java/com/testdroid/api/APISort.java @@ -85,7 +85,7 @@ public String serialize() { return sorts.stream().map(SortItem::toString).collect(Collectors.joining(":")); } - public String toString(){ + public String toString() { return serialize(); } diff --git a/src/main/java/com/testdroid/api/DefaultAPIClient.java b/src/main/java/com/testdroid/api/DefaultAPIClient.java index 62db1822..6b5df198 100644 --- a/src/main/java/com/testdroid/api/DefaultAPIClient.java +++ b/src/main/java/com/testdroid/api/DefaultAPIClient.java @@ -1,16 +1,10 @@ package com.testdroid.api; -import com.fasterxml.jackson.core.type.TypeReference; import com.google.api.client.auth.oauth2.BearerToken; import com.google.api.client.auth.oauth2.Credential; import com.google.api.client.http.*; import com.google.api.client.http.apache.ApacheHttpTransport; import com.google.api.client.http.javanet.NetHttpTransport; -import com.testdroid.api.dto.Context; -import com.testdroid.api.http.MultipartFormDataContent; -import com.testdroid.api.model.APIDevice; -import com.testdroid.api.model.APILabelGroup; -import com.testdroid.api.model.APIUser; import net.sf.json.JSONObject; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; @@ -21,27 +15,18 @@ import org.apache.http.auth.UsernamePasswordCredentials; import org.apache.http.client.AuthCache; import org.apache.http.client.protocol.HttpClientContext; -import org.apache.http.client.utils.URIBuilder; import org.apache.http.conn.params.ConnRoutePNames; import org.apache.http.impl.auth.BasicScheme; import org.apache.http.impl.client.BasicAuthCache; import org.apache.http.impl.client.DefaultHttpClient; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import javax.xml.bind.JAXBContext; -import javax.xml.bind.JAXBException; -import javax.xml.bind.Unmarshaller; import java.io.File; import java.io.IOException; import java.io.InputStream; -import java.io.StringReader; -import java.net.URISyntaxException; import java.security.GeneralSecurityException; -import java.util.Arrays; -import java.util.Collections; import java.util.HashMap; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; import static java.nio.charset.StandardCharsets.UTF_8; @@ -52,6 +37,8 @@ */ public class DefaultAPIClient extends AbstractAPIClient { + private static final Logger LOGGER = LoggerFactory.getLogger(APIKeyClient.class); + public static final int HTTP_CONNECT_TIMEOUT = 60000; public static final int HTTP_READ_TIMEOUT = 60000; @@ -78,9 +65,7 @@ public DefaultAPIClient(String cloudURL, String username, String password, boole try { netHttpBuilder = new NetHttpTransport.Builder().doNotValidateCertificate(); } catch (GeneralSecurityException ex) { - Logger.getLogger(DefaultAPIClient.class.getName()) - .log(Level.WARNING, "Cannot set not-validating certificate. Certificate will be validating.", - ex); + LOGGER.warn("Cannot set not-validating certificate. Certificate will be validating.", ex); netHttpBuilder = new NetHttpTransport.Builder(); } } else { @@ -99,9 +84,7 @@ public DefaultAPIClient( try { apacheBuilder = new ApacheHttpTransport.Builder().setProxy(proxy).doNotValidateCertificate(); } catch (GeneralSecurityException ex) { - Logger.getLogger(DefaultAPIClient.class.getName()) - .log(Level.WARNING, "Cannot set not-validating certificate. Certificate will be validating.", - ex); + LOGGER.warn("Cannot set not-validating certificate. Certificate will be validating.", ex); apacheBuilder = new ApacheHttpTransport.Builder().setProxy(proxy); } } else { diff --git a/src/main/java/com/testdroid/api/model/APIBillingPeriodType.java b/src/main/java/com/testdroid/api/model/APIBillingPeriodType.java index ef433064..4d090671 100644 --- a/src/main/java/com/testdroid/api/model/APIBillingPeriodType.java +++ b/src/main/java/com/testdroid/api/model/APIBillingPeriodType.java @@ -4,7 +4,6 @@ * @author Damian Sniezek */ public enum APIBillingPeriodType { - BUY, CHARGE, CANCEL diff --git a/src/main/java/com/testdroid/api/model/APIDeviceSession.java b/src/main/java/com/testdroid/api/model/APIDeviceSession.java index f13acad8..aee52a09 100644 --- a/src/main/java/com/testdroid/api/model/APIDeviceSession.java +++ b/src/main/java/com/testdroid/api/model/APIDeviceSession.java @@ -17,8 +17,9 @@ public class APIDeviceSession extends APIEntity { @XmlType(namespace = "APIDeviceSession") public enum Type { - MANUAL, - AUTOMATIC + ADB, + AUTOMATIC, + MANUAL } @XmlType(namespace = "APIDeviceSession") @@ -92,6 +93,8 @@ public boolean isFinished() { private Long deviceTime; + private Long duration; + public APIDeviceSession() { } @@ -125,7 +128,8 @@ public APIDeviceSession(Long id, Type type, Date createTime, Date startTime, Dat APIDevice device, Long timeLimit, Long launchAppDuration, State state, Long deviceRunId, Integer testCaseAllCount, Integer testCaseSuccessCount, Integer testCasePassedCount, Integer testCaseFailedCount, Integer testCaseSkippedCount, Boolean billable, String excludeReason, - Long deviceInstanceId, RetryState retryState, Integer autoRetriesLeftCount, Long deviceTime) { + Long deviceInstanceId, RetryState retryState, Integer autoRetriesLeftCount, Long deviceTime, + Long duration) { this(id, type, createTime, startTime, installTime, endTime, device, timeLimit, launchAppDuration, state, deviceRunId, billable, excludeReason, deviceTime); this.testCaseAllCount = testCaseAllCount; @@ -136,6 +140,7 @@ public APIDeviceSession(Long id, Type type, Date createTime, Date startTime, Dat this.deviceInstanceId = deviceInstanceId; this.retryState = retryState; this.autoRetriesLeftCount = autoRetriesLeftCount; + this.duration = duration; } public Type getType() { @@ -306,6 +311,14 @@ public void setDeviceTime(Long deviceTime) { this.deviceTime = deviceTime; } + public Long getDuration() { + return duration; + } + + public void setDuration(Long duration) { + this.duration = duration; + } + @JsonIgnore public APIListResource getDeviceSessionStepsResource() throws APIException { return getListResource(createUri(selfURI, "/steps"), APIDeviceSessionStep.class); @@ -361,5 +374,6 @@ protected void clone(T from) { this.retryState = apiDeviceSession.retryState; this.autoRetriesLeftCount = apiDeviceSession.autoRetriesLeftCount; this.deviceTime = apiDeviceSession.deviceTime; + this.duration = apiDeviceSession.duration; } } diff --git a/src/main/java/com/testdroid/api/model/APIProject.java b/src/main/java/com/testdroid/api/model/APIProject.java index debc586a..64fa59fd 100644 --- a/src/main/java/com/testdroid/api/model/APIProject.java +++ b/src/main/java/com/testdroid/api/model/APIProject.java @@ -435,7 +435,6 @@ public APITestRun runWithConfig( Map body = new HashMap<>(); body.put("scheduler", config.getScheduler() != null ? config.getScheduler().name() : null); body.put("appCrawlerRun", config.isAppCrawlerRun()); - body.put("autoScreenshots", config.isAutoScreenshots()); body.put("screenshotDir", config.getScreenshotDir()); body.put("limitationType", config.getLimitationType() != null ? config.getLimitationType().name() : null); body.put("limitationValue", config.getLimitationValue()); @@ -449,7 +448,6 @@ public APITestRun runWithConfig( body.put("uiAutomatorTestClasses", config.getUiAutomatorTestClasses()); body.put("launchApp", config.isLaunchApp()); body.put("instrumentationRunner", config.getInstrumentationRunner()); - body.put("appRequired", config.isAppRequired()); body.put("timeout", config.getTimeout()); body.put("name", testRunName); body.put("usedDeviceIds[]", StringUtils.join(deviceIds, ",")); diff --git a/src/main/java/com/testdroid/api/model/APIProjectJobConfig.java b/src/main/java/com/testdroid/api/model/APIProjectJobConfig.java index 38882f8a..504a4256 100644 --- a/src/main/java/com/testdroid/api/model/APIProjectJobConfig.java +++ b/src/main/java/com/testdroid/api/model/APIProjectJobConfig.java @@ -17,6 +17,7 @@ public class APIProjectJobConfig extends APIEntity { @XmlType(namespace = "APIProjectJobConfig") public enum Type { + ADB(APIDevice.OsType.ANDROID, "Remote ADB"), DEFAULT(APIDevice.OsType.ANDROID, "Android instrumentation"), INSTATEST(APIDevice.OsType.ANDROID, "Android App Crawler"), INTERACTIVE(APIDevice.OsType.ANDROID, "Testdroid Interactive"), diff --git a/src/main/java/com/testdroid/api/model/APITestRunConfig.java b/src/main/java/com/testdroid/api/model/APITestRunConfig.java index 8ab47d7b..647531e4 100644 --- a/src/main/java/com/testdroid/api/model/APITestRunConfig.java +++ b/src/main/java/com/testdroid/api/model/APITestRunConfig.java @@ -32,24 +32,16 @@ public enum Scheduler { SINGLE } - private boolean createVNCConnection; - private String appiumBrokerAddress; - private boolean appRequired = true; - private String applicationPassword; private String applicationUsername; - private boolean autoScreenshots; - private Long creditsPrice; private String deviceLanguageCode = Locale.US.toString(); - private boolean useAdditionalFiles = true; - private boolean videoRecordingEnabled; private String hookURL; @@ -126,17 +118,15 @@ public APITestRunConfig() { } public APITestRunConfig( - Long id, Scheduler scheduler, Boolean appCrawlerRun, Boolean autoScreenshots, String screenshotDir, - LimitationType limitationType, String limitationValue, String withAnnotation, String withoutAnnotation, - String applicationUsername, String applicationPassword, Long deviceGroupId, - String usedDeviceGroupName, Long creditsPrice, String deviceLanguageCode, String hookURL, - String uiAutomatorTestClasses, Boolean launchApp, String instrumentationRunner, Boolean appRequired, - Boolean useAdditionalFiles, Boolean videoRecordingEnabled, Long timeout, String appiumBrokerAddress, - Boolean createVNCConnection, Integer maxAutoRetriesCount) { + Long id, Scheduler scheduler, Boolean appCrawlerRun, String screenshotDir, LimitationType limitationType, + String limitationValue, String withAnnotation, String withoutAnnotation, String applicationUsername, + String applicationPassword, Long deviceGroupId, String usedDeviceGroupName, Long creditsPrice, + String deviceLanguageCode, String hookURL, String uiAutomatorTestClasses, Boolean launchApp, + String instrumentationRunner, Boolean videoRecordingEnabled, Long timeout, String appiumBrokerAddress, + Integer maxAutoRetriesCount) { super(id); this.scheduler = scheduler; this.appCrawlerRun = appCrawlerRun; - this.autoScreenshots = autoScreenshots; this.screenshotDir = screenshotDir; this.limitationType = limitationType; this.limitationValue = limitationValue; @@ -153,12 +143,9 @@ public APITestRunConfig( this.uiAutomatorTestClasses = uiAutomatorTestClasses; this.launchApp = launchApp; this.instrumentationRunner = instrumentationRunner; - this.appRequired = appRequired; this.videoRecordingEnabled = videoRecordingEnabled; this.timeout = timeout; - this.useAdditionalFiles = useAdditionalFiles; this.appiumBrokerAddress = appiumBrokerAddress; - this.createVNCConnection = createVNCConnection; this.maxAutoRetriesCount = maxAutoRetriesCount; } @@ -194,14 +181,6 @@ public void setLimitationType(LimitationType limitationType) { this.limitationType = limitationType; } - public boolean isAutoScreenshots() { - return autoScreenshots; - } - - public void setAutoScreenshots(boolean autoScreenshots) { - this.autoScreenshots = autoScreenshots; - } - public boolean isRunAvailable() { return runAvailable; } @@ -332,14 +311,6 @@ public void setInstrumentationRunner(String instrumentationRunner) { this.instrumentationRunner = instrumentationRunner; } - public boolean isAppRequired() { - return appRequired; - } - - public void setAppRequired(boolean appRequired) { - this.appRequired = appRequired; - } - private String getParametersURI() { return createUri(selfURI, "/parameters"); } @@ -352,14 +323,6 @@ public void setTimeout(Long timeout) { this.timeout = timeout; } - public boolean getUseAdditionalFiles() { - return useAdditionalFiles; - } - - public void setUseAdditionalFiles(boolean useAdditionalFiles) { - this.useAdditionalFiles = useAdditionalFiles; - } - public boolean isVideoRecordingEnabled() { return videoRecordingEnabled; } @@ -376,14 +339,6 @@ public void setAppiumBrokerAddress(String appiumBrokerAddress) { this.appiumBrokerAddress = appiumBrokerAddress; } - public boolean isCreateVNCConnection() { - return createVNCConnection; - } - - public void setCreateVNCConnection(boolean createVNCConnection) { - this.createVNCConnection = createVNCConnection; - } - public Integer getMaxAutoRetriesCount() { return maxAutoRetriesCount; } @@ -549,7 +504,6 @@ public void update() throws APIException { Map body = new HashMap<>(); body.put("scheduler", scheduler != null ? scheduler.name() : null); body.put("appCrawlerRun", appCrawlerRun); - body.put("autoScreenshots", autoScreenshots); body.put("screenshotDir", screenshotDir); body.put("limitationType", limitationType != null ? limitationType.name() : null); body.put("limitationValue", limitationValue); @@ -563,10 +517,8 @@ public void update() throws APIException { body.put("uiAutomatorTestClasses", uiAutomatorTestClasses); body.put("launchApp", launchApp); body.put("instrumentationRunner", instrumentationRunner); - body.put("appRequired", appRequired); body.put("timeout", timeout); body.put("appiumBrokerAddress", appiumBrokerAddress); - body.put("createVNCConnection", createVNCConnection); body.put("maxAutoRetriesCount", maxAutoRetriesCount); APITestRunConfig config = postResource(selfURI, body, APITestRunConfig.class); clone(config); @@ -579,8 +531,6 @@ protected void clone(T from) { cloneBase(from); this.applicationPassword = apiTestRunConfig.applicationPassword; this.applicationUsername = apiTestRunConfig.applicationUsername; - this.appRequired = apiTestRunConfig.appRequired; - this.autoScreenshots = apiTestRunConfig.autoScreenshots; this.creditsPrice = apiTestRunConfig.creditsPrice; this.deviceLanguageCode = apiTestRunConfig.deviceLanguageCode; this.videoRecordingEnabled = apiTestRunConfig.videoRecordingEnabled; @@ -601,9 +551,7 @@ protected void clone(T from) { this.withAnnotation = apiTestRunConfig.withAnnotation; this.withoutAnnotation = apiTestRunConfig.withoutAnnotation; this.timeout = apiTestRunConfig.timeout; - this.useAdditionalFiles = apiTestRunConfig.useAdditionalFiles; this.appiumBrokerAddress = apiTestRunConfig.appiumBrokerAddress; - this.createVNCConnection = apiTestRunConfig.createVNCConnection; this.maxAutoRetriesCount = apiTestRunConfig.maxAutoRetriesCount; this.frameworkId = apiTestRunConfig.frameworkId; this.availableDeviceGroups = apiTestRunConfig.availableDeviceGroups; diff --git a/src/main/java/com/testdroid/api/model/DeviceRunStateType.java b/src/main/java/com/testdroid/api/model/DeviceRunStateType.java deleted file mode 100644 index d2625e4c..00000000 --- a/src/main/java/com/testdroid/api/model/DeviceRunStateType.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.testdroid.api.model; - -import javax.xml.bind.annotation.XmlType; - -/** - * @author Łukasz Kajda - * @author Slawomir Pawluk - */ -@XmlType -public enum DeviceRunStateType { - PREPARING, - WAITING, - DEVICE_WAITING, - DEVICE_DOWNLOAD_TESTSESSION, - DEVICE_UNINSTALLING_ALL, - DEVICE_REBOOTING, - DEVICE_WIFI_CHECKING, - DEVICE_ADD_PERMISSIONS, - DEVICE_REPACKAGING, - DEVICE_TARGET_INSTALLING, - DEVICE_TEST_INSTALLING, - DEVICE_REMOTECONTROL_RUNNING, - DEVICE_RUNNING, - DEVICE_SDCARD_COPYING, - DEVICE_TARGET_UNINSTALLING, - DEVICE_UIAUTOMATOR_RUNNING, - DEVICE_TEST_UNINSTALLING, - RESULTS_WAITING, - RESULTS_PROCESSING, - PARSE_LOGCAT, - ADB_SHELL_COMMAND; - - public String getDisplayName() { - switch (this) { - case PARSE_LOGCAT: - return "Launching application"; - case DEVICE_REBOOTING: - return "Rebooting device"; - case DEVICE_REPACKAGING: - return "Repackaging APKs"; - case DEVICE_RUNNING: - return "Running tests"; - case DEVICE_SDCARD_COPYING: - return "Retrieving data from SD card"; - case DEVICE_TARGET_INSTALLING: - return "Installing application"; - case DEVICE_TARGET_UNINSTALLING: - return "Uninstalling application"; - case DEVICE_TEST_INSTALLING: - return "Installing test APK"; - case DEVICE_TEST_UNINSTALLING: - return "Uninstalling test APK"; - case DEVICE_UNINSTALLING_ALL: - return "Cleaning device for testing"; - case DEVICE_WAITING: - return "Uploading test data to the device"; - case DEVICE_WIFI_CHECKING: - return "WI-FI verification"; - case DEVICE_ADD_PERMISSIONS: - return "Added permissions in APK's manifest"; - case DEVICE_DOWNLOAD_TESTSESSION: - return "Downloading test session"; - case PREPARING: - return "Preparing test run"; - case RESULTS_PROCESSING: - return "Processing results"; - case RESULTS_WAITING: - return "Downloading results from the device"; - case WAITING: - return "Waiting in queue for device"; - case DEVICE_UIAUTOMATOR_RUNNING: - return "Running UIAutomator tests"; - case DEVICE_REMOTECONTROL_RUNNING: - return "Remote control"; - case ADB_SHELL_COMMAND: - return "ADB shell command"; - default: - return "Unknown state"; - } - } - -} diff --git a/src/main/java/com/testdroid/api/model/enums/APIPaymentMethod.java b/src/main/java/com/testdroid/api/model/enums/APIPaymentMethod.java index 4608cdb9..8ad41918 100644 --- a/src/main/java/com/testdroid/api/model/enums/APIPaymentMethod.java +++ b/src/main/java/com/testdroid/api/model/enums/APIPaymentMethod.java @@ -1,6 +1,8 @@ package com.testdroid.api.model.enums; -import static java.lang.Boolean.*; +import static java.lang.Boolean.FALSE; +import static java.lang.Boolean.TRUE; + /** * @author Łukasz Kajda */ @@ -14,11 +16,11 @@ public enum APIPaymentMethod { private Boolean allowUpdate; - private APIPaymentMethod(){ + APIPaymentMethod() { } - private APIPaymentMethod(Boolean allowUpdate){ + APIPaymentMethod(Boolean allowUpdate) { this.allowUpdate = allowUpdate; } diff --git a/src/main/java/com/testdroid/api/sample/RunProjectSample.java b/src/main/java/com/testdroid/api/sample/RunProjectSample.java index 670ef78c..869d2515 100644 --- a/src/main/java/com/testdroid/api/sample/RunProjectSample.java +++ b/src/main/java/com/testdroid/api/sample/RunProjectSample.java @@ -35,7 +35,6 @@ public static void main(String[] args) { // Configure test run config testRunConfig.setApplicationPassword("applicationPassword"); testRunConfig.setApplicationUsername("applicationUsername"); - testRunConfig.setAutoScreenshots(false); testRunConfig.setDeviceLanguageCode("EN"); testRunConfig.setDeviceGroupId(deviceGroup.getId()); testRunConfig.setAppCrawlerRun(Boolean.FALSE);