summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/java/com/mavlushechka/a1qa/utils/Posts.java16
-rw-r--r--src/test/java/com/mavlushechka/a1qa/TestCase1.java6
2 files changed, 17 insertions, 5 deletions
diff --git a/src/main/java/com/mavlushechka/a1qa/utils/Posts.java b/src/main/java/com/mavlushechka/a1qa/utils/Posts.java
new file mode 100644
index 0000000..d0bdfaa
--- /dev/null
+++ b/src/main/java/com/mavlushechka/a1qa/utils/Posts.java
@@ -0,0 +1,16 @@
+package com.mavlushechka.a1qa.utils;
+
+import com.mavlushechka.a1qa.models.Post;
+
+import java.util.List;
+import java.util.stream.IntStream;
+
+public class Posts {
+
+ public static boolean isPostsAscending(List<Post> posts) {
+ return IntStream.range(1, posts.size())
+ .map(index -> posts.get(index - 1).compareTo(posts.get(index)))
+ .allMatch(order -> order <= 0);
+ }
+
+}
diff --git a/src/test/java/com/mavlushechka/a1qa/TestCase1.java b/src/test/java/com/mavlushechka/a1qa/TestCase1.java
index ea78efc..44be656 100644
--- a/src/test/java/com/mavlushechka/a1qa/TestCase1.java
+++ b/src/test/java/com/mavlushechka/a1qa/TestCase1.java
@@ -8,7 +8,6 @@ import org.testng.annotations.Test;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.stream.IntStream;
public class TestCase1 extends BaseTest {
@@ -26,10 +25,7 @@ public class TestCase1 extends BaseTest {
for (Object post : posts) {
postsArrayList.add((Post) post);
}
- boolean isPostsAscending = IntStream.range(1, postsArrayList.size())
- .map(index -> postsArrayList.get(index - 1).compareTo(postsArrayList.get(index)))
- .allMatch(order -> order <= 0);
- Assert.assertTrue(isPostsAscending, "Posts are not sorted ascending.");
+ Assert.assertTrue(Posts.isPostsAscending(postsArrayList), "Posts are not sorted ascending.");
String post99Spec = JSONParser.parseData("testData", "testCases[0].steps[1].spec");
String post99RequestMethod = JSONParser.parseData("testData", "testCases[0].steps[1].requestMethod");