diff --git a/pom.xml b/pom.xml index 856408d..515cadc 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.testdroid testdroid-api - 2.138 + 2.139 jar Bitbar API v2 https://github.com/bitbar/testdroid-api diff --git a/src/main/java/com/testdroid/api/APISimpleList.java b/src/main/java/com/testdroid/api/APISimpleList.java new file mode 100644 index 0000000..503904d --- /dev/null +++ b/src/main/java/com/testdroid/api/APISimpleList.java @@ -0,0 +1,38 @@ +package com.testdroid.api; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import javax.xml.bind.annotation.XmlRootElement; +import java.util.List; + +@XmlRootElement +@JsonIgnoreProperties(value = {"id", "selfURI"}) +public class APISimpleList extends APIEntity { + + private List data; + + public APISimpleList() { + // need for serialization + } + + public APISimpleList(List data) { + this.data = data; + } + + @Override + @JsonIgnore + protected void clone(V from) { + APISimpleList source = (APISimpleList) from; + cloneBase(from); + this.data = source.data; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } +} diff --git a/src/main/java/com/testdroid/api/dto/MappingKey.java b/src/main/java/com/testdroid/api/dto/MappingKey.java index 1fb2dd4..c847b3b 100644 --- a/src/main/java/com/testdroid/api/dto/MappingKey.java +++ b/src/main/java/com/testdroid/api/dto/MappingKey.java @@ -65,7 +65,6 @@ public class MappingKey { public static final String CREATED_BY_EMAIL = "createdByEmail"; public static final String CREATED_BY_ID = "createdById"; public static final String CREATE_TIME = "createTime"; - public static final String CREATE_CBT_ACCOUNT = "createCBTAccount"; public static final String CREDITS_PRICE = "creditsPrice"; public static final String CURRENT_STEP_TYPE = "currentStepType"; public static final String CUSTOM_PLAN = "customPlan"; @@ -208,6 +207,7 @@ public class MappingKey { public static final String ORGANIZATION = "organization"; public static final String ORIGINAL_NAME = "originalName"; public static final String OS_TYPE = "osType"; + public static final String OS_VERSION = "osVersion"; public static final String PAID = "paid"; public static final String PARAMETERS = "parameters"; public static final String PASSED_RATIO = "passedRatio"; diff --git a/src/main/java/com/testdroid/api/model/APIBrokerHub.java b/src/main/java/com/testdroid/api/model/APIBrokerHub.java new file mode 100644 index 0000000..44d07f8 --- /dev/null +++ b/src/main/java/com/testdroid/api/model/APIBrokerHub.java @@ -0,0 +1,80 @@ +package com.testdroid.api.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.testdroid.api.APIEntity; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement +@JsonIgnoreProperties(value = {"id", "selfURI"}) +public class APIBrokerHub extends APIEntity { + + private String location; + + private String url; + + public APIBrokerHub() { + // need for serialization/deserialization + } + + public APIBrokerHub(String location, String url) { + this.location = location; + this.url = url; + } + + @Override + protected void clone(T from) { + APIBrokerHub source = (APIBrokerHub) from; + cloneBase(source); + + this.location = source.location; + this.url = source.url; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("location", location) + .append("url", url) + .toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + + if (o == null || getClass() != o.getClass()) { + return false; + } + + APIBrokerHub hub = (APIBrokerHub) o; + + return new EqualsBuilder().append(location, hub.location).append(url, hub.url).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37).append(location).append(url).toHashCode(); + } +} diff --git a/src/main/java/com/testdroid/api/model/APIClientSideTestConfig.java b/src/main/java/com/testdroid/api/model/APIClientSideTestConfig.java index d5dcf33..9a1e7f6 100644 --- a/src/main/java/com/testdroid/api/model/APIClientSideTestConfig.java +++ b/src/main/java/com/testdroid/api/model/APIClientSideTestConfig.java @@ -21,8 +21,12 @@ public class APIClientSideTestConfig implements Serializable { private String externalId; + private String hookURL; + private String location; + private String osVersion; + private String platform; private String screenResolution; @@ -53,6 +57,14 @@ public static Optional fromString(String name) { public APIClientSideTestConfig() { } + public String getHookURL() { + return hookURL; + } + + public void setHookURL(String hookURL) { + this.hookURL = hookURL; + } + public Target getTarget() { return target; } @@ -132,4 +144,12 @@ public String getExternalId() { public void setExternalId(String externalId) { this.externalId = externalId; } + + public String getOsVersion() { + return osVersion; + } + + public void setOsVersion(String osVersion) { + this.osVersion = osVersion; + } } diff --git a/src/main/java/com/testdroid/api/model/APIDevice.java b/src/main/java/com/testdroid/api/model/APIDevice.java index dbd599c..73044f9 100644 --- a/src/main/java/com/testdroid/api/model/APIDevice.java +++ b/src/main/java/com/testdroid/api/model/APIDevice.java @@ -3,6 +3,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.testdroid.api.APIEntity; import com.testdroid.api.APIList; +import org.apache.commons.lang3.StringUtils; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlType; @@ -41,7 +42,8 @@ public enum Platform { IOS(OsType.IOS), ANDROID(OsType.ANDROID), WINDOWS(OsType.DESKTOP, "Windows"), - MACOS(OsType.DESKTOP, "macOS"), + MAC(OsType.DESKTOP, "macOS"), + MACOS(OsType.DESKTOP, "oldMac"), // TODO: remove in 2.140 LINUX(OsType.DESKTOP, "Linux"), UNDEFINED(OsType.UNDEFINED); @@ -65,6 +67,12 @@ public OsType getOsType() { public String getDisplayName() { return displayName; } + + public static APIDevice.Platform getByDisplayName(String displayName) { + return Arrays.stream(APIDevice.Platform.values()) + .filter(p -> StringUtils.equalsIgnoreCase(p.getDisplayName(), displayName)) + .findAny().orElse(UNDEFINED); + } } @XmlType(namespace = "APIDevice") diff --git a/src/main/java/com/testdroid/api/model/APIDeviceSessionConfig.java b/src/main/java/com/testdroid/api/model/APIDeviceSessionConfig.java index daf9692..fb8a395 100644 --- a/src/main/java/com/testdroid/api/model/APIDeviceSessionConfig.java +++ b/src/main/java/com/testdroid/api/model/APIDeviceSessionConfig.java @@ -22,8 +22,6 @@ public class APIDeviceSessionConfig extends APIEntity implements Serializable { private Long deviceModelId; - private String platform; - private String screenResolution; private APITunnelSettings tunnelSettings; @@ -56,14 +54,6 @@ public APIDeviceSession.Type getType() { return type; } - public String getPlatform() { - return platform; - } - - public void setPlatform(String platform) { - this.platform = platform; - } - public String getBrowserName() { return browserName; } @@ -113,7 +103,6 @@ protected void clone(T from) { this.browserName = prototype.browserName; this.browserVersion = prototype.browserVersion; this.deviceModelId = prototype.deviceModelId; - this.platform = prototype.platform; this.screenResolution = prototype.screenResolution; this.tunnelSettings = prototype.tunnelSettings; this.type = prototype.type; diff --git a/src/main/java/com/testdroid/api/model/APIUser.java b/src/main/java/com/testdroid/api/model/APIUser.java index b31e1f6..5af6ae0 100644 --- a/src/main/java/com/testdroid/api/model/APIUser.java +++ b/src/main/java/com/testdroid/api/model/APIUser.java @@ -120,8 +120,6 @@ public String getDisplayName() { private String registrationIP; - private Boolean sdcSync; - private Collection accountOwners; public APIUser() { @@ -145,7 +143,7 @@ public APIUser( String timeZone, LocalDateTime createTime, LocalDateTime deleteTime, LocalDateTime lastLoginTime, LocalDateTime lastLaunchedTestTime, Boolean isMainUser, Long mainUserId, String mainUserEmail, String apiKey, Status status, Long createdById, String createdByEmail, MfaStatus mfaStatus, - String registrationIP, Boolean sdcSync) { + String registrationIP) { this(id, email, firstName, lastName, createTime, deleteTime, status); this.state = state; this.country = country; @@ -168,7 +166,6 @@ public APIUser( this.mfaStatus = mfaStatus; this.registrationIP = registrationIP; this.selfURI = String.format("/users/%s", id); - this.sdcSync = sdcSync; } public String getEmail() { @@ -445,14 +442,6 @@ public void setRegistrationIP(String registrationIP) { this.registrationIP = registrationIP; } - public Boolean getSdcSync() { - return sdcSync; - } - - public void setSdcSync(Boolean sdcSync) { - this.sdcSync = sdcSync; - } - public void setAccountOwners(Collection accountOwners) { this.accountOwners = accountOwners; } @@ -608,7 +597,6 @@ protected void clone(T from) { this.mfaStatus = apiUser.mfaStatus; this.mfaQRCodeUrl = apiUser.mfaQRCodeUrl; this.registrationIP = apiUser.registrationIP; - this.sdcSync = apiUser.sdcSync; this.accountOwners = apiUser.accountOwners; } } diff --git a/src/main/java/com/testdroid/api/model/capabilities/APIDesktopPlatform.java b/src/main/java/com/testdroid/api/model/capabilities/APIDesktopPlatform.java index cc4b4a4..0a7bd34 100644 --- a/src/main/java/com/testdroid/api/model/capabilities/APIDesktopPlatform.java +++ b/src/main/java/com/testdroid/api/model/capabilities/APIDesktopPlatform.java @@ -2,6 +2,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore; import com.testdroid.api.APIEntity; +import com.testdroid.api.model.APIDevice; import javax.xml.bind.annotation.XmlRootElement; import java.util.*; @@ -20,12 +21,15 @@ public class APIDesktopPlatform extends APIEntity { private List resolutions = new ArrayList<>(); + private String version; + private APIDesktopPlatform() { } - public APIDesktopPlatform(String name) { - this.name = name; - this.value = name.toLowerCase(); + public APIDesktopPlatform(APIDevice.Platform platform, String version) { + this.name = platform.getDisplayName(); + this.value = platform.name(); + this.version = version; } public void setName(String name) { @@ -62,6 +66,18 @@ public APIDesktopPlatform setResolutions(List resolutions) { return this; } + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public APIDevice.Platform toPlatform() { + return APIDevice.Platform.getByDisplayName(name); + } + @Override @JsonIgnore protected void clone(T from) { @@ -71,6 +87,7 @@ protected void clone(T from) { this.value = apiDeviceFilterGroup.value; this.browsers = apiDeviceFilterGroup.browsers; this.resolutions = apiDeviceFilterGroup.resolutions; + this.version = apiDeviceFilterGroup.version; } @Override @@ -84,11 +101,12 @@ public boolean equals(Object o) { APIDesktopPlatform that = (APIDesktopPlatform) o; return name.equals(that.name) && value.equals(that.value) && - browsers.equals(that.browsers); + browsers.equals(that.browsers) && + version.equals(that.version); } @Override public int hashCode() { - return Objects.hash(name, value, browsers); + return Objects.hash(name, value, browsers, version); } } 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 a45a3ca..6761e39 100644 --- a/src/main/java/com/testdroid/api/model/enums/APIPaymentMethod.java +++ b/src/main/java/com/testdroid/api/model/enums/APIPaymentMethod.java @@ -25,8 +25,7 @@ public enum APIPaymentMethod { STRIPE(createStripeMapping()), INVOICE(createInvoiceMapping()), PROMOTION(emptyMap()), - AWS(emptyMap()), - CBT(createCBTMapping()); + AWS(emptyMap()); private static Map, List> createInvoiceMapping() { Map, List> result = new HashMap<>(); @@ -58,17 +57,6 @@ private static Map, List> createStripeMapping() { return Collections.unmodifiableMap(result); } - private static Map, List> createCBTMapping() { - Map, List> result = new HashMap<>(); - //create and activate by CBT - result.put(asList(TRUE, FALSE, FALSE, FALSE), asList(CREATE, ACTIVATE)); - //upgrade by CBT - result.put(asList(TRUE, TRUE, FALSE, FALSE), asList(CREATE, ACTIVATE, CANCEL)); - //cancel by CBT - result.put(asList(FALSE, TRUE, FALSE, FALSE), singletonList(CANCEL)); - return Collections.unmodifiableMap(result); - } - private final Map, List> operationSchema; APIPaymentMethod(Map, List> operationSchema) { diff --git a/src/main/java/com/testdroid/api/util/TypeReferenceFactory.java b/src/main/java/com/testdroid/api/util/TypeReferenceFactory.java index edfb16b..2cb995b 100644 --- a/src/main/java/com/testdroid/api/util/TypeReferenceFactory.java +++ b/src/main/java/com/testdroid/api/util/TypeReferenceFactory.java @@ -1,11 +1,7 @@ package com.testdroid.api.util; import com.fasterxml.jackson.core.type.TypeReference; -import com.testdroid.api.APIMaintenance; -import com.testdroid.api.APIEntity; -import com.testdroid.api.APIExceptionMessage; -import com.testdroid.api.APIList; -import com.testdroid.api.APIMessage; +import com.testdroid.api.*; import com.testdroid.api.model.*; import com.testdroid.api.model.capabilities.APIDesktopBrowserCapabilities; import com.testdroid.api.model.devicetime.APIBasicDeviceTime; @@ -88,6 +84,14 @@ public class TypeReferenceFactory { //@formatter:on } + private static final Map, TypeReference> SIMPLE_LIST_MAP = new HashMap<>(); + + static { + //@formatter:off + SIMPLE_LIST_MAP.put(APIBrokerHub.class, new TypeReference>() {}); + //@formatter:on + } + private static final Map, TypeReference> MAP = new HashMap<>(); static { @@ -167,6 +171,10 @@ public static TypeReference> getListTypeRef(Cla return (TypeReference>) LIST_MAP.get(clazz); } + public static TypeReference> getSimpleListTypeRef(Class clazz) { + return (TypeReference>) SIMPLE_LIST_MAP.get(clazz); + } + public static TypeReference> getMapTypeReference() { return new TypeReference>() { };