Class MockPageContext

  • All Implemented Interfaces:
    IPageContext

    public class MockPageContext
    extends java.lang.Object
    implements IPageContext
    Mock implementation of a page context - suitable for a single session only.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clearRequest()  
      void clearSession()  
      <T> T getRequestData​(MetaDataKey<T> key, java.util.function.Supplier<T> defaultValue)
      Get data from the current request cycle.
      <T extends java.io.Serializable>
      T
      getSessionAttribute​(java.lang.String key, java.util.function.Supplier<T> defaultValue)
      Get an attribute from the session.
      <T extends java.io.Serializable>
      T
      getSessionData​(MetaDataKey<T> key, java.util.function.Supplier<T> defaultValue)
      Get metadata from the session.
      java.lang.String getSessionId​(boolean bind)
      Get the identifier of the session.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MockPageContext

        public MockPageContext()
      • MockPageContext

        public MockPageContext​(java.lang.String sessionId)
    • Method Detail

      • getSessionAttribute

        public <T extends java.io.Serializable> T getSessionAttribute​(java.lang.String key,
                                                                      java.util.function.Supplier<T> defaultValue)
        Description copied from interface: IPageContext
        Get an attribute from the session.
        Binds the session if not already set and supplied default value is not null.
        Specified by:
        getSessionAttribute in interface IPageContext
        Parameters:
        key - key
        defaultValue - default value to use if not present
        Returns:
        value
        See Also:
        Session.getAttribute(String)
      • getSessionData

        public <T extends java.io.Serializable> T getSessionData​(MetaDataKey<T> key,
                                                                 java.util.function.Supplier<T> defaultValue)
        Description copied from interface: IPageContext
        Get metadata from the session.
        Binds the session if not already set and supplied default value is not null.
        Specified by:
        getSessionData in interface IPageContext
        Parameters:
        key - key
        defaultValue - default value to use if not present
        Returns:
        value
        See Also:
        Session.getMetaData(MetaDataKey)
      • getSessionId

        public java.lang.String getSessionId​(boolean bind)
        Description copied from interface: IPageContext
        Get the identifier of the session.
        Specified by:
        getSessionId in interface IPageContext
        Parameters:
        bind - should the session be bound
        Returns:
        session id, might be null if not bound yet
      • clearRequest

        public void clearRequest()
      • clearSession

        public void clearSession()