Java Code Examples for org.hamcrest.Matchers#describedAs()

The following examples show how to use org.hamcrest.Matchers#describedAs() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
private static Matcher<? super Table> tableNameMatcher(String tableName) {
  Matcher<Table> subMatchers = Matchers.allOf(ImmutableList.of(
    propertyMatcher(Table::getName, "name", tableNameEqualTo(tableName))
  ));

  return Matchers.describedAs("%0", subMatchers, tableName);
}
 
Example 2
private static Matcher<? super View> viewNameMatcher(String viewName) {
  Matcher<View> subMatchers = Matchers.allOf(ImmutableList.of(
    propertyMatcher(View::getName, "name", viewNameEqualTo(viewName))
  ));

  return Matchers.describedAs("%0", subMatchers, viewName);
}
 
Example 3
private static Matcher<? super Column> columnMatcher(Column column) {
  Matcher<Column> subMatchers = Matchers.allOf(ImmutableList.of(
    propertyMatcher(Column::getName, "name", columnNameEqualTo(column.getName())),
    propertyMatcher(Column::getType, "type", equalTo(column.getType())),
    propertyMatcher(Column::getWidth, "width", equalTo(column.getWidth())),
    propertyMatcher(Column::getScale, "scale", equalTo(column.getScale())),
    propertyMatcher(Column::isNullable, "null", equalTo(column.isNullable())),
    propertyMatcher(Column::isPrimaryKey, "PK", equalTo(column.isPrimaryKey())),
    propertyMatcher(Column::getDefaultValue, "default", equalTo(column.getDefaultValue())),
    propertyMatcher(Column::isAutoNumbered, "autonum", equalTo(column.isAutoNumbered())),
    propertyMatcher(Column::getAutoNumberStart, "from", equalTo(column.getAutoNumberStart()))
  ));

  return Matchers.describedAs("%0", subMatchers, column.toString());
}
 
Example 4
private static Matcher<? super Index> indexMatcher(Index index) {
  Matcher<Index> subMatchers = Matchers.allOf(ImmutableList.of(
    propertyMatcher(Index::getName, "name", indexNameEqualTo(index.getName())),
    propertyMatcher(Index::columnNames, "columns", contains(indexColumnNamesEqualTo(index.columnNames()))),
    propertyMatcher(Index::isUnique, "unique", equalTo(index.isUnique()))
  ));

  return Matchers.describedAs("%0", subMatchers, index.toString());
}
 
Example 5
public static Matcher<Iterable<? extends TimeSeriesCollection>> createOrderingExceptation(Collection<? extends TimeSeriesCollection> c) {
    return Matchers.describedAs("is ordered by timestamp",
            Matchers.contains(c.stream()
                    .map(TimeSeriesCollection::getTimestamp)
                    .sorted()
                    .map(ts -> Matchers.hasProperty("timestamp", Matchers.equalTo(ts)))
                    .collect(Collectors.toList())));
}