Skip to content

Commit f2f26c5

Browse files
committed
refactor asserts
1 parent dd6abf5 commit f2f26c5

File tree

4 files changed

+29
-41
lines changed

4 files changed

+29
-41
lines changed

jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public class AngularPage extends WebPage {
2323
public static InputSection inputSection;
2424
public static SelectSection selectSection;
2525
public static ListSection listSection;
26-
public static AutocompleteSection autocompleteSection;
2726
public static SnackbarSection snackbarSection;
2827
public static MenuSection menuSection;
2928
public static PaginatorSection paginatorSection;

jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/complex/GridListTests.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@ public void basicGridListTest() {
2828
basicGridList.show();
2929
basicGridList.shouldBe().visible();
3030

31-
basicGridList.has().numberOfColumnsInGridList("2")
31+
basicGridList.has().numberOfColumns(2)
3232
.and().rowHeight("2:1")
3333
.and().gutterSize("10px")
3434

3535
.and().cellText(1, "1")
3636
.and().cellBackgroundColor(1, LIGHT_BLUE_2.value())
37-
.and().numberOfColumnsInCell(1, "1")
38-
.and().numberOfRowsInCell(1, "1");
37+
.and().numberOfColumnsInCell(1, 1)
38+
.and().numberOfRowsInCell(1, 1);
3939
}
4040

4141
@Test(description = "Test checks dynamic grid list attributes")
@@ -44,7 +44,7 @@ public void dynamicGridListTest() {
4444
dynamicGridList.show();
4545
dynamicGridList.shouldBe().visible();
4646

47-
dynamicGridList.has().numberOfColumnsInGridList("4")
47+
dynamicGridList.has().numberOfColumns(4)
4848
.and().rowHeight("100px")
4949
.and().gutterSize("10px")
5050

@@ -54,11 +54,11 @@ public void dynamicGridListTest() {
5454
.and().cellBackgroundColor(2, LIGHT_GREEN_2.value())
5555
.and().cellBackgroundColor(4, LIGHT_LILAC.value())
5656

57-
.and().numberOfColumnsInCell(1, "3")
58-
.and().numberOfColumnsInCell(2, "1")
59-
.and().numberOfColumnsInCell(4, "2")
57+
.and().numberOfColumnsInCell(1, 3)
58+
.and().numberOfColumnsInCell(2, 1)
59+
.and().numberOfColumnsInCell(4, 2)
6060

61-
.and().numberOfRowsInCell(1, "1")
62-
.and().numberOfRowsInCell(2, "2");
61+
.and().numberOfRowsInCell(1, 1)
62+
.and().numberOfRowsInCell(2, 2);
6363
}
6464
}

jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/GridListAssert.java

+14-25
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44

55
import com.epam.jdi.light.angular.elements.complex.GridList;
66
import com.epam.jdi.light.asserts.generic.UIAssert;
7+
import com.epam.jdi.light.angular.elements.enums.AngularColors;
78
import com.epam.jdi.light.common.JDIAction;
89
import org.hamcrest.Matchers;
910

1011
public class GridListAssert extends UIAssert<GridListAssert, GridList> {
1112

1213
@JDIAction("Assert that '{name}' has number of columns '{0}'")
13-
public GridListAssert numberOfColumnsInGridList(String expectedNumberOfColumns) {
14-
String actualNumberOfColumns = element().numberOfColumnsInGridList();
14+
public GridListAssert numberOfColumns(int expectedNumberOfColumns) {
15+
int actualNumberOfColumns = element().numberOfColumns();
1516
jdiAssert(actualNumberOfColumns, Matchers.is(expectedNumberOfColumns),
1617
String.format("\nActual number of columns in Grid List: '%s'\n" +
1718
"is not equal to expected: '%s'", actualNumberOfColumns, expectedNumberOfColumns));
@@ -21,54 +22,42 @@ public GridListAssert numberOfColumnsInGridList(String expectedNumberOfColumns)
2122
@JDIAction("Assert that '{name}' has row's height '{0}'")
2223
public GridListAssert rowHeight(String expectedRowHeight) {
2324
String actualRowHeight = element().rowHeight();
24-
jdiAssert(actualRowHeight, Matchers.is(expectedRowHeight),
25-
String.format("\nActual row height: '%s'\n" +
26-
"is not equal to expected: '%s'", actualRowHeight, expectedRowHeight));
25+
jdiAssert(actualRowHeight, Matchers.is(expectedRowHeight));
2726
return this;
2827
}
2928

3029
@JDIAction("Assert that '{name}' has gutter size '{0}'")
3130
public GridListAssert gutterSize(String expectedGutterSize) {
3231
String actualGutterSize = element().gutterSize();
33-
jdiAssert(actualGutterSize, Matchers.is(expectedGutterSize),
34-
String.format("\nActual gutter size: '%s'\n" +
35-
"is not equal to expected: '%s'", actualGutterSize, expectedGutterSize));
32+
jdiAssert(actualGutterSize, Matchers.is(expectedGutterSize));
3633
return this;
3734
}
3835

3936
@JDIAction("Assert that '{name}' cell has text '{1}'")
40-
public GridListAssert cellText(int cellIndex, String ExpectedText) {
37+
public GridListAssert cellText(int cellIndex, String expectedText) {
4138
String actualText = element().cellByIndex(cellIndex).text();
42-
jdiAssert(actualText, Matchers.is(ExpectedText),
43-
String.format("\nActual cell's text: '%s'\n" +
44-
"is not equal to expected: '%s'", actualText, ExpectedText));
39+
jdiAssert(actualText, Matchers.is(expectedText));
4540
return this;
4641
}
4742

4843
@JDIAction("Assert that '{name}' cell has background color '{1}'")
4944
public GridListAssert cellBackgroundColor(int cellIndex, String expectedColor) {
5045
String actualColor = element().cellBackgroundColorByIndex(cellIndex);
51-
jdiAssert(actualColor, Matchers.is(expectedColor),
52-
String.format("\nActual cell's background color: '%s'\n" +
53-
"is not equal to expected: '%s'", actualColor, expectedColor));
46+
jdiAssert(actualColor, Matchers.is(expectedColor));
5447
return this;
5548
}
5649

5750
@JDIAction("Assert that '{name}' cell has number of columns '{1}'")
58-
public GridListAssert numberOfColumnsInCell(int cellIndex, String expectedNumberOfColumns) {
59-
String actualNumberOfColumns = element().numberOfColumnsInCellByIndex(cellIndex);
60-
jdiAssert(actualNumberOfColumns, Matchers.is(expectedNumberOfColumns),
61-
String.format("\nActual number of columns in cell: '%s'\n" +
62-
"is not equal to expected: '%s'", actualNumberOfColumns, expectedNumberOfColumns));
51+
public GridListAssert numberOfColumnsInCell(int cellIndex, int expectedNumberOfColumns) {
52+
int actualNumberOfColumns = element().numberOfColumnsInCellByIndex(cellIndex);
53+
jdiAssert(actualNumberOfColumns, Matchers.is(expectedNumberOfColumns));
6354
return this;
6455
}
6556

6657
@JDIAction("Assert that '{name}' cell has number of rows '{1}'")
67-
public GridListAssert numberOfRowsInCell(int cellIndex, String expectedNumberOfRows) {
68-
String actualNumberOfRows = element().numberOfRowsInCellByIndex(cellIndex);
69-
jdiAssert(actualNumberOfRows, Matchers.is(expectedNumberOfRows),
70-
String.format("\nActual number of rows in cell: '%s'\n" +
71-
"is not equal to expected: '%s'", actualNumberOfRows, expectedNumberOfRows));
58+
public GridListAssert numberOfRowsInCell(int cellIndex, int expectedNumberOfRows) {
59+
int actualNumberOfRows = element().numberOfRowsInCellByIndex(cellIndex);
60+
jdiAssert(actualNumberOfRows, Matchers.is(expectedNumberOfRows));
7261
return this;
7362
}
7463
}

jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/complex/GridList.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
public class GridList extends UIBaseElement<GridListAssert> {
1313

1414
@JDIAction(value = "Get '{name}' number of columns")
15-
public String numberOfColumnsInGridList() {
16-
return core().getAttribute("cols");
15+
public int numberOfColumns() {
16+
return Integer.parseInt(core().getAttribute("cols"));
1717
}
1818

1919
@JDIAction(value = "Get '{name}' row's height")
@@ -32,13 +32,13 @@ public UIElement cellByIndex(int index) {
3232
}
3333

3434
@JDIAction(value = "Get '{name}' cell's number of columns by index '{0}'")
35-
public String numberOfColumnsInCellByIndex(int index) {
36-
return cellByIndex(index).getAttribute("colspan");
35+
public int numberOfColumnsInCellByIndex(int index) {
36+
return Integer.parseInt(cellByIndex(index).getAttribute("colspan"));
3737
}
3838

3939
@JDIAction(value = "Get '{name}' cell's number of rows by index '{0}'")
40-
public String numberOfRowsInCellByIndex(int index) {
41-
return cellByIndex(index).getAttribute("rowspan");
40+
public int numberOfRowsInCellByIndex(int index) {
41+
return Integer.parseInt(cellByIndex(index).getAttribute("rowspan"));
4242
}
4343

4444
@JDIAction(value = "Get '{name}' cell's background color by index '{0}'")

0 commit comments

Comments
 (0)