Package org.trellisldp.test
Class InMemoryResourceService
- java.lang.Object
-
- org.trellisldp.test.InMemoryResourceService
-
- All Implemented Interfaces:
ResourceService
,RetrievalService<Resource>
public class InMemoryResourceService extends Object implements ResourceService
AResourceService
that stores its contents in memory, for testing.
-
-
Constructor Summary
Constructors Constructor Description InMemoryResourceService()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletionStage<Void>
add(IRI identifier, Dataset newData)
CompletionStage<Void>
delete(Metadata metadata)
Delete a resource from the server.String
generateIdentifier()
An identifier generator.CompletionStage<? extends Resource>
get(IRI identifier)
Get a resource by the given identifier.CompletionStage<Void>
replace(Metadata metadata, Dataset data)
Replace a resource in the server.Set<IRI>
supportedInteractionModels()
Return a collection of interaction models supported by this Resource Service.CompletionStage<Void>
touch(IRI identifier)
Update the modification date of the provided resource.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.trellisldp.api.ResourceService
create, getResourceIdentifier, skolemize, toExternal, toInternal, unskolemize
-
-
-
-
Method Detail
-
get
public CompletionStage<? extends Resource> get(IRI identifier)
Description copied from interface:RetrievalService
Get a resource by the given identifier.- Specified by:
get
in interfaceRetrievalService<Resource>
- Parameters:
identifier
- the resource identifier- Returns:
- the resource
-
replace
public CompletionStage<Void> replace(Metadata metadata, Dataset data)
Description copied from interface:ResourceService
Replace a resource in the server.- Specified by:
replace
in interfaceResourceService
- Parameters:
metadata
- metadata for the resourcedata
- the dataset to be persisted- Returns:
- a new completion stage that, when the stage completes normally, indicates that the supplied data
were successfully stored in the corresponding persistence layer. In the case of an unsuccessful write 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.
-
delete
public CompletionStage<Void> delete(Metadata metadata)
Description copied from interface:ResourceService
Delete a resource from the server.- Specified by:
delete
in interfaceResourceService
- Parameters:
metadata
- metadata for the resource- Returns:
- a new completion stage that, when the stage completes normally, indicates that the resource
was successfully deleted from the corresponding persistence layer. In the case of an unsuccessful delete
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.
-
add
public CompletionStage<Void> add(IRI identifier, Dataset newData)
- Specified by:
add
in interfaceResourceService
- Parameters:
identifier
- the identifier under which to persist a datasetnewData
- a dataset to persist- Returns:
- a new completion stage that, when the stage completes normally, indicates that the supplied data
were successfully stored in the corresponding persistence layer. In the case of an unsuccessful write 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.
-
touch
public CompletionStage<Void> touch(IRI identifier)
Description copied from interface:ResourceService
Update the modification date of the provided resource.- Specified by:
touch
in interfaceResourceService
- Parameters:
identifier
- the identifier of the resource- Returns:
- a new completion stage that, when the stage completes normally, indicates that the identified resource has been updated with a new modification date.
-
supportedInteractionModels
public Set<IRI> supportedInteractionModels()
Description copied from interface:ResourceService
Return a collection of interaction models supported by this Resource Service.- Specified by:
supportedInteractionModels
in interfaceResourceService
- Returns:
- a set of supported interaction models
-
generateIdentifier
public String generateIdentifier()
Description copied from interface:ResourceService
An identifier generator.- Specified by:
generateIdentifier
in interfaceResourceService
- Returns:
- a new identifier
-
-