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
ABinaryServicethat 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 StringgenerateIdentifier(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:RetrievalServiceGet a resource by the given identifier.- Specified by:
getin interfaceRetrievalService<Binary>- Parameters:
identifier- the resource identifier- Returns:
- the resource
-
setContent
public CompletionStage<Void> setContent(BinaryMetadata meta, InputStream bytes)
Description copied from interface:BinaryServiceSet the content for a binary object.- Specified by:
setContentin interfaceBinaryService- Parameters:
meta- the binary metadatabytes- the content- Returns:
- the new completion stage
-
purgeContent
public CompletionStage<Void> purgeContent(IRI identifier)
Description copied from interface:BinaryServicePurge the content from its corresponding datastore.- Specified by:
purgeContentin 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
CompletionStagewill 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:BinaryServiceGet a new identifier.- Specified by:
generateIdentifierin interfaceBinaryService- Parameters:
identifier- the associated resource identifier- Returns:
- a new identifier
-
-