|
Fish & Chips Club 4.10.0.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object hirondelle.fish.main.member.MemberDAO hirondelle.fish.main.member.MemberDAOFake
public class MemberDAOFake
Test double for MemberDAO
.
This is a 'fake' class is intended for unit testing only. This implementation stores its data in memory, using a static member of this class. This class is safe for access from multiple threads.
Note: this class uses synchronized to ensure thread safety. However, this may not really be necessary in many cases. It's only really necessary when your testing involves more than a single thread of execution. When running stand-alone unit tests, there is usually only one such thread. When using tools such as HttpUnit, however, which throw multiple HTTP requests at your app, then 'synchronized' is required.
This class goes to some lengths to mimic the real behavior as closely as possible.
For example, the items returned by list()
are sorted correctly using a specific
Comparator. In addition, there is a mechanism for forcing particular
exceptions to occur (important for exercising all branches.)
Constructor Summary | |
---|---|
MemberDAOFake()
|
Method Summary | |
---|---|
(package private) Id |
add(Member aMember)
Add a new Member to the database. |
(package private) boolean |
change(Member aMember)
Update an existing Member . |
(package private) int |
delete(Id aMemberId)
Delete a single Member . |
Member |
fetch(Id aMemberId)
Return a single Member identified by its id. |
(package private) Integer |
getNumActiveMembers()
Return the number of currently active members. |
(package private) List<Member> |
list()
Return a List of all Member objects, sorted by Member Name. |
Methods inherited from class hirondelle.fish.main.member.MemberDAO |
---|
deleteMany, getInstance |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MemberDAOFake()
Method Detail |
---|
List<Member> list() throws DAOException
MemberDAO
Member
objects, sorted by Member Name.
list
in class MemberDAO
DAOException
public Member fetch(Id aMemberId) throws DAOException
MemberDAO
Member
identified by its id.
fetch
in class MemberDAO
DAOException
Id add(Member aMember) throws DAOException, DuplicateException
MemberDAO
Member
to the database.
The name of the Member must be unique. If there is a name
conflict, then a DuplicateException
is thrown.
add
in class MemberDAO
DAOException
DuplicateException
boolean change(Member aMember) throws DAOException, DuplicateException
MemberDAO
Member
.
The name of the Member must be unique. If there is a name
conflict, then a DuplicateException
is thrown.
change
in class MemberDAO
DAOException
DuplicateException
int delete(Id aMemberId) throws DAOException
MemberDAO
Member
.
If an item is linked to this Member
, then deletion will fail, and a
DAOException
is thrown.
delete
in class MemberDAO
DAOException
Integer getNumActiveMembers() throws DAOException
MemberDAO
getNumActiveMembers
in class MemberDAO
DAOException
|
Fish & Chips Club 4.10.0.0 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |