Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
daaexample
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Iago Gómez Salgado
daaexample
Commits
bc5b27b1
Commit
bc5b27b1
authored
Mar 11, 2017
by
Iago Gómez Salgado
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add IsEqualToPet matcher
parent
614f4cc6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
IsEqualToPet.java
src/test/java/es/uvigo/esei/daa/matchers/IsEqualToPet.java
+58
-0
No files found.
src/test/java/es/uvigo/esei/daa/matchers/IsEqualToPet.java
0 → 100644
View file @
bc5b27b1
package
es
.
uvigo
.
esei
.
daa
.
matchers
;
import
org.hamcrest.Factory
;
import
org.hamcrest.Matcher
;
import
es.uvigo.esei.daa.entities.Pet
;
public
class
IsEqualToPet
extends
IsEqualToEntity
<
Pet
>
{
public
IsEqualToPet
(
Pet
entity
)
{
super
(
entity
);
}
@Override
protected
boolean
matchesSafely
(
Pet
actual
)
{
this
.
clearDescribeTo
();
if
(
actual
==
null
)
{
this
.
addTemplatedDescription
(
"actual"
,
expected
.
toString
());
return
false
;
}
else
{
return
checkAttribute
(
"id"
,
Pet:
:
getId
,
actual
)
&&
checkAttribute
(
"name"
,
Pet:
:
getName
,
actual
)
&&
checkAttribute
(
"kind"
,
Pet:
:
getKind
,
actual
)
&&
checkAttribute
(
"breed"
,
Pet:
:
getBreed
,
actual
)
&&
checkAttribute
(
"owner"
,
Pet:
:
getOwner
,
actual
);
}
}
/**
* Factory method that creates a new {@link IsEqualToEntity} matcher with
* the provided {@link Pet} as the expected value.
*
* @param pet the expected person.
* @return a new {@link IsEqualToEntity} matcher with the provided
* {@link Pet} as the expected value.
*/
@Factory
public
static
IsEqualToPet
equalsToPet
(
Pet
pet
)
{
return
new
IsEqualToPet
(
pet
);
}
/**
* Factory method that returns a new {@link Matcher} that includes several
* {@link IsEqualToPet} matchers, each one using an {@link Pet} of the
* provided ones as the expected value.
*
* @param pets the pets to be used as the expected values.
* @return a new {@link Matcher} that includes several
* {@link IsEqualToPet} matchers, each one using an {@link Pet} of the
* provided ones as the expected value.
* @see IsEqualToEntity#containsEntityInAnyOrder(java.util.function.Function, Object...)
*/
@Factory
public
static
Matcher
<
Iterable
<?
extends
Pet
>>
containsPetsInAnyOrder
(
Pet
...
pets
)
{
return
containsEntityInAnyOrder
(
IsEqualToPet:
:
equalsToPet
,
pets
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment