Fish & Chips Club 4.10.0.0

hirondelle.fish.main.member
Class MemberDAOFake

Object
  extended by hirondelle.fish.main.member.MemberDAO
      extended by hirondelle.fish.main.member.MemberDAOFake

public class MemberDAOFake
extends MemberDAO

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

MemberDAOFake

public MemberDAOFake()
Method Detail

list

List<Member> list()
            throws DAOException
Description copied from class: MemberDAO
Return a List of all Member objects, sorted by Member Name.

Overrides:
list in class MemberDAO
Throws:
DAOException

fetch

public Member fetch(Id aMemberId)
             throws DAOException
Description copied from class: MemberDAO
Return a single Member identified by its id.

Overrides:
fetch in class MemberDAO
Throws:
DAOException

add

Id add(Member aMember)
 throws DAOException,
        DuplicateException
Description copied from class: MemberDAO
Add a new Member to the database.

The name of the Member must be unique. If there is a name conflict, then a DuplicateException is thrown.

Overrides:
add in class MemberDAO
Returns:
the autogenerated database id.
Throws:
DAOException
DuplicateException

change

boolean change(Member aMember)
         throws DAOException,
                DuplicateException
Description copied from class: MemberDAO
Update an existing Member.

The name of the Member must be unique. If there is a name conflict, then a DuplicateException is thrown.

Overrides:
change in class MemberDAO
Returns:
true only if a record is actually edited.
Throws:
DAOException
DuplicateException

delete

int delete(Id aMemberId)
     throws DAOException
Description copied from class: MemberDAO
Delete a single Member.

If an item is linked to this Member, then deletion will fail, and a DAOException is thrown.

Overrides:
delete in class MemberDAO
Throws:
DAOException

getNumActiveMembers

Integer getNumActiveMembers()
                      throws DAOException
Description copied from class: MemberDAO
Return the number of currently active members.

Overrides:
getNumActiveMembers in class MemberDAO
Throws:
DAOException

Fish & Chips Club 4.10.0.0

Copyright Hirondelle Systems - Generated 2013Oct19.12.26