Skip to content

Commit

Permalink
Merge pull request #488 from szprutamich/master
Browse files Browse the repository at this point in the history
Version 3.19
  • Loading branch information
szprutamich authored May 16, 2023
2 parents dde4aad + bb5a03e commit a0822bb
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 23 deletions.
11 changes: 8 additions & 3 deletions 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>3.18</version>
<version>3.19</version>
<packaging>jar</packaging>
<name>Bitbar API v2</name>
<url>https://github.com/bitbar/testdroid-api</url>
Expand All @@ -12,11 +12,11 @@
<jacoco-maven-plugin.skip>true</jacoco-maven-plugin.skip>
<!-- disable default deployment -->
<maven.deploy.skip>true</maven.deploy.skip>
<org.springframework.boot.spring-boot-dependencies>2.7.9</org.springframework.boot.spring-boot-dependencies>
<org.springframework.boot.spring-boot-dependencies>2.7.10</org.springframework.boot.spring-boot-dependencies>
<org.apache.commons.collections4.version>4.4</org.apache.commons.collections4.version>
<org.apache.commons.io.version>2.11.0</org.apache.commons.io.version>
<commons-text.version>1.10.0</commons-text.version>
<com.google.http-client>1.42.3</com.google.http-client>
<com.google.http-client>1.43.1</com.google.http-client>
<com.google.oauth-client>1.34.1</com.google.oauth-client>
<dependency-check-maven.version>6.1.1</dependency-check-maven.version>
<jacoco-maven-plugin.version>0.8.7</jacoco-maven-plugin.version>
Expand Down Expand Up @@ -284,5 +284,10 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>
3 changes: 3 additions & 0 deletions src/main/java/com/testdroid/api/AbstractAPIClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public abstract class AbstractAPIClient implements APIClient {
private static final List<Integer> POSSIBLE_GET_STATUSES = Arrays.asList(SC_OK, SC_ACCEPTED, SC_CREATED,
SC_NO_CONTENT);

/**
* @throws APIException Overriding classes may throw this exception if they execute some API calls
*/
protected HttpRequestFactory getRequestFactory() throws APIException {
return httpTransport.createRequestFactory();
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/testdroid/api/dto/MappingKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ private MappingKey() {
public static final String IP_ADDRESS = "ipAddress";
public static final String IS_EXCLUDED = "isExcluded";
public static final String IS_MAIN_USER = "isMainUser";
public static final String JENKINS_VERSION = "jenkinsVersion";
public static final String JOB_CONFIG_ID = "jobConfigId";
public static final String KEY = "key";
public static final String LABEL_GROUP_ID = "labelGroupId";
Expand Down
16 changes: 8 additions & 8 deletions src/main/java/com/testdroid/api/model/APIAdminDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ public APIAdminDevice(
String unlockGesture, String releaseVersion, Integer apiLevel, Long deviceModelId,
String deviceModelName, ComplexState state, LocalDateTime stateTime, LocalDateTime stateChangeTime,
InitStep initStep, String ipAddress, Long clusterId, String clusterName, String clusterUrl,
String jenkinsUrl, String pluginVersion, APICluster.State clusterState, LocalDateTime clusterStateTime,
LocalDateTime clusterStateChangeTime, Boolean clusterEnabled, APICluster.Type clusterType,
String clusterIpAddress, String clusterRegion, String clusterLocation, LocalDateTime lastOnlineTime,
Long accountId, String mainUserEmail, String location, Long testTimeLimit, Boolean locked,
APIDevice.OsType osType, APIDevice.Platform platform) {
String jenkinsUrl, String pluginVersion, String jenkinsVersion, APICluster.State clusterState,
LocalDateTime clusterStateTime, LocalDateTime clusterStateChangeTime, Boolean clusterEnabled,
APICluster.Type clusterType, String clusterIpAddress, String clusterRegion, String clusterLocation,
LocalDateTime lastOnlineTime, Long accountId, String mainUserEmail, String location, Long testTimeLimit,
Boolean locked, APIDevice.OsType osType, APIDevice.Platform platform) {
super(id);
this.name = name;
this.manufacturer = manufacturer;
Expand All @@ -162,9 +162,9 @@ public APIAdminDevice(
this.stateChangeTime = TimeConverter.toDate(stateChangeTime);
this.initStep = initStep;
this.ipAddress = ipAddress;
this.cluster = new APICluster(clusterId, clusterName, clusterUrl, jenkinsUrl, pluginVersion, clusterState,
clusterStateTime, clusterStateChangeTime, clusterEnabled, clusterType, clusterIpAddress, clusterRegion,
clusterLocation);
this.cluster = new APICluster(clusterId, clusterName, clusterUrl, jenkinsUrl, pluginVersion, jenkinsVersion,
clusterState, clusterStateTime, clusterStateChangeTime, clusterEnabled, clusterType, clusterIpAddress,
clusterRegion, clusterLocation);
this.lastOnlineTime = TimeConverter.toDate(lastOnlineTime);
this.accountId = accountId;
this.testTimeLimit = testTimeLimit;
Expand Down
21 changes: 18 additions & 3 deletions src/main/java/com/testdroid/api/model/APICluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public enum Type {

private String pluginVersion;

private String jenkinsVersion;

private Type type = Type.BARE_METAL;

private String ipAddress;
Expand All @@ -66,9 +68,9 @@ public APICluster() {

@SuppressWarnings("squid:S107")
public APICluster(
Long id, String name, String url, String jenkinsUrl, String pluginVersion, State state,
LocalDateTime stateTime, LocalDateTime stateChangeTime, Boolean enabled, Type type, String ipAddress,
String region, String location) {
Long id, String name, String url, String jenkinsUrl, String pluginVersion, String jenkinsVersion,
State state, LocalDateTime stateTime, LocalDateTime stateChangeTime, Boolean enabled, Type type,
String ipAddress, String region, String location) {
super(id);
this.name = name;
this.url = url;
Expand All @@ -78,6 +80,7 @@ public APICluster(
this.stateChangeTime = TimeConverter.toDate(stateChangeTime);
this.enabled = enabled;
this.pluginVersion = pluginVersion;
this.jenkinsVersion = jenkinsVersion;
this.type = type;
this.ipAddress = ipAddress;
this.region = region;
Expand Down Expand Up @@ -120,6 +123,15 @@ public APICluster setPluginVersion(String pluginVersion) {
return this;
}

public String getJenkinsVersion() {
return jenkinsVersion;
}

public APICluster setJenkinsVersion(String jenkinsVersion) {
this.jenkinsVersion = jenkinsVersion;
return this;
}

public State getState() {
return state;
}
Expand Down Expand Up @@ -215,6 +227,7 @@ protected <T extends APIEntity> void clone(T from) {
this.url = apiCluster.url;
this.jenkinsUrl = apiCluster.jenkinsUrl;
this.pluginVersion = apiCluster.pluginVersion;
this.jenkinsVersion = apiCluster.jenkinsVersion;
this.type = apiCluster.type;
this.ipAddress = apiCluster.ipAddress;
this.region = apiCluster.region;
Expand Down Expand Up @@ -242,6 +255,7 @@ public boolean equals(Object o) {
.append(url, cluster.url)
.append(jenkinsUrl, cluster.jenkinsUrl)
.append(pluginVersion, cluster.pluginVersion)
.append(jenkinsVersion, cluster.jenkinsVersion)
.append(type, cluster.type)
.append(ipAddress, cluster.ipAddress)
.append(region, cluster.region)
Expand All @@ -260,6 +274,7 @@ public int hashCode() {
.append(url)
.append(jenkinsUrl)
.append(pluginVersion)
.append(jenkinsVersion)
.append(type)
.append(ipAddress)
.append(region)
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/com/testdroid/api/model/APIDeviceFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,22 @@ public class APIDeviceFilter extends APIEntity {
@JsonIgnore
private String labelGroupDisplayName;

@JsonIgnore
private boolean expanded;

public APIDeviceFilter() {
}

@SuppressWarnings("squid:S107")
public APIDeviceFilter(
Long labelId, String labelName, String labelDisplayName, Long labelGroupId, String labelGroupDisplayName,
boolean hidden, APIDevice.OsType osType, Long order) {
boolean hidden, boolean expanded, APIDevice.OsType osType, Long order) {
super(labelId);
this.parentId = labelGroupId;
this.name = labelName;
this.displayName = labelDisplayName;
this.hidden = hidden;
this.expanded = expanded;
this.osType = osType;
this.labelGroupDisplayName = labelGroupDisplayName;
}
Expand Down Expand Up @@ -72,6 +76,10 @@ public String getLabelGroupDisplayName() {
return labelGroupDisplayName;
}

public boolean isExpanded() {
return expanded;
}

@Override
@JsonIgnore
protected <T extends APIEntity> void clone(T from) {
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/com/testdroid/api/model/APIDeviceFilterGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ public class APIDeviceFilterGroup extends APIEntity {

private String name;

private boolean expanded;

private List<APIDeviceFilter> deviceFilters = new ArrayList<>();

public APIDeviceFilterGroup() {
}

public APIDeviceFilterGroup(Long id, String name) {
public APIDeviceFilterGroup(Long id, String name, boolean expanded) {
super(id);
this.name = name;
this.expanded = expanded;
}

public String getName() {
Expand All @@ -31,6 +34,14 @@ public void setName(String name) {
this.name = name;
}

public boolean isExpanded() {
return expanded;
}

public void setExpanded(boolean expanded) {
this.expanded = expanded;
}

public List<APIDeviceFilter> getDeviceFilters() {
return deviceFilters;
}
Expand All @@ -46,6 +57,7 @@ protected <T extends APIEntity> void clone(T from) {
APIDeviceFilterGroup apiDeviceFilterGroup = (APIDeviceFilterGroup) from;
cloneBase(from);
this.name = apiDeviceFilterGroup.name;
this.expanded = apiDeviceFilterGroup.expanded;
this.deviceFilters = apiDeviceFilterGroup.deviceFilters;
}
}
13 changes: 6 additions & 7 deletions src/test/java/com/testdroid/api/APIUserAPIClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import static java.util.Collections.singletonMap;
import static org.apache.commons.lang3.StringUtils.EMPTY;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

/**
Expand Down Expand Up @@ -213,13 +214,11 @@ void requestScreenshotsZip(APIClient apiClient) throws APIException, Interrupted
assertThat(apiTestRun.getState()).isIn(RUNNING, WAITING);
apiTestRun.requestScreenshotsZip();
APIUserFile file = apiTestRun.getScreenshotsZip();
while (file.getState() != APIUserFile.State.READY) {
try {
TimeUnit.SECONDS.sleep(3);
file.refresh();
} catch (InterruptedException ignore) {
}
}
await().atMost(3, TimeUnit.MINUTES).pollInterval(3, TimeUnit.SECONDS)
.until(() -> {
file.refresh();
return file.getState() == APIUserFile.State.READY;
});
try (InputStream inputStream = file.getFile()) {
FileUtils.copyInputStreamToFile(inputStream, Files.createTempFile(null, null).toFile());
}
Expand Down

0 comments on commit a0822bb

Please sign in to comment.