├── README.md
├── pom.xml
└── src
├── main
└── java
│ └── com
│ └── github
│ └── yunusmete
│ └── stf
│ ├── api
│ ├── STFService.java
│ └── ServiceGenerator.java
│ ├── model
│ ├── App.java
│ ├── Battery.java
│ ├── Browser.java
│ ├── Device.java
│ ├── DeviceBody.java
│ ├── Display.java
│ ├── Network.java
│ ├── Phone.java
│ ├── Provider.java
│ ├── Settings.java
│ └── User.java
│ └── rest
│ ├── ClaimResponse.java
│ ├── DeviceResponse.java
│ ├── RemoteConnectResponse.java
│ └── UserResponse.java
└── test
└── java
├── AppiumTest.java
└── STF.java
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | ## OpenSTF Java Client
4 | [](https://maven-badges.herokuapp.com/maven-central/com.github.yunusmete.stf/openstf-java-client/)
5 |
6 | This project is a client of OpenSTF REST API which enables controlling and managing devices in device farm from your browser. You can go and view the project from this link: https://github.com/openstf/stf
7 |
8 | You can use that client with test automation frameworks like Appium.
9 |
10 | ### Download
11 |
12 | Maven:
13 | ```xml
14 |
15 | com.github.yunusmete.stf
16 | openstf-java-client
17 | 1.0
18 |
19 | ```
20 |
21 | Gradle:
22 | ```
23 | compile 'com.github.yunusmete.stf:openstf-java-client:1.0'
24 | ```
25 |
26 | Also you can download [the latest JAR][1] and add to your project.
27 |
28 | ### License [](https://opensource.org/licenses/Apache-2.0)
29 |
30 | Copyright 2016 Yunus Mete, Turkey.
31 |
32 | Licensed under the Apache License, Version 2.0 (the "License");
33 | you may not use this file except in compliance with the License.
34 | You may obtain a copy of the License at
35 |
36 | http://www.apache.org/licenses/LICENSE-2.0
37 |
38 | Unless required by applicable law or agreed to in writing, software
39 | distributed under the License is distributed on an "AS IS" BASIS,
40 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
41 | See the License for the specific language governing permissions and
42 | limitations under the License.
43 |
44 | [1]: http://repo1.maven.org/maven2/com/github/yunusmete/stf/openstf-java-client/1.0/
45 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | com.github.yunusmete.stf
8 | openstf-java-client
9 | jar
10 | openstf-java-client
11 | 1.0
12 | Java Client for Open STF API
13 | https://github.com/yunusmete/openstf-java-client
14 |
15 |
16 |
17 | Apache License, Version 2.0
18 | https://www.apache.org/licenses/LICENSE-2.0
19 |
20 |
21 |
22 |
23 |
24 | Yunus Mete
25 | yunusmete32@gmail.com
26 | Netas
27 | https://www.netas.com.tr
28 |
29 |
30 |
31 |
32 | UTF-8
33 | 1.7
34 | 1.7
35 |
36 |
37 |
38 | scm:git:git@github.com/yunusmete/openstf-java-client.git
39 | scm:git:git@github.com/yunusmete/openstf-java-client.git
40 | git@github.com/yunusmete/openstf-java-client.git
41 | openstf-java-client-1.0.0
42 |
43 |
44 |
45 |
46 | com.squareup.retrofit
47 | retrofit
48 | 1.9.0
49 |
50 |
51 | com.squareup.okhttp
52 | okhttp
53 | 2.7.2
54 |
55 |
56 | io.appium
57 | java-client
58 | 4.0.0
59 |
60 |
61 | junit
62 | junit
63 | 4.12
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | org.apache.maven.plugins
72 | maven-gpg-plugin
73 |
74 |
75 | sign-artifacts
76 | verify
77 |
78 | sign
79 |
80 |
81 |
82 |
83 |
84 |
85 | org.sonatype.plugins
86 | nexus-staging-maven-plugin
87 | 1.6.3
88 | true
89 |
90 | ossrh
91 | https://oss.sonatype.org/
92 | true
93 |
94 |
95 |
96 |
97 | org.apache.maven.plugins
98 | maven-source-plugin
99 |
100 |
101 | attach-sources
102 |
103 | jar
104 |
105 |
106 |
107 |
108 |
109 | org.apache.maven.plugins
110 | maven-javadoc-plugin
111 |
112 |
113 | attach-javadocs
114 |
115 | jar
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 | ossrh
126 | https://oss.sonatype.org/content/repositories/snapshots
127 |
128 |
129 |
130 |
131 |
--------------------------------------------------------------------------------
/src/main/java/com/github/yunusmete/stf/api/STFService.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.yunusmete.stf.api;
3 |
4 | import com.github.yunusmete.stf.model.DeviceBody;
5 | import com.github.yunusmete.stf.rest.RemoteConnectResponse;
6 | import com.github.yunusmete.stf.rest.UserResponse;
7 | import retrofit.http.*;
8 |
9 | import com.github.yunusmete.stf.rest.ClaimResponse;
10 | import com.github.yunusmete.stf.rest.DeviceResponse;
11 |
12 | /**
13 | * Created by yunusm on 07.11.2016.
14 | */
15 | public interface STFService {
16 |
17 | // DEVICE API
18 |
19 | /**
20 | * Get list of devices
21 | *
22 | * @return list of devices
23 | */
24 | @GET("/devices")
25 | DeviceResponse getDevices();
26 |
27 | @GET("/devices/{serial}")
28 | DeviceResponse getDeviceBySerial(@Path("serial") String serial);
29 |
30 | // USER API
31 | @GET("/user")
32 | UserResponse getUser();
33 |
34 | @GET("/user/devices")
35 | DeviceResponse getUserDevices();
36 |
37 | @POST("/user/devices")
38 | ClaimResponse addDeviceToUser(@Body DeviceBody body);
39 |
40 | @DELETE("/user/devices/{serial}")
41 | ClaimResponse deleteDeviceBySerial(@Path("serial") String serial);
42 |
43 | @POST("/user/devices/{serial}/remoteConnect")
44 | RemoteConnectResponse remoteConnectDeviceBySerial(@Path("serial") String serial);
45 |
46 | @DELETE("/user/devices/{serial}/remoteConnect")
47 | RemoteConnectResponse remoteDisconnectDeviceBySerial(@Path("serial") String serial);
48 |
49 | @GET("/user/accessTokens")
50 | DeviceResponse getAccessTokens();
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/com/github/yunusmete/stf/api/ServiceGenerator.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.yunusmete.stf.api;
3 |
4 | import retrofit.RequestInterceptor;
5 | import retrofit.RestAdapter;
6 | import retrofit.client.OkClient;
7 |
8 | import com.squareup.okhttp.OkHttpClient;
9 |
10 | /**
11 | * Created by yunusm on 07.11.2016.
12 | */
13 | public class ServiceGenerator {
14 |
15 | public static String API_BASE_URL = "localhost:7100/api/v1";
16 |
17 | private static RestAdapter.Builder builder = new RestAdapter.Builder().setEndpoint(API_BASE_URL)
18 | .setClient(new OkClient(new OkHttpClient()));
19 |
20 | public static S createService(Class serviceClass, final String baseURL, final String accessToken) {
21 | if (accessToken != null) {
22 | builder.setEndpoint(baseURL).setRequestInterceptor(new RequestInterceptor() {
23 | public void intercept(RequestFacade requestFacade) {
24 | requestFacade.addHeader("Authorization", "Bearer " + accessToken);
25 | }
26 | });
27 | }
28 |
29 | RestAdapter adapter = builder.build();
30 | return adapter.create(serviceClass);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/com/github/yunusmete/stf/model/App.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.yunusmete.stf.model;
3 |
4 | import javax.annotation.Generated;
5 | import com.google.gson.annotations.Expose;
6 | import com.google.gson.annotations.SerializedName;
7 |
8 | public class App {
9 |
10 | @SerializedName("id")
11 | @Expose
12 | private String id;
13 | @SerializedName("name")
14 | @Expose
15 | private String name;
16 | @SerializedName("selected")
17 | @Expose
18 | private boolean selected;
19 | @SerializedName("system")
20 | @Expose
21 | private boolean system;
22 | @SerializedName("type")
23 | @Expose
24 | private String type;
25 | @SerializedName("developer")
26 | @Expose
27 | private String developer;
28 |
29 | /**
30 | * @return The id
31 | */
32 | public String getId() {
33 | return id;
34 | }
35 |
36 | /**
37 | * @param id
38 | * The id
39 | */
40 | public void setId(String id) {
41 | this.id = id;
42 | }
43 |
44 | /**
45 | * @return The name
46 | */
47 | public String getName() {
48 | return name;
49 | }
50 |
51 | /**
52 | * @param name
53 | * The name
54 | */
55 | public void setName(String name) {
56 | this.name = name;
57 | }
58 |
59 | /**
60 | * @return The selected
61 | */
62 | public boolean isSelected() {
63 | return selected;
64 | }
65 |
66 | /**
67 | * @param selected
68 | * The selected
69 | */
70 | public void setSelected(boolean selected) {
71 | this.selected = selected;
72 | }
73 |
74 | /**
75 | * @return The system
76 | */
77 | public boolean isSystem() {
78 | return system;
79 | }
80 |
81 | /**
82 | * @param system
83 | * The system
84 | */
85 | public void setSystem(boolean system) {
86 | this.system = system;
87 | }
88 |
89 | /**
90 | * @return The type
91 | */
92 | public String getType() {
93 | return type;
94 | }
95 |
96 | /**
97 | * @param type
98 | * The type
99 | */
100 | public void setType(String type) {
101 | this.type = type;
102 | }
103 |
104 | /**
105 | * @return The developer
106 | */
107 | public String getDeveloper() {
108 | return developer;
109 | }
110 |
111 | /**
112 | * @param developer
113 | * The developer
114 | */
115 | public void setDeveloper(String developer) {
116 | this.developer = developer;
117 | }
118 |
119 | @Override
120 | public String toString() {
121 | return "App{" + "id='" + id + '\'' + ", name='" + name + '\'' + ", selected=" + selected + ", system=" + system + ", type='" + type + '\'' + ", developer='" + developer + '\'' + '}';
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/src/main/java/com/github/yunusmete/stf/model/Battery.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.yunusmete.stf.model;
3 |
4 | import javax.annotation.Generated;
5 | import com.google.gson.annotations.Expose;
6 | import com.google.gson.annotations.SerializedName;
7 |
8 | public class Battery {
9 |
10 | @SerializedName("health")
11 | @Expose
12 | private String health;
13 | @SerializedName("level")
14 | @Expose
15 | private int level;
16 | @SerializedName("scale")
17 | @Expose
18 | private int scale;
19 | @SerializedName("source")
20 | @Expose
21 | private String source;
22 | @SerializedName("status")
23 | @Expose
24 | private String status;
25 | @SerializedName("temp")
26 | @Expose
27 | private double temp;
28 | @SerializedName("voltage")
29 | @Expose
30 | private double voltage;
31 |
32 | /**
33 | * @return The health
34 | */
35 | public String getHealth() {
36 | return health;
37 | }
38 |
39 | /**
40 | * @param health
41 | * The health
42 | */
43 | public void setHealth(String health) {
44 | this.health = health;
45 | }
46 |
47 | /**
48 | * @return The level
49 | */
50 | public int getLevel() {
51 | return level;
52 | }
53 |
54 | /**
55 | * @param level
56 | * The level
57 | */
58 | public void setLevel(int level) {
59 | this.level = level;
60 | }
61 |
62 | /**
63 | * @return The scale
64 | */
65 | public int getScale() {
66 | return scale;
67 | }
68 |
69 | /**
70 | * @param scale
71 | * The scale
72 | */
73 | public void setScale(int scale) {
74 | this.scale = scale;
75 | }
76 |
77 | /**
78 | * @return The source
79 | */
80 | public String getSource() {
81 | return source;
82 | }
83 |
84 | /**
85 | * @param source
86 | * The source
87 | */
88 | public void setSource(String source) {
89 | this.source = source;
90 | }
91 |
92 | /**
93 | * @return The status
94 | */
95 | public String getStatus() {
96 | return status;
97 | }
98 |
99 | /**
100 | * @param status
101 | * The status
102 | */
103 | public void setStatus(String status) {
104 | this.status = status;
105 | }
106 |
107 | /**
108 | * @return The temp
109 | */
110 | public double getTemp() {
111 | return temp;
112 | }
113 |
114 | /**
115 | * @param temp
116 | * The temp
117 | */
118 | public void setTemp(double temp) {
119 | this.temp = temp;
120 | }
121 |
122 | /**
123 | * @return The voltage
124 | */
125 | public double getVoltage() {
126 | return voltage;
127 | }
128 |
129 | /**
130 | * @param voltage
131 | * The voltage
132 | */
133 | public void setVoltage(double voltage) {
134 | this.voltage = voltage;
135 | }
136 |
137 | @Override
138 | public String toString() {
139 | return "Battery{" + "health='" + health + '\'' + ", level=" + level + ", scale=" + scale + ", source='" + source + '\'' + ", status='" + status + '\'' + ", temp=" + temp + ", voltage=" + voltage + '}';
140 | }
141 | }
142 |
--------------------------------------------------------------------------------
/src/main/java/com/github/yunusmete/stf/model/Browser.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.yunusmete.stf.model;
3 |
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import com.google.gson.annotations.Expose;
8 | import com.google.gson.annotations.SerializedName;
9 |
10 | public class Browser {
11 |
12 | @SerializedName("apps")
13 | @Expose
14 | private List apps = new ArrayList();
15 | @SerializedName("selected")
16 | @Expose
17 | private boolean selected;
18 |
19 | /**
20 | * @return The apps
21 | */
22 | public List getApps() {
23 | return apps;
24 | }
25 |
26 | /**
27 | * @param apps
28 | * The apps
29 | */
30 | public void setApps(List apps) {
31 | this.apps = apps;
32 | }
33 |
34 | /**
35 | * @return The selected
36 | */
37 | public boolean isSelected() {
38 | return selected;
39 | }
40 |
41 | /**
42 | * @param selected
43 | * The selected
44 | */
45 | public void setSelected(boolean selected) {
46 | this.selected = selected;
47 | }
48 |
49 | @Override
50 | public String toString() {
51 | return "Browser{" + "apps=" + apps + ", selected=" + selected + '}';
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/com/github/yunusmete/stf/model/Device.java:
--------------------------------------------------------------------------------
1 |
2 | package com.github.yunusmete.stf.model;
3 |
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import com.google.gson.annotations.Expose;
8 | import com.google.gson.annotations.SerializedName;
9 |
10 | public class Device {
11 |
12 | @SerializedName("abi")
13 | @Expose
14 | private String abi;
15 | @SerializedName("airplaneMode")
16 | @Expose
17 | private boolean airplaneMode;
18 | @SerializedName("battery")
19 | @Expose
20 | private Battery battery;
21 | @SerializedName("browser")
22 | @Expose
23 | private Browser browser;
24 | @SerializedName("channel")
25 | @Expose
26 | private String channel;
27 | @SerializedName("createdAt")
28 | @Expose
29 | private String createdAt;
30 | @SerializedName("display")
31 | @Expose
32 | private Display display;
33 | @SerializedName("manufacturer")
34 | @Expose
35 | private String manufacturer;
36 | @SerializedName("model")
37 | @Expose
38 | private String model;
39 | @SerializedName("network")
40 | @Expose
41 | private Network network;
42 | @SerializedName("operator")
43 | @Expose
44 | private String operator;
45 | @SerializedName("owner")
46 | @Expose
47 | private Object owner;
48 | @SerializedName("phone")
49 | @Expose
50 | private Phone phone;
51 | @SerializedName("platform")
52 | @Expose
53 | private String platform;
54 | @SerializedName("presenceChangedAt")
55 | @Expose
56 | private String presenceChangedAt;
57 | @SerializedName("present")
58 | @Expose
59 | private boolean present;
60 | @SerializedName("product")
61 | @Expose
62 | private String product;
63 | @SerializedName("provider")
64 | @Expose
65 | private Provider provider;
66 | @SerializedName("ready")
67 | @Expose
68 | private boolean ready;
69 | @SerializedName("remoteConnect")
70 | @Expose
71 | private boolean remoteConnect;
72 | @SerializedName("remoteConnectUrl")
73 | @Expose
74 | private Object remoteConnectUrl;
75 | @SerializedName("reverseForwards")
76 | @Expose
77 | private List