Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package framework.common;
import com.microsoft.playwright.Locator;
import com.microsoft.playwright.assertions.PlaywrightAssertions;
import java.time.LocalDate;
import java.util.Collection;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class Assertions {
/**
* This method asserts that two collections are equal.
*
* @param expected expected collection.
* @param actual actual collection.
* @param <T> collection type.
*/
public static <T> void assertEqualCollections(Collection<T> expected, Collection<T> actual) {
assertEquals("The collections are different in size: ", expected.size(), actual.size());
expected.forEach(element -> assertTrue("Expected element " + element + " not found in actual collection",
actual.contains(element)));
}
/**
* This method verifies that a given date is in a wished range.
*
* @param startDate start date of the range.
* @param endDate end date of the range.
* @param date date that is wanted for verification.
*/
public static void assertDateIsInRange(LocalDate startDate, LocalDate endDate, LocalDate date) {
assertTrue("The chosen date is before the start of the range", date.isAfter(startDate) || date.equals(startDate));
assertTrue("The chosen date is after the end of the range", date.isBefore(endDate) || date.equals(endDate));
}
/**
* This method verifies that an element is visible.
*
* @param locator Locator object wanted for visibility verification.
*/
public static void assertElementIsVisibleByLocator(Locator locator) {
PlaywrightAssertions.assertThat(locator).isVisible();
}
}