Package com.attivio.sdk.service
Class MockContentStoreClient
- java.lang.Object
-
- com.attivio.sdk.service.MockContentStoreClient
-
- All Implemented Interfaces:
ContentStoreClient
public class MockContentStoreClient extends java.lang.Object implements ContentStoreClient
Content store that saves the stream to a byte array in memory.This store provides no memory savings but does allow for ease of development and provides high speed access to the underlying data. This class is intended for use only within test environments. When running outside the Attivio build environemnt, it is recommended that
reset()be called after each test.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classMockContentStoreClient.MemoryContentPointermemory content pointer.
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Map<java.lang.String,MockContentStoreClient.MemoryContentPointer>mapMap of id to stream.-
Fields inherited from interface com.attivio.sdk.client.ContentStoreClient
DEFAULT_NAMESPACE, GET_EXTERNAL_URI, OK_STORE_RESPONSE
-
-
Constructor Summary
Constructors Constructor Description MockContentStoreClient()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(java.lang.String id)True if the content store has a stream for this id.voiddelete(java.lang.String id)Delete a record by id from the content store.voiddeleteAll()Delete all content in the content store.protected static voidensureWebServer()longgetTotalRecords()Get the total number of records in the content store.static voidreset()Resets the content store client, clearing the map of content and stopping the webServer.ContentPointerretrieve(java.lang.String id)Retrieve a ContentPointer in the ContentStore.voidsetNamespace(java.lang.String namespace)Sets the namespace all ids will be stored in.ContentPointerstore(java.lang.String id, InputStreamBuilder input)Store a ContentPointer in the ContentStore.
-
-
-
Field Detail
-
map
protected static final java.util.Map<java.lang.String,MockContentStoreClient.MemoryContentPointer> map
Map of id to stream.
-
-
Method Detail
-
reset
public static void reset()
Resets the content store client, clearing the map of content and stopping the webServer. This method should be called after each test if running outside of the Attivio build environment.
-
ensureWebServer
protected static void ensureWebServer() throws java.lang.Exception- Throws:
java.lang.Exception
-
retrieve
public ContentPointer retrieve(java.lang.String id) throws AttivioException
Retrieve a ContentPointer in the ContentStore.- Specified by:
retrievein interfaceContentStoreClient- Returns:
- the ContentPointer or null if
idis not in the store. - Throws:
AttivioException
-
store
public ContentPointer store(java.lang.String id, InputStreamBuilder input) throws AttivioException
Store a ContentPointer in the ContentStore.- Specified by:
storein interfaceContentStoreClient- Throws:
AttivioException
-
delete
public void delete(java.lang.String id) throws AttivioExceptionDelete a record by id from the content store.- Specified by:
deletein interfaceContentStoreClient- Throws:
AttivioException
-
deleteAll
public void deleteAll() throws AttivioExceptionDelete all content in the content store.- Specified by:
deleteAllin interfaceContentStoreClient- Throws:
AttivioException
-
getTotalRecords
public long getTotalRecords()
Get the total number of records in the content store.- Specified by:
getTotalRecordsin interfaceContentStoreClient
-
contains
public boolean contains(java.lang.String id)
True if the content store has a stream for this id.- Specified by:
containsin interfaceContentStoreClient
-
setNamespace
public void setNamespace(java.lang.String namespace)
Sets the namespace all ids will be stored in. Defaults to "content".- Specified by:
setNamespacein interfaceContentStoreClient
-
-