Package org.eclipse.microprofile.openapi.tck.utils

# Class TCKMatchers

java.lang.Object
org.eclipse.microprofile.openapi.tck.utils.TCKMatchers

public final class TCKMatchers extends Object

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`TCKMatchers.ItemOrSingletonMatcher`
`static class`
`TCKMatchers.NumericEqualityMatcher`

## Method Summary

Modifier and Type
Method
Description
`static org.hamcrest.Matcher<Number>`
`comparesEqualToNumber(Number expected)`
Creates a matcher of `Comparable<Number>` that matches when the examined number is equal to the specified value, as reported by the `compareTo` method of the `BigDecimal`s created by passing both Number values' `doubleValue` to `BigDecimal.valueOf(double)`.
`static <T> org.hamcrest.Matcher<T>`
`hasOptionalEntry(String entryName, Object value)`
Creates a matcher which matches a map entry with an allowed value or the absence of a map entry from the object.
`static org.hamcrest.Matcher<Object>`
`itemOrSingleton(Object item)`
Creates a matcher which matches an item or a `Collection` containing just that item
`static org.hamcrest.Matcher<Object>`
`itemOrSingleton(org.hamcrest.Matcher<?> itemMatcher)`
Creates a matcher which matches an item or a `Collection` containing just that item
`static org.hamcrest.Matcher<Number>`
`number(Number number)`
Creates a matcher which matches numbers based on their numeric value without considering their type.
`static org.hamcrest.Matcher<String>`
`patternMatchesValue(String value)`
Creates a matcher which matches when the given value matches a string compiled to a regular expression pattern.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### comparesEqualToNumber

public static org.hamcrest.Matcher<Number> comparesEqualToNumber(Number expected)
Creates a matcher of `Comparable<Number>` that matches when the examined number is equal to the specified value, as reported by the `compareTo` method of the `BigDecimal`s created by passing both Number values' `doubleValue` to `BigDecimal.valueOf(double)`.

For example:

     assertThat(1, comparesEqualToNumber(1))

Parameters:
  `expected` - the value which, when passed to the compareTo method of the examined object following conversion to BigDecimal, should return zero
Returns:
  a matcher to test the equality of the examined Number

### itemOrSingleton

public static org.hamcrest.Matcher<Object> itemOrSingleton(org.hamcrest.Matcher<?> itemMatcher)
Creates a matcher which matches an item or a `Collection` containing just that item

Parameters:
  `itemMatcher` - the matcher for the item
Returns:
  the matcher

### itemOrSingleton

public static org.hamcrest.Matcher<Object> itemOrSingleton(Object item)
Creates a matcher which matches an item or a `Collection` containing just that item

Parameters:
  `item` - the item
Returns:
  the matcher

### number

public static org.hamcrest.Matcher<Number> number(Number number)
Creates a matcher which matches numbers based on their numeric value without considering their type.

Both the expected and actual value are converted to `BigDecimal` and compared using `compareTo`.

Parameters:
  `number` - the expected number
Returns:
  the matcher

### hasOptionalEntry

public static <T> org.hamcrest.Matcher<T> hasOptionalEntry(String entryName, Object value)
Creates a matcher which matches a map entry with an allowed value or the absence of a map entry from the object.

Parameters:
  `entryName` - name of the entry in the map
  `value` - a single allowed value in the map entry, if present
Returns:
  the matcher

### patternMatchesValue

public static org.hamcrest.Matcher<String> patternMatchesValue(String value)
Creates a matcher which matches when the given value matches a string compiled to a regular expression pattern.

Parameters:
  `value` - a value to match against the regular expression
Returns:
  the matcher