Package org.trellisldp.test
Class InMemoryBinaryService
- java.lang.Object
-
- org.trellisldp.test.InMemoryBinaryService
-
- All Implemented Interfaces:
BinaryService
,RetrievalService<Binary>
public class InMemoryBinaryService extends Object implements BinaryService
ABinaryService
that stores its contents in memory, for testing.
-
-
Constructor Summary
Constructors Constructor Description InMemoryBinaryService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
generateIdentifier(IRI identifier)
Get a new identifier.CompletionStage<? extends Binary>
get(IRI identifier)
Get a resource by the given identifier.CompletionStage<Void>
purgeContent(IRI identifier)
Purge the content from its corresponding datastore.CompletionStage<Void>
setContent(BinaryMetadata meta, InputStream bytes)
Set the content for a binary object.
-
-
-
Method Detail
-
get
public CompletionStage<? extends Binary> get(IRI identifier)
Description copied from interface:RetrievalService
Get a resource by the given identifier.- Specified by:
get
in interfaceRetrievalService<Binary>
- Parameters:
identifier
- the resource identifier- Returns:
- the resource
-
setContent
public CompletionStage<Void> setContent(BinaryMetadata meta, InputStream bytes)
Description copied from interface:BinaryService
Set the content for a binary object.- Specified by:
setContent
in interfaceBinaryService
- Parameters:
meta
- the binary metadatabytes
- the content- Returns:
- the new completion stage
-
purgeContent
public CompletionStage<Void> purgeContent(IRI identifier)
Description copied from interface:BinaryService
Purge the content from its corresponding datastore.- Specified by:
purgeContent
in interfaceBinaryService
- Parameters:
identifier
- the binary object identifier- Returns:
- a new completion stage that, when the stage completes normally, indicates that the binary data
were successfully deleted from the corresponding persistence layer. In the case of an unsuccessful
operation, the
CompletionStage
will complete exceptionally and can be handled withCompletionStage.handle(java.util.function.BiFunction<? super T, java.lang.Throwable, ? extends U>)
,CompletionStage.exceptionally(java.util.function.Function<java.lang.Throwable, ? extends T>)
or similar methods.
-
generateIdentifier
public String generateIdentifier(IRI identifier)
Description copied from interface:BinaryService
Get a new identifier.- Specified by:
generateIdentifier
in interfaceBinaryService
- Parameters:
identifier
- the associated resource identifier- Returns:
- a new identifier
-
-