MockDataSource class
In-memory mock implementation of DataSource for testing.
Constructed empty by default. Call seedDefaults to populate with 3 standard test documents and 4 media assets (the pre-Phase-4 behaviour).
All operations are synchronous in-memory. No network calls.
- Implemented types
Constructors
- MockDataSource()
- Constructs an empty MockDataSource.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
archiveDocumentVersion(
String versionId) → Future< DocumentVersion?> -
Archives a document version.
override
-
createDocument(
String documentType, String title, Map< String, dynamic> data, {String? slug, bool isDefault = false}) → Future<DeskDocument> -
Creates a new document with an initial version.
override
-
createDocumentVersion(
String documentId, {String status = 'draft', String? changeLog}) → Future< DocumentVersion> -
Creates a new version snapshot for a document at the current state.
override
-
deleteDocument(
String documentId) → Future< bool> -
Deletes a document.
override
-
deleteDocumentVersion(
String versionId) → Future< bool> -
Deletes a document version.
override
-
deleteMedia(
String assetId) → Future< bool> -
Delete a media asset. Fails if asset is still referenced by documents.
override
-
forceSetCrdtHlc(
String documentId, String hlc) → void - Test helper: forcibly sets crdtHlc on a document without going through the full updateDocumentData path. Useful when that method is overridden in a subclass (e.g. _HangingDataSource) to simulate in-flight requests.
-
getDocument(
String documentId) → Future< DeskDocument?> -
Retrieves a single document by its ID.
override
-
getDocuments(
String documentType, {String? search, int limit = 20, int offset = 0}) → Future< DocumentList> -
Retrieves a paginated list of documents for a specific document type.
override
-
getDocumentTypes(
) → Future< List< String> > -
Retrieves all unique document types in the system.
override
-
getDocumentVersion(
String versionId) → Future< DocumentVersion?> -
Retrieves a single document version by its ID.
override
-
getDocumentVersionData(
String versionId) → Future< Map< String, dynamic> ?> -
Get the document data for a specific version
Reconstructs data from CRDT operations at the version's HLC snapshot
override
-
getDocumentVersions(
String documentId, {int limit = 20, int offset = 0}) → Future< DocumentVersionList> -
Retrieves a paginated list of versions for a specific document.
override
-
getMediaAsset(
String assetId) → Future< MediaAsset?> -
Get a single asset by assetId.
override
-
getMediaUsageCount(
String assetId) → Future< int> -
Get usage count: how many documents reference this asset.
override
-
getPublishedData(
String documentId) → Future< Map< String, dynamic> ?> -
Returns the data snapshot that was frozen at the last publishCurrentVersion
call for
documentId, ornullif the document has never been published. -
listMedia(
{String? search, MediaTypeFilter? type, MediaSort sort = MediaSort.dateDesc, int limit = 50, int offset = 0}) → Future< MediaPage> -
List/search media assets with filtering and sorting.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
publishCurrentVersion(
String documentId) → Future< DocumentVersion> -
Atomically publishes the document's current draft as a new version.
override
-
reset(
) → void - Clears all data and re-seeds with default fixture data.
-
seedDefaults(
) → void -
Seeds the store with 3 standard test documents of type
test_all_fieldsand 4 media assets. -
setDefaultDocument(
String documentTypeSlug, String documentId) → Future< DeskDocument> -
Atomically unsets the current default for
documentTypeSlugand setsdocumentIdas the new default. Returns the updated document.override -
suggestSlug(
String title, String documentType) → Future< String> -
Suggests a unique slug for a document based on its title.
override
-
toString(
) → String -
A string representation of this object.
inherited
-
updateDocument(
String documentId, {String? title, String? slug, bool? isDefault}) → Future< DeskDocument?> -
Updates document metadata (title, slug, isDefault).
To update document data, use createDocumentVersion instead.
override
-
updateDocumentData(
String documentId, Map< String, dynamic> updates, {String? sessionId}) → Future<DeskDocument> -
Updates document data using CRDT operations (partial updates).
Only changed fields need to be provided - they will be merged automatically.
override
-
updateMediaAsset(
String assetId, {String? fileName}) → Future< MediaAsset> -
Update mutable asset fields.
override
-
uploadFile(
String fileName, Uint8List fileData) → Future< MediaAsset> -
Upload a non-image file.
override
-
uploadImage(
String fileName, Uint8List fileData) → Future< MediaAsset> -
Upload an image. The server computes all derived metadata.
Returns the MediaAsset (existing if deduplicated, new otherwise).
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited