|
1 | 1 | package com.epam.jdi.light.angular.asserts; |
2 | 2 |
|
3 | | -import com.epam.jdi.light.angular.elements.complex.Select; |
| 3 | +import com.epam.jdi.light.angular.elements.complex.MaterialSelector; |
4 | 4 | import com.epam.jdi.light.asserts.generic.UIAssert; |
| 5 | +import com.epam.jdi.light.common.JDIAction; |
| 6 | +import org.hamcrest.Matcher; |
| 7 | +import org.hamcrest.Matchers; |
5 | 8 |
|
6 | | -public class SelectAssert extends UIAssert<SelectAssert, Select> { |
| 9 | +import java.util.List; |
| 10 | +import java.util.Map; |
7 | 11 |
|
| 12 | +import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; |
| 13 | +import static com.jdiai.tools.EnumUtils.getEnumValue; |
| 14 | +import static com.jdiai.tools.LinqUtils.toStringArray; |
| 15 | +import static org.hamcrest.Matchers.hasItem; |
| 16 | +import static org.hamcrest.Matchers.hasItems; |
8 | 17 |
|
| 18 | +public class SelectAssert extends UIAssert<SelectAssert, MaterialSelector> { |
| 19 | + @JDIAction("Assert that '{name}' expanded") |
| 20 | + public SelectAssert expanded() { |
| 21 | + jdiAssert(element().isExpanded(), Matchers.is(true)); |
| 22 | + return this; |
| 23 | + } |
| 24 | + |
| 25 | + @JDIAction("Assert that '{name}' collapsed") |
| 26 | + public SelectAssert collapsed() { |
| 27 | + jdiAssert(element().isCollapsed(), Matchers.is(true)); |
| 28 | + return this; |
| 29 | + } |
| 30 | + |
| 31 | + @JDIAction("Assert that '{0}' option selected for '{name}'") |
| 32 | + public SelectAssert selected(final Matcher<String> condition) { |
| 33 | + jdiAssert(element().selected(), condition); |
| 34 | + return this; |
| 35 | + } |
| 36 | + |
| 37 | + @JDIAction("Assert that '{0}' option selected for '{name}'") |
| 38 | + public SelectAssert selected(final String option) { |
| 39 | + return selected(Matchers.is(option)); |
| 40 | + } |
| 41 | + |
| 42 | + public <T extends Enum<?>> SelectAssert selected(final T option) { |
| 43 | + return selected(getEnumValue(option)); |
| 44 | + } |
| 45 | + |
| 46 | + public <T extends Enum<?>> SelectAssert value(final T option) { |
| 47 | + jdiAssert(element().values(), hasItem(getEnumValue(option))); |
| 48 | + return this; |
| 49 | + } |
| 50 | + |
| 51 | + @JDIAction("Assert that '{name}' value '{0}'") |
| 52 | + public SelectAssert value(final Matcher<String> condition) { |
| 53 | + return values(hasItem(condition)); |
| 54 | + } |
| 55 | + |
| 56 | + @JDIAction("Assert that '{name}' has value '{0}'") |
| 57 | + public SelectAssert value(final String value) { |
| 58 | + return values(hasItem(value)); |
| 59 | + } |
| 60 | + |
| 61 | + @JDIAction("Assert that '{name}' values '{0}'") |
| 62 | + public SelectAssert values(final Matcher<? super List<String>> condition) { |
| 63 | + jdiAssert(element().values(), condition); |
| 64 | + return this; |
| 65 | + } |
| 66 | + |
| 67 | + public SelectAssert values(final String... values) { |
| 68 | + return values(hasItems(values)); |
| 69 | + } |
| 70 | + |
| 71 | + public SelectAssert values(final List<String> values) { |
| 72 | + return values(toStringArray(values)); |
| 73 | + } |
| 74 | + |
| 75 | + @JDIAction("Assert that '{name}' has groups '{0}'") |
| 76 | + public SelectAssert groups(final Matcher<? super List<String>> condition) { |
| 77 | + jdiAssert(element().groups(), condition); |
| 78 | + return this; |
| 79 | + } |
| 80 | + |
| 81 | + public SelectAssert groups(final List<String> groups) { |
| 82 | + return groups(toStringArray(groups)); |
| 83 | + } |
| 84 | + |
| 85 | + public SelectAssert groups(final String... values) { |
| 86 | + return groups(hasItems(values)); |
| 87 | + } |
| 88 | + |
| 89 | + @JDIAction("Assert that '{name}' has groups and options '{0}'") |
| 90 | + public SelectAssert groupsAndOptions(final Map<String, List<String>> expectedGroupsAndOptions) { |
| 91 | + jdiAssert(element().groupsAndOptions(), Matchers.is(expectedGroupsAndOptions)); |
| 92 | + return this; |
| 93 | + } |
| 94 | + |
| 95 | + @JDIAction("Assert that '{name}' has enabled values '{0}'") |
| 96 | + public SelectAssert listEnabled(final Matcher<? super List<String>> condition) { |
| 97 | + jdiAssert(element().listEnabled(), condition); |
| 98 | + return this; |
| 99 | + } |
| 100 | + |
| 101 | + public SelectAssert listEnabled(final List<String> listEnabled) { |
| 102 | + return listEnabled(toStringArray(listEnabled)); |
| 103 | + } |
| 104 | + |
| 105 | + public SelectAssert listEnabled(final String... values) { |
| 106 | + return listEnabled(hasItems(values)); |
| 107 | + } |
| 108 | + |
| 109 | + @JDIAction("Assert that '{name}' has disabled values '{0}'") |
| 110 | + public SelectAssert listDisabled(final Matcher<? super List<String>> condition) { |
| 111 | + jdiAssert(element().listDisabled(), condition); |
| 112 | + return this; |
| 113 | + } |
| 114 | + |
| 115 | + public SelectAssert listDisabled(final List<String> listDisabled) { |
| 116 | + return listDisabled(toStringArray(listDisabled)); |
| 117 | + } |
| 118 | + |
| 119 | + public SelectAssert listDisabled(final String... values) { |
| 120 | + return listDisabled(hasItems(values)); |
| 121 | + } |
| 122 | + |
| 123 | + @JDIAction("Assert that rgba({0}, {1}, {2}, {3}) is the specified color") |
| 124 | + public SelectAssert color(final int red, final int green, final int blue, final double a) { |
| 125 | + jdiAssert(element().color(red, green, blue, a), Matchers.is(true)); |
| 126 | + return this; |
| 127 | + } |
9 | 128 | } |
0 commit comments