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

The following examples show how to use org.hamcrest.Matchers#describedAs() . 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
Source File: TestDatabaseMetaDataProvider.java    From morf with Apache License 2.0 5 votes vote down vote up
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
Source File: TestDatabaseMetaDataProvider.java    From morf with Apache License 2.0 5 votes vote down vote up
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
Source File: TestDatabaseMetaDataProvider.java    From morf with Apache License 2.0 5 votes vote down vote up
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
Source File: TestDatabaseMetaDataProvider.java    From morf with Apache License 2.0 5 votes vote down vote up
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
Source File: JsonUtil.java    From monsoon with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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())));
}