com.epam.jdi.light.asserts.TableAssert Maven / Gradle / Ivy
package com.epam.jdi.light.asserts;
import com.epam.jdi.light.elements.complex.table.Column;
import com.epam.jdi.light.elements.complex.table.Table;
import com.epam.jdi.tools.pairs.Pair;
import org.hamcrest.Matcher;
import java.util.List;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
public class TableAssert {
Table table;
public TableAssert(Table table) {
this.table = table;
}
public void isEmpty() {
assertThat(table.isEmpty() ? "is empty" : "is not empty", is("is empty"));
}
public void isNotEmpty() {
assertThat(table.isEmpty() ? "is empty" : "is not empty", is("is not empty"));
}
public void size(int size) {
assertThat(table.size(), is(size));
}
public void hasColumn(String column) {
assertThat(table.header(), hasItem(column));
}
public void hasColumns(List columns) {
for(String column : columns)
hasColumn(column);
}
public void columnsCount(int count) {
assertThat(table.header(), hasSize(count));
}
public void hasRowsWhereValue(Matcher matcher, Column column) {
assertThat(table.row(matcher, column), notNullValue());
}
public void hasRowsWhereValue(Pair, Column>... matchers) {
for (Pair, Column> matcher : matchers)
hasRowsWhereValue(matcher.key, matcher.value);
}
}