summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/com/mavlushechka/a1qa/utils/JSONPlaceholderAPIManager.java28
-rw-r--r--src/main/resources/testData.json5
2 files changed, 20 insertions, 13 deletions
diff --git a/src/main/java/com/mavlushechka/a1qa/utils/JSONPlaceholderAPIManager.java b/src/main/java/com/mavlushechka/a1qa/utils/JSONPlaceholderAPIManager.java
index 2305daf..25b9fe4 100644
--- a/src/main/java/com/mavlushechka/a1qa/utils/JSONPlaceholderAPIManager.java
+++ b/src/main/java/com/mavlushechka/a1qa/utils/JSONPlaceholderAPIManager.java
@@ -9,28 +9,32 @@ import java.util.List;
public class JSONPlaceholderAPIManager {
- public static Post getPost(String spec) throws IOException {
- return getObject(spec, Post.class);
+ private final static String postsSpec = "/posts";
+ private final static String usersSpec = "/users";
+
+
+ public static Post getPost(int id) throws IOException {
+ return getObject(postsSpec + "/" + id, Post.class);
}
- public static List<Post> getPosts(String spec) throws IOException {
- return getObjects(spec, Post.class);
+ public static List<Post> getPosts() throws IOException {
+ return getObjects(postsSpec, Post.class);
}
- public static Post postPost(String spec, Post post) throws IOException {
- return postObject(spec, post, Post.class);
+ public static Post postPost(Post post) throws IOException {
+ return postObject(postsSpec, post, Post.class);
}
- public static User getUser(String spec) throws IOException {
- return getObject(spec, User.class);
+ public static User getUser(int id) throws IOException {
+ return getObject(usersSpec + "/" + id, User.class);
}
- public static List<User> getUsers(String spec) throws IOException {
- return getObjects(spec, User.class);
+ public static List<User> getUsers() throws IOException {
+ return getObjects(usersSpec, User.class);
}
- public static User postUser(String spec, User user) throws IOException {
- return postObject(spec, user, User.class);
+ public static User postUser(User user) throws IOException {
+ return postObject(usersSpec, user, User.class);
}
private static <T> T getObject(String spec, Class<T> classOfObject) throws IOException {
diff --git a/src/main/resources/testData.json b/src/main/resources/testData.json
index b495e75..24ac764 100644
--- a/src/main/resources/testData.json
+++ b/src/main/resources/testData.json
@@ -63,7 +63,10 @@
{
"spec": "/users/5",
"requestMethod": "GET",
- "responseCode": "200"
+ "responseCode": "200",
+ "user": {
+ "id": "5"
+ }
}
]
}