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 class
MockContentStoreClient.MemoryContentPointer
memory content pointer.
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Map<java.lang.String,MockContentStoreClient.MemoryContentPointer>
map
Map 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 boolean
contains(java.lang.String id)
True if the content store has a stream for this id.void
delete(java.lang.String id)
Delete a record by id from the content store.void
deleteAll()
Delete all content in the content store.protected static void
ensureWebServer()
long
getTotalRecords()
Get the total number of records in the content store.static void
reset()
Resets the content store client, clearing the map of content and stopping the webServer.ContentPointer
retrieve(java.lang.String id)
Retrieve a ContentPointer in the ContentStore.void
setNamespace(java.lang.String namespace)
Sets the namespace all ids will be stored in.ContentPointer
store(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:
retrieve
in interfaceContentStoreClient
- Returns:
- the ContentPointer or null if
id
is 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:
store
in interfaceContentStoreClient
- Throws:
AttivioException
-
delete
public void delete(java.lang.String id) throws AttivioException
Delete a record by id from the content store.- Specified by:
delete
in interfaceContentStoreClient
- Throws:
AttivioException
-
deleteAll
public void deleteAll() throws AttivioException
Delete all content in the content store.- Specified by:
deleteAll
in interfaceContentStoreClient
- Throws:
AttivioException
-
getTotalRecords
public long getTotalRecords()
Get the total number of records in the content store.- Specified by:
getTotalRecords
in interfaceContentStoreClient
-
contains
public boolean contains(java.lang.String id)
True if the content store has a stream for this id.- Specified by:
contains
in interfaceContentStoreClient
-
setNamespace
public void setNamespace(java.lang.String namespace)
Sets the namespace all ids will be stored in. Defaults to "content".- Specified by:
setNamespace
in interfaceContentStoreClient
-
-