Mock Document Store for Unit tests. This class provides a rudimentary memory-based content management system (CMS), to enable testing of the connector framework without external dependencies.
The CMS has a very simple document-model: see the MockRepositoryDocument class.
Documents have ID's: it is an important invariant that document ID's are unique.
When constructed, the CMS is empty. Documents can be added, changed, or removed by "events" (see MockRepositoryEvent). Thus the CMS is side-effected only through the following calls:
- reinit() - throws away the current store, if any, and sets it to an empty state
- applyEvent() - takes an event and applies it the store (adds, changes or deletes a document)
The CMS can be inspected by the following calls:
- getDocByID() - returns the document with the specified ID, if present. Document must have unique IDs
- iterator() - returns an iterator for all documents, in timestamp order. (Note: this class implements Iterable
Two integrity constraints are enforced after every side-effecting change:
- checkDocidUniquenessIntegrity() - makes sure that IDs are unique
- checkDateOrderIntegrity() - makes sure that the iterator returns documents in timestamp order
TODO(ziff):
- add event call-back
- add textual dump/load so bigger test cases can be built easily