Package net.officefloor.frame.test
Class Assertions
- java.lang.Object
-
- org.junit.jupiter.api.Assertions
-
- net.officefloor.frame.test.Assertions
-
public class Assertions extends org.junit.jupiter.api.Assertions
Assertions
extended with additional features.- Author:
- Daniel Sagenschneider
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interface
Assertions.FailOperation
Operation forassertFail(net.officefloor.frame.test.Assertions.FailOperation, java.lang.Class<F>)
that should fail.
-
Constructor Summary
Constructors Constructor Description Assertions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
assertContents(java.io.File expected, java.io.File actual)
Asserts the contents of the inputFile
instances are the same.static void
assertContents(java.io.Reader expected, java.io.Reader actual)
Asserts the contents of the inputReader
instances are the same.static <F extends java.lang.Throwable>
FassertFail(java.lang.Class<F> expectedFailureType, java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... parameters)
Provides simplified facade to verifyMethod
will fail.static <F extends java.lang.Throwable>
FassertFail(java.lang.Class<F> expectedFailureType, java.lang.Object object, java.lang.String methodName, java.lang.Object... parameters)
Provides simplified facade to verifyMethod
will fail.static <F extends java.lang.Throwable>
FassertFail(Assertions.FailOperation operation, java.lang.Class<F> expectedFailureType)
Asserts the failure.static <O> void
assertGraph(O expectedRoot, O actualRoot, java.lang.String... ignoreMethodNames)
Assets that the input graph is as expected.static <O> void
assertList(java.lang.String[] methods, java.util.List<O> list, O... expectedItems)
Asserts that properties on items within list match.static <O> void
assertList(java.lang.String[] methods, O[] array, O... expectedItems)
Asserts that properties on items within the array match.static <O> void
assertList(java.lang.String sortMethod, java.lang.String[] methods, java.util.List<O> list, O... expectedItems)
Asserts that properties on items within list match after the list is sorted.static <O> void
assertList(java.util.List<O> list, O... expectedItems)
Asserts that the input list equals the expected.static <O> void
assertList(ListItemMatcher<O> matcher, java.util.List<O> list, O... expectedItems)
Asserts that the input list is as expected.static <O> void
assertProperties(O expected, O actual, java.lang.String... methods)
Asserts that properties on the input objects match for the specified methods.static void
assertTextEquals(java.lang.String expected, java.lang.String actual, java.lang.String message)
Asserts the input texts match taking into account platform differences.static void
assertXmlEquals(java.lang.String expected, java.lang.String actual, java.lang.String message)
Asserts the input XML's match with white spacing removed.static java.lang.String
createPlatformIndependentText(java.lang.String rawText)
Creates the platform independent text for comparing.static <T> T
getItem(java.util.Collection<T> items, java.lang.String methodName, java.lang.Object value)
Obtains the item within the items whose property by methodName matches the input value.static java.lang.Object
getProperty(java.lang.Object object, java.lang.String methodName)
Obtains the property on the Object.static java.lang.String
removeXmlWhiteSpacing(java.lang.String xml)
Removes the white spacing from the XML.-
Methods inherited from class org.junit.jupiter.api.Assertions
assertAll, assertAll, assertAll, assertAll, assertAll, assertAll, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertArrayEquals, assertDoesNotThrow, assertDoesNotThrow, assertDoesNotThrow, assertDoesNotThrow, assertDoesNotThrow, assertDoesNotThrow, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertFalse, assertFalse, assertFalse, assertFalse, assertIterableEquals, assertIterableEquals, assertIterableEquals, assertLinesMatch, assertLinesMatch, assertLinesMatch, assertLinesMatch, assertLinesMatch, assertLinesMatch, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotEquals, assertNotNull, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNotSame, assertNull, assertNull, assertNull, assertSame, assertSame, assertSame, assertThrows, assertThrows, assertThrows, assertTimeout, assertTimeout, assertTimeout, assertTimeout, assertTimeout, assertTimeout, assertTimeoutPreemptively, assertTimeoutPreemptively, assertTimeoutPreemptively, assertTimeoutPreemptively, assertTimeoutPreemptively, assertTimeoutPreemptively, assertTrue, assertTrue, assertTrue, assertTrue, assertTrue, assertTrue, fail, fail, fail, fail, fail
-
-
-
-
Method Detail
-
assertFail
public static <F extends java.lang.Throwable> F assertFail(Assertions.FailOperation operation, java.lang.Class<F> expectedFailureType)
Asserts the failure.- Type Parameters:
F
- Failure type.- Parameters:
operation
-Assertions.FailOperation
that is expected fail.expectedFailureType
- Expect type of failure.- Returns:
- Actual failure for further assertions.
-
assertFail
public static <F extends java.lang.Throwable> F assertFail(java.lang.Class<F> expectedFailureType, java.lang.Object object, java.lang.String methodName, java.lang.Object... parameters)
Provides simplified facade to verifyMethod
will fail.- Type Parameters:
F
- Failure type.- Parameters:
expectedFailureType
- Expected failure of method.object
- Object to invokeMethod
on.methodName
- Name of theMethod
.parameters
- Parameters for theMethod
.- Returns:
- Actual failure for further assertions.
-
assertFail
public static <F extends java.lang.Throwable> F assertFail(java.lang.Class<F> expectedFailureType, java.lang.Object object, java.lang.reflect.Method method, java.lang.Object... parameters)
Provides simplified facade to verifyMethod
will fail.- Type Parameters:
F
- Failure type.- Parameters:
expectedFailureType
- Expected failure of method.object
- Object to invokeMethod
on.method
-Method
.parameters
- Parameters for theMethod
.- Returns:
- Actual failure for further assertions.
-
assertTextEquals
public static void assertTextEquals(java.lang.String expected, java.lang.String actual, java.lang.String message)
Asserts the input texts match taking into account platform differences.- Parameters:
expected
- Raw expected text.actual
- Raw actual text.message
- Message.
-
createPlatformIndependentText
public static java.lang.String createPlatformIndependentText(java.lang.String rawText)
Creates the platform independent text for comparing.- Parameters:
rawText
- Raw text.- Returns:
- Platform independent text.
-
assertXmlEquals
public static void assertXmlEquals(java.lang.String expected, java.lang.String actual, java.lang.String message)
Asserts the input XML's match with white spacing removed.- Parameters:
expected
- Raw expected text.actual
- Raw actual text.message
- Message.
-
removeXmlWhiteSpacing
public static java.lang.String removeXmlWhiteSpacing(java.lang.String xml)
Removes the white spacing from the XML.- Parameters:
xml
- XML.- Returns:
- XML with white spacing removed.
-
assertGraph
public static <O> void assertGraph(O expectedRoot, O actualRoot, java.lang.String... ignoreMethodNames) throws java.lang.Exception
Assets that the input graph is as expected.- Type Parameters:
O
- Type.- Parameters:
expectedRoot
- Expected root.actualRoot
- Actual root.ignoreMethodNames
- Listing of methods to be ignored in checking.- Throws:
java.lang.Exception
- If fails.
-
assertContents
public static void assertContents(java.io.File expected, java.io.File actual) throws java.io.IOException
Asserts the contents of the inputFile
instances are the same.- Parameters:
expected
- Expected file.actual
- Actual file.- Throws:
java.io.IOException
- If fails to read contents.
-
assertContents
public static void assertContents(java.io.Reader expected, java.io.Reader actual)
Asserts the contents of the inputReader
instances are the same.- Parameters:
expected
- Expected content.actual
- Actual content.
-
assertList
@SafeVarargs public static <O> void assertList(ListItemMatcher<O> matcher, java.util.List<O> list, O... expectedItems)
Asserts that the input list is as expected.- Type Parameters:
O
- Type.- Parameters:
matcher
- Matches the items of the list.list
- List to be checked.expectedItems
- Items expected to be in the list.
-
assertList
@SafeVarargs public static <O> void assertList(java.util.List<O> list, O... expectedItems)
Asserts that the input list equals the expected.- Type Parameters:
O
- Type.- Parameters:
list
- List to be checked.expectedItems
- Items expected in the list.
-
assertList
@SafeVarargs public static <O> void assertList(java.lang.String[] methods, java.util.List<O> list, O... expectedItems)
Asserts that properties on items within list match.- Type Parameters:
O
- Type.- Parameters:
methods
- Method names to specify the properties on the items to match.list
- List to be checked.expectedItems
- Items expected in the list.
-
assertList
@SafeVarargs public static <O> void assertList(java.lang.String[] methods, O[] array, O... expectedItems)
Asserts that properties on items within the array match.- Type Parameters:
O
- Type.- Parameters:
methods
- Method names to specify the properties on the items to match.array
- Array to be checked.expectedItems
- Items expected in the array.
-
assertList
@SafeVarargs public static <O> void assertList(java.lang.String sortMethod, java.lang.String[] methods, java.util.List<O> list, O... expectedItems)
Asserts that properties on items within list match after the list is sorted.- Type Parameters:
O
- Type.- Parameters:
sortMethod
- Name of method on the items to sort the list by to ensure match in order.methods
- Method names to specify the properties on the items to match.list
- List to be checked.expectedItems
- Items expected in the list.
-
assertProperties
public static <O> void assertProperties(O expected, O actual, java.lang.String... methods)
Asserts that properties on the input objects match for the specified methods.- Type Parameters:
O
- Type.- Parameters:
expected
- Expected item.actual
- Actual item.methods
- Method names to specify the properties on the item to match.
-
getProperty
public static java.lang.Object getProperty(java.lang.Object object, java.lang.String methodName)
Obtains the property on the Object.- Parameters:
object
- Object.methodName
- Method name to obtain property value.- Returns:
- Value of property.
-
getItem
public static <T> T getItem(java.util.Collection<T> items, java.lang.String methodName, java.lang.Object value)
Obtains the item within the items whose property by methodName matches the input value.- Type Parameters:
T
- Item type.- Parameters:
items
- Items to search.methodName
- Property on the item.value
- Value of property the item should match.- Returns:
- Item with the matching property.
-
-