|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.fest.assertions.Assert
org.fest.assertions.GenericAssert<BufferedImage>
org.fest.assertions.ImageAssert
public class ImageAssert
Understands assertion methods for images. To create a new instance of this class use the method
.
Assertions.assertThat(BufferedImage)
Field Summary |
---|
Fields inherited from class org.fest.assertions.GenericAssert |
---|
actual |
Constructor Summary | |
---|---|
protected |
ImageAssert(BufferedImage actual)
Creates a new ImageAssert . |
Method Summary | |
---|---|
ImageAssert |
as(Description description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
ImageAssert |
as(String description)
Sets the description of the actual value, to be used in as message of any
thrown when an assertion fails. |
ImageAssert |
describedAs(Description description)
Alias for , since "as" is a keyword in
Groovy. |
ImageAssert |
describedAs(String description)
Alias for , since "as" is a keyword in
Groovy. |
ImageAssert |
doesNotSatisfy(Condition<BufferedImage> condition)
Verifies that the actual image does not satisfy the given condition. |
ImageAssert |
hasSize(Dimension expected)
Verifies that the size of the actual image is equal to the given one. |
ImageAssert |
is(Condition<BufferedImage> condition)
Alias for . |
ImageAssert |
isEqualTo(BufferedImage expected)
Verifies that the actual image is equal to the given one. |
ImageAssert |
isEqualTo(BufferedImage expected,
Threshold threshold)
Verifies that the actual image is equal to the given one. |
ImageAssert |
isNot(Condition<BufferedImage> condition)
Alias for . |
ImageAssert |
isNotEqualTo(BufferedImage image)
Verifies that the actual image is not equal to the given one. |
ImageAssert |
isNotNull()
Verifies that the actual image is not null . |
ImageAssert |
isNotSameAs(BufferedImage expected)
Verifies that the actual image is not the same as the given one. |
ImageAssert |
isSameAs(BufferedImage expected)
Verifies that the actual image is the same as the given one. |
ImageAssert |
overridingErrorMessage(String message)
Replaces the default message displayed in case of a failure with the given one. |
static BufferedImage |
read(String imageFilePath)
Reads the image in the specified path. |
ImageAssert |
satisfies(Condition<BufferedImage> condition)
Verifies that the actual image satisfies the given condition. |
Methods inherited from class org.fest.assertions.GenericAssert |
---|
assertDoesNotSatisfy, assertEqualTo, assertIs, assertIsNot, assertNotEqualTo, assertNotNull, assertNotSameAs, assertSameAs, assertSatisfies, isNull |
Methods inherited from class org.fest.assertions.Assert |
---|
customErrorMessage, description, description, description, equals, fail, fail, failIfCustomMessageIsSet, failIfCustomMessageIsSet, failure, formattedErrorMessage, hashCode, rawDescription, replaceDefaultErrorMessagesWith |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected ImageAssert(BufferedImage actual)
ImageAssert
.
actual
- the target to verify.Method Detail |
---|
public static BufferedImage read(String imageFilePath) throws IOException
imageFilePath
- the path of the image to read.
NullPointerException
- if the given path is null
.
IllegalArgumentException
- if the given path does not belong to a file.
IOException
- if any I/O error occurred while reading the image.public ImageAssert as(String description)
AssertionError
thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion
failure will not show the provided description.
For example:
assertThat(val).as("name").isEqualTo("Frodo");
as
in class GenericAssert<BufferedImage>
description
- the description of the actual value.
public ImageAssert describedAs(String description)
GenericAssert.as(String)
, since "as" is a keyword in
Groovy. This method should be called before any assertion
method, otherwise any assertion failure will not show the provided description.
For example:
assertThat(val).describedAs("name").isEqualTo("Frodo");
describedAs
in class GenericAssert<BufferedImage>
description
- the description of the actual value.
public ImageAssert as(Description description)
AssertionError
thrown when an assertion fails. This method should be called before any assertion method, otherwise any assertion
failure will not show the provided description.
For example:
assertThat(val).as(new BasicDescription("name")).isEqualTo("Frodo");
as
in class GenericAssert<BufferedImage>
description
- the description of the actual value.
public ImageAssert describedAs(Description description)
GenericAssert.as(Description)
, since "as" is a keyword in
Groovy. This method should be called before any assertion
method, otherwise any assertion failure will not show the provided description.
For example:
assertThat(val).describedAs(new BasicDescription("name")).isEqualTo("Frodo");
describedAs
in class GenericAssert<BufferedImage>
description
- the description of the actual value.
public ImageAssert satisfies(Condition<BufferedImage> condition)
satisfies
in class GenericAssert<BufferedImage>
condition
- the given condition.
NullPointerException
- if the given condition is null
.
AssertionError
- if the actual image does not satisfy the given condition.is(Condition)
public ImageAssert doesNotSatisfy(Condition<BufferedImage> condition)
doesNotSatisfy
in class GenericAssert<BufferedImage>
condition
- the given condition.
NullPointerException
- if the given condition is null
.
AssertionError
- if the actual image satisfies the given condition.isNot(Condition)
public ImageAssert is(Condition<BufferedImage> condition)
satisfies(Condition)
.
is
in class GenericAssert<BufferedImage>
condition
- the given condition.
NullPointerException
- if the given condition is null
.
AssertionError
- if the actual image does not satisfy the given condition.public ImageAssert isNot(Condition<BufferedImage> condition)
doesNotSatisfy(Condition)
.
isNot
in class GenericAssert<BufferedImage>
condition
- the given condition.
NullPointerException
- if the given condition is null
.
AssertionError
- if the actual image satisfies the given condition.public ImageAssert isEqualTo(BufferedImage expected)
isEqualTo
in class GenericAssert<BufferedImage>
expected
- the given image to compare the actual image to.
AssertionError
- if the actual image is not equal to the given one.public ImageAssert isEqualTo(BufferedImage expected, Threshold threshold)
expected
- the given image to compare the actual image to.threshold
- the threshold to use to decide if the color of two pixels are similar: two pixels that are
identical to the human eye may still have slightly different color values. For example, by using a threshold of 1
we can indicate that a blue value of 60 is similar to a blue value of 61.
AssertionError
- if the actual image is not equal to the given one.public ImageAssert isNotEqualTo(BufferedImage image)
isNotEqualTo
in class GenericAssert<BufferedImage>
image
- the given image to compare the actual image to.
AssertionError
- if the actual image is equal to the given one.public ImageAssert isNotNull()
null
.
isNotNull
in class GenericAssert<BufferedImage>
AssertionError
- if the actual image is null
.public ImageAssert isNotSameAs(BufferedImage expected)
isNotSameAs
in class GenericAssert<BufferedImage>
expected
- the given image to compare the actual image to.
AssertionError
- if the actual image is the same as the given one.public ImageAssert isSameAs(BufferedImage expected)
isSameAs
in class GenericAssert<BufferedImage>
expected
- the given image to compare the actual image to.
AssertionError
- if the actual image is not the same as the given one.public ImageAssert hasSize(Dimension expected)
expected
- the expected size of the actual image.
AssertionError
- if the actual image is null
.
NullPointerException
- if the given size is null
.
AssertionError
- if the size of the actual image is not equal to the given one.public ImageAssert overridingErrorMessage(String message)
For example, the following assertion:
assertThat("Hello").isEqualTo("Bye");will fail with the default message "expected:<'[Bye]'> but was:<'[Hello]'>."
We can replace this message with our own:
assertThat("Hello").overridingErrorMessage("'Hello' should be equal to 'Bye'").isEqualTo("Bye");in this case, the assertion will fail showing the message "'Hello' should be equal to 'Bye'".
overridingErrorMessage
in class GenericAssert<BufferedImage>
message
- the given error message, which will replace the default one.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |