Skip to content

Commit

Permalink
Merge pull request #443 from wicherska/master
Browse files Browse the repository at this point in the history
Version 2.139
  • Loading branch information
szprutamich authored Mar 15, 2022
2 parents 217f148 + 5ed0ad4 commit b64bcfb
Show file tree
Hide file tree
Showing 11 changed files with 187 additions and 50 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.testdroid</groupId>
<artifactId>testdroid-api</artifactId>
<version>2.138</version>
<version>2.139</version>
<packaging>jar</packaging>
<name>Bitbar API v2</name>
<url>https://github.com/bitbar/testdroid-api</url>
Expand Down
38 changes: 38 additions & 0 deletions src/main/java/com/testdroid/api/APISimpleList.java
Original file line number Diff line number Diff line change
@@ -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<T extends APIEntity> extends APIEntity {

private List<T> data;

public APISimpleList() {
// need for serialization
}

public APISimpleList(List<T> data) {
this.data = data;
}

@Override
@JsonIgnore
protected <V extends APIEntity> void clone(V from) {
APISimpleList<T> source = (APISimpleList<T>) from;
cloneBase(from);
this.data = source.data;
}

public List<T> getData() {
return data;
}

public void setData(List<T> data) {
this.data = data;
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/testdroid/api/dto/MappingKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
80 changes: 80 additions & 0 deletions src/main/java/com/testdroid/api/model/APIBrokerHub.java
Original file line number Diff line number Diff line change
@@ -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 <T extends APIEntity> 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();
}
}
20 changes: 20 additions & 0 deletions src/main/java/com/testdroid/api/model/APIClientSideTestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -53,6 +57,14 @@ public static Optional<Target> fromString(String name) {
public APIClientSideTestConfig() {
}

public String getHookURL() {
return hookURL;
}

public void setHookURL(String hookURL) {
this.hookURL = hookURL;
}

public Target getTarget() {
return target;
}
Expand Down Expand Up @@ -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;
}
}
10 changes: 9 additions & 1 deletion src/main/java/com/testdroid/api/model/APIDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand All @@ -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")
Expand Down
11 changes: 0 additions & 11 deletions src/main/java/com/testdroid/api/model/APIDeviceSessionConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ public class APIDeviceSessionConfig extends APIEntity implements Serializable {

private Long deviceModelId;

private String platform;

private String screenResolution;

private APITunnelSettings tunnelSettings;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -113,7 +103,6 @@ protected <T extends APIEntity> 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;
Expand Down
14 changes: 1 addition & 13 deletions src/main/java/com/testdroid/api/model/APIUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ public String getDisplayName() {

private String registrationIP;

private Boolean sdcSync;

private Collection<APIUser> accountOwners;

public APIUser() {
Expand All @@ -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;
Expand All @@ -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() {
Expand Down Expand Up @@ -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<APIUser> accountOwners) {
this.accountOwners = accountOwners;
}
Expand Down Expand Up @@ -608,7 +597,6 @@ protected <T extends APIEntity> void clone(T from) {
this.mfaStatus = apiUser.mfaStatus;
this.mfaQRCodeUrl = apiUser.mfaQRCodeUrl;
this.registrationIP = apiUser.registrationIP;
this.sdcSync = apiUser.sdcSync;
this.accountOwners = apiUser.accountOwners;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -20,12 +21,15 @@ public class APIDesktopPlatform extends APIEntity {

private List<String> 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) {
Expand Down Expand Up @@ -62,6 +66,18 @@ public APIDesktopPlatform setResolutions(List<String> 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 <T extends APIEntity> void clone(T from) {
Expand All @@ -71,6 +87,7 @@ protected <T extends APIEntity> void clone(T from) {
this.value = apiDeviceFilterGroup.value;
this.browsers = apiDeviceFilterGroup.browsers;
this.resolutions = apiDeviceFilterGroup.resolutions;
this.version = apiDeviceFilterGroup.version;
}

@Override
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ public enum APIPaymentMethod {
STRIPE(createStripeMapping()),
INVOICE(createInvoiceMapping()),
PROMOTION(emptyMap()),
AWS(emptyMap()),
CBT(createCBTMapping());
AWS(emptyMap());

private static Map<List<Boolean>, List<PlanOperation>> createInvoiceMapping() {
Map<List<Boolean>, List<PlanOperation>> result = new HashMap<>();
Expand Down Expand Up @@ -58,17 +57,6 @@ private static Map<List<Boolean>, List<PlanOperation>> createStripeMapping() {
return Collections.unmodifiableMap(result);
}

private static Map<List<Boolean>, List<PlanOperation>> createCBTMapping() {
Map<List<Boolean>, List<PlanOperation>> 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<Boolean>, List<PlanOperation>> operationSchema;

APIPaymentMethod(Map<List<Boolean>, List<PlanOperation>> operationSchema) {
Expand Down
Loading

0 comments on commit b64bcfb

Please sign in to comment.