Class StorageOperations

java.lang.Object
org.mule.munit.tools.util.store.StorageOperations

public class StorageOperations extends Object
Operations to store temporary data
Since:
2.2.0
Author:
Mulesoft Inc.
  • Field Details

    • storageRule

      @Inject protected org.mule.munit.runner.component.rules.TemporaryStorageRule storageRule
  • Constructor Details

    • StorageOperations

      public StorageOperations()
  • Method Details

    • store

      @Summary("Stores the given data associated with the given key") @Throws(StoreErrorProvider.class) public void store(String key, @Optional(defaultValue="#[payload]") @Content org.mule.runtime.api.metadata.TypedValue<Serializable> value, @Optional(defaultValue="false") boolean failIfPresent)
      Stores the given value using the given key.

      This operation can be used either for storing new values or updating existing ones. This operation is synchronized on the key level. No other operation will be able to access the same key.

      Parameters:
      key - the key of the value to be stored
      value - the value to be stored
      failIfPresent - whether to fail or update the pre existing value if the key already exists on the store
    • retrieve

      @Summary("Retrieves the data associated with the given key") @Throws(RetrieveErrorProvider.class) public org.mule.runtime.extension.api.runtime.operation.Result<Serializable,​Void> retrieve(String key)
      Retrieves the value stored for the given key.

      If no value exists for the key, then a MUNIT-TOOLS:MISSING_KEY error will be thrown. This operations is synchronized on the key level. No other operation will be able to access the same key while this operation is running

      Parameters:
      key - the key of the value to be retrieved
      Returns:
      The stored value
    • remove

      @Summary("Removes the data associated with the given key") @Throws(RetrieveErrorProvider.class) public org.mule.runtime.extension.api.runtime.operation.Result<Serializable,​Void> remove(String key)
      Removes the value associated to the given key.

      If no value exist for the key, then a MUNIT-TOOLS:MISSING_KEY error will be thrown.This operation is synchronized on the key level. No other operation will be able to access the same key while this operation is running.

      Parameters:
      key - the key of the object to be removed
      Returns:
      The storage value
    • clearStoredData

      @Summary("Clears all stored data") public void clearStoredData()
      Removes all stored data
    • storeOAuthToken

      @Alias("store-oauth-token") @Throws(StoreOAuthTokenErrorProvider.class) public void storeOAuthToken(String accessToken, @ParameterDsl(allowInlineDefinition=false) org.mule.runtime.api.store.ObjectStore objectStore, @Optional(defaultValue="") String ownerConfigName, @Optional(defaultValue="") String resourceOwnerId, @Optional String refreshToken, @Optional String expiresIn, @Optional String state, @Optional @Content Map<String,​Object> additionalParameters, @Optional(defaultValue="true") boolean overwrite) throws org.mule.runtime.api.store.ObjectStoreException
      Stores a test OAuth token in the supplied ObjectStore
      Parameters:
      ownerConfigName - the config name of the connector that's going to consume the token
      resourceOwnerId - the id of the resource owner
      accessToken - the access token
      refreshToken - the refresh token
      expiresIn - the expiration string
      state - the state parameter used in the OAuth dance
      additionalParameters - additional parameters returned by the service provider
      overwrite - whether to overwrite the token if already exists or fail instead.
      objectStore - the object store to store the token in
      Throws:
      org.mule.runtime.api.store.ObjectStoreException