Skip to content

Commit

Permalink
Merge pull request #318 from snieguu/master
Browse files Browse the repository at this point in the history
Version 2.42
  • Loading branch information
szprutamich committed Jun 28, 2017
2 parents 7b075b9 + 377a594 commit ff54055
Show file tree
Hide file tree
Showing 13 changed files with 240 additions and 32 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.testdroid</groupId>
<artifactId>testdroid-api</artifactId>
<version>2.41</version>
<version>2.42</version>
<packaging>jar</packaging>
<name>Testdroid API v2</name>
<url>https://github.com/bitbar/testdroid-api</url>
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/com/testdroid/api/APIEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@
APIAdminInteractiveDeviceSession.class,
APIUserIntegration.class,
APIAdminDeviceSessionStatistics.class,
APIActivity.class
APIActivity.class,
APIDevicePicker.class,
APIDeviceFilter.class,
APIDeviceFilterGroup.class
})
public abstract class APIEntity {

Expand Down
20 changes: 12 additions & 8 deletions src/main/java/com/testdroid/api/APIKeyClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,18 +412,18 @@ public APIUser register(String email) throws APIException {

@Override
public APIListResource<APIDevice> getDevices() {
return new APIListResource<APIDevice>(this, DEVICES_URI);
return new APIListResource<>(this, DEVICES_URI);
}

@Override
public APIListResource<APIDevice> getDevices(APIDevice.DeviceFilter... filters) {
return new APIListResource<APIDevice>(this, DEVICES_URI, new APIDeviceQueryBuilder()
return new APIListResource<>(this, DEVICES_URI, new APIDeviceQueryBuilder()
.filterWithDeviceFilters(filters));
}

@Override
public APIListResource<APIDevice> getDevices(APIDeviceQueryBuilder queryBuilder) {
return new APIListResource<APIDevice>(this, DEVICES_URI, queryBuilder);
return new APIListResource<>(this, DEVICES_URI, queryBuilder);
}

@Override
Expand Down Expand Up @@ -483,13 +483,17 @@ private String buildUrl(String url, APIQueryBuilder queryBuilder) throws APIExce
}
}

private Map fixMapParameters(Map map) {
for (Object key : map.keySet()) {
if (map.get(key) == null) {
private Map fixMapParameters(Map<String, Object> map) {
String key;
Object value;
for (Map.Entry<String, Object> entry : map.entrySet()) {
key = entry.getKey();
value = entry.getValue();
if (value == null) {
map.put(key, "");
}
if (map.get(key) instanceof Enum<?>) {
map.put(key, map.get(key).toString());
if (value instanceof Enum<?>) {
map.put(key, value.toString());
}
}
return map;
Expand Down
26 changes: 15 additions & 11 deletions src/main/java/com/testdroid/api/DefaultAPIClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,12 +208,12 @@ protected String acquireAccessToken() throws APIException {
}

GenericUrl url = new GenericUrl(String.format("%s/oauth/token", cloudURL));
HttpContent content = new UrlEncodedContent(new HashMap() {{
put("client_id", "testdroid-cloud-api");
put("grant_type", "password");
put("username", username);
put("password", password);
}});
HashMap data = new HashMap();
data.put("client_id", "testdroid-cloud-api");
data.put("grant_type", "password");
data.put("username", username);
data.put("password", password);
HttpContent content = new UrlEncodedContent(data);

HttpRequest request = httpTransport.createRequestFactory().buildPostRequest(url, content);
request.setConnectTimeout(HTTP_CONNECT_TIMEOUT); // one minute
Expand Down Expand Up @@ -648,13 +648,17 @@ private String buildUrl(String url, APIQueryBuilder queryBuilder) throws APIExce
}
}

private Map fixMapParameters(Map map) {
for (Object key : map.keySet()) {
if (map.get(key) == null) {
private Map fixMapParameters(Map<String, Object> map) {
String key;
Object value;
for (Map.Entry<String, Object> entry : map.entrySet()) {
key = entry.getKey();
value = entry.getValue();
if (value == null) {
map.put(key, "");
}
if (map.get(key) instanceof Enum<?>) {
map.put(key, map.get(key).toString());
if (value instanceof Enum<?>) {
map.put(key, value.toString());
}
}
return map;
Expand Down
27 changes: 26 additions & 1 deletion src/main/java/com/testdroid/api/model/APIAdminDeviceProblem.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ public class APIAdminDeviceProblem extends APIEntity {

private Long deviceId;

private Long deviceModelId;

private String deviceModelName;

private String deviceName;

private APIAdminDeviceProblemPair[] problems;
Expand All @@ -25,11 +29,14 @@ public APIAdminDeviceProblem() {
}

public APIAdminDeviceProblem(
Long clusterId, String clusterName, Long deviceId, String deviceName, APIAdminDeviceProblemPair[] problems) {
Long clusterId, String clusterName, Long deviceId, String deviceName, Long deviceModelId,
String deviceModelName, APIAdminDeviceProblemPair[] problems) {
this.clusterId = clusterId;
this.clusterName = clusterName;
this.deviceId = deviceId;
this.deviceName = deviceName;
this.deviceModelId = deviceModelId;
this.deviceModelName = deviceModelName;
this.problems = problems;
}

Expand Down Expand Up @@ -65,6 +72,22 @@ public void setDeviceName(String deviceName) {
this.deviceName = deviceName;
}

public Long getDeviceModelId() {
return deviceModelId;
}

public void setDeviceModelId(Long deviceModelId) {
this.deviceModelId = deviceModelId;
}

public String getDeviceModelName() {
return deviceModelName;
}

public void setDeviceModelName(String deviceModelName) {
this.deviceModelName = deviceModelName;
}

public APIAdminDeviceProblemPair[] getProblems() {
return problems;
}
Expand All @@ -82,6 +105,8 @@ protected <T extends APIEntity> void clone(T from) {
this.clusterName = apiAdminDeviceProblem.clusterName;
this.deviceId = apiAdminDeviceProblem.deviceId;
this.deviceName = apiAdminDeviceProblem.deviceName;
this.deviceModelId = apiAdminDeviceProblem.deviceModelId;
this.deviceModelName = apiAdminDeviceProblem.deviceModelName;
this.problems = apiAdminDeviceProblem.problems;
}
}
12 changes: 12 additions & 0 deletions 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.fasterxml.jackson.annotation.JsonView;
import com.testdroid.api.APIEntity;
import com.testdroid.api.APIList;
import com.testdroid.api.APIView;

import javax.xml.bind.annotation.XmlRootElement;
Expand Down Expand Up @@ -88,6 +89,8 @@ public boolean isIos() {

private String mainUserEmail;

private APIList<APIDeviceProperty> properties;

public APIDevice() {
}

Expand Down Expand Up @@ -300,6 +303,14 @@ public void setMainUserEmail(String mainUserEmail) {
this.mainUserEmail = mainUserEmail;
}

public APIList<APIDeviceProperty> getProperties() {
return properties;
}

public void setProperties(APIList<APIDeviceProperty> properties) {
this.properties = properties;
}

@Override
@JsonIgnore
protected <T extends APIEntity> void clone(T from) {
Expand All @@ -325,6 +336,7 @@ protected <T extends APIEntity> void clone(T from) {
this.enabled = apiDevice.enabled;
this.accountId = apiDevice.accountId;
this.mainUserEmail = apiDevice.mainUserEmail;
this.properties = apiDevice.properties;
}

}
52 changes: 52 additions & 0 deletions src/main/java/com/testdroid/api/model/APIDeviceFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.testdroid.api.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.testdroid.api.APIEntity;

import javax.xml.bind.annotation.XmlRootElement;

/**
* @author Michał Szpruta <michal.szpruta@bitbar.com>
*/
@XmlRootElement
public class APIDeviceFilter extends APIEntity {

private String name;

private boolean hidden;

public APIDeviceFilter() {
}

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

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public boolean isHidden() {
return hidden;
}

public void setHidden(boolean hidden) {
this.hidden = hidden;
}

@Override
@JsonIgnore
protected <T extends APIEntity> void clone(T from) {
APIDeviceFilter apiDeviceFilter = (APIDeviceFilter) from;
cloneBase(from);
this.name = apiDeviceFilter.name;
this.hidden = apiDeviceFilter.hidden;
}

}
52 changes: 52 additions & 0 deletions src/main/java/com/testdroid/api/model/APIDeviceFilterGroup.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.testdroid.api.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.testdroid.api.APIEntity;

import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;

/**
* @author Michał Szpruta <michal.szpruta@bitbar.com>
*/
@XmlRootElement
public class APIDeviceFilterGroup extends APIEntity {

private String name;

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

public APIDeviceFilterGroup() {
}

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

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public List<APIDeviceFilter> getDeviceFilters() {
return deviceFilters;
}

public void setDeviceFilters(List<APIDeviceFilter> deviceFilters) {
this.deviceFilters = deviceFilters;
}

@Override
@JsonIgnore
protected <T extends APIEntity> void clone(T from) {
APIDeviceFilterGroup apiDeviceFilterGroup = (APIDeviceFilterGroup) from;
cloneBase(from);
this.name = apiDeviceFilterGroup.name;
this.deviceFilters = apiDeviceFilterGroup.deviceFilters;
}
}
41 changes: 41 additions & 0 deletions src/main/java/com/testdroid/api/model/APIDevicePicker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.testdroid.api.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.testdroid.api.APIEntity;

import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;

/**
* @author Michał Szpruta <michal.szpruta@bitbar.com>
*/
@XmlRootElement
public class APIDevicePicker extends APIEntity {

private List<APIDeviceFilterGroup> deviceFilterGroups = new ArrayList<>();

public APIDevicePicker() {
}

public APIDevicePicker(Long id, List<APIDeviceFilterGroup> deviceFilterGroups) {
super(id);
this.deviceFilterGroups = deviceFilterGroups;
}

public List<APIDeviceFilterGroup> getDeviceFilterGroups() {
return deviceFilterGroups;
}

public void setDeviceFilterGroups(List<APIDeviceFilterGroup> deviceFilterGroups) {
this.deviceFilterGroups = deviceFilterGroups;
}

@Override
@JsonIgnore
protected <T extends APIEntity> void clone(T from) {
APIDevicePicker apiDevicePicker = (APIDevicePicker) from;
this.deviceFilterGroups = apiDevicePicker.deviceFilterGroups;
cloneBase(from);
}
}
13 changes: 12 additions & 1 deletion src/main/java/com/testdroid/api/model/APIProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ public APIProjectJobConfig.Type getJobConfigType() {

private Long frameworkId;

private boolean isShared;

public APIProject() {
}

public APIProject(
Long id, Date createTime, Date archiveTime, String name, String description, Type type, Long sharedById,
String sharedByEmail, boolean common, APIArchivingStrategy archivingStrategy, Integer archivingItemCount,
Long frameworkId) {
Long frameworkId, Boolean isShared) {
super(id);
this.createTime = createTime;
this.archiveTime = archiveTime;
Expand All @@ -116,6 +118,7 @@ public APIProject(
this.archivingStrategy = archivingStrategy;
this.archivingItemCount = archivingItemCount;
this.frameworkId = frameworkId;
this.isShared = isShared;
this.jobConfig = new HashMap<>();
}

Expand Down Expand Up @@ -188,6 +191,14 @@ public void setSharedByEmail(String sharedByEmail) {
this.sharedByEmail = sharedByEmail;
}

public boolean isShared() {
return isShared;
}

public void setShared(boolean isShared) {
this.isShared = isShared;
}

public APIArchivingStrategy getArchivingStrategy() {
return archivingStrategy;
}
Expand Down
Loading

0 comments on commit ff54055

Please sign in to comment.