Class NotificationClient

  • All Implemented Interfaces:
    Closeable, AutoCloseable, org.apache.http.client.HttpClient

    public class NotificationClient
    extends CQClient
    The base client for all notifications related tests. It provides a core set of commonly used notification functions e.g. list / approve / delete
    It extends from CQClient which in turn provides a core set of commonly used website and page functionality.
    • Constructor Detail

      • NotificationClient

        public NotificationClient​(org.apache.http.impl.client.CloseableHttpClient http,
                                  org.apache.sling.testing.clients.SlingClientConfig config)
                           throws org.apache.sling.testing.clients.ClientException
        Throws:
        org.apache.sling.testing.clients.ClientException
      • NotificationClient

        public NotificationClient​(URI serverUrl,
                                  String user,
                                  String password)
                           throws org.apache.sling.testing.clients.ClientException
        Throws:
        org.apache.sling.testing.clients.ClientException
    • Method Detail

      • getAvailableNotificationAction

        public ArrayList<String> getAvailableNotificationAction()
                                                         throws org.apache.sling.testing.clients.ClientException
        Get the list of available action to be notified for. For now this list is hardcoded in a javascript library file which is loaded by the UI
        Returns:
        The list of available actions. Null is none is found
        Throws:
        org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
      • getNotificationMessages

        public ArrayList<Notification> getNotificationMessages()
                                                        throws org.apache.sling.testing.clients.ClientException
        Get all the existing notification messages.
        Returns:
        List of the existing notification messages
        Throws:
        org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
      • getNotificationMessages

        public ArrayList<Notification> getNotificationMessages​(int start,
                                                               int limit)
                                                        throws org.apache.sling.testing.clients.ClientException
        Get all the existing notification messages.
        Parameters:
        start - first notification
        limit - max notifications
        Returns:
        List of the existing notification messages
        Throws:
        org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
      • resetConfig

        public void resetConfig()
                         throws org.apache.sling.testing.clients.ClientException
        Delete any existing subscription
        Throws:
        org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
      • configNotifications

        public org.apache.sling.testing.clients.SlingHttpResponse configNotifications​(String channel,
                                                                                      String[] actions,
                                                                                      String packages,
                                                                                      int... expectedStatus)
                                                                               throws org.apache.sling.testing.clients.ClientException
        Set a notification subscription
        Parameters:
        channel - The type of notification (for now only "inbox")
        actions - The list of actions to be notified for
        packages - The paths to survey
        expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
        Returns:
        Response of the HTTP request
        Throws:
        org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
      • getNotificationInboxPage

        public org.apache.sling.testing.clients.SlingHttpResponse getNotificationInboxPage​(int... expectedStatus)
                                                                                    throws org.apache.sling.testing.clients.ClientException
        Get the notification inbox html page
        Parameters:
        expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
        Returns:
        Response of the HTTP request
        Throws:
        org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
      • approveNotification

        public org.apache.sling.testing.clients.SlingHttpResponse approveNotification​(Notification notification,
                                                                                      int... expectedStatus)
                                                                               throws org.apache.sling.testing.clients.ClientException
        Approve a notification message (mark it as read)
        Parameters:
        notification - The notification message to approve
        expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
        Returns:
        Response of the HTTP request
        Throws:
        org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
      • deleteNotification

        public org.apache.sling.testing.clients.SlingHttpResponse deleteNotification​(Notification notification,
                                                                                     int... expectedStatus)
                                                                              throws org.apache.sling.testing.clients.ClientException
        Delete a notification message
        Parameters:
        notification - The notification message to delete
        expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
        Returns:
        Response of the HTTP request
        Throws:
        org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
      • deleteNotifications

        public void deleteNotifications​(ArrayList<Notification> notifications,
                                        int... expectedStatus)
                                 throws org.apache.sling.testing.clients.ClientException
        Delete a list notification messages
        Parameters:
        notifications - The notification messages to delete
        expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
        Throws:
        org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
      • deleteAllNotifications

        public void deleteAllNotifications()
                                    throws org.apache.sling.testing.clients.ClientException
        Delete all the notification messages
        Throws:
        org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle
      • performAction

        public org.apache.sling.testing.clients.SlingHttpResponse performAction​(Notification notification,
                                                                                String action,
                                                                                int... expectedStatus)
                                                                         throws org.apache.sling.testing.clients.ClientException
        Do an action on a notification message (delete/approve)
        Parameters:
        notification - The notification message to apply the action to
        action - Action to perform (for now delete/approve)
        expectedStatus - list of allowed HTTP Status to be returned. If not set, http status 200 (OK) is assumed.
        Returns:
        Response of the HTTP request
        Throws:
        org.apache.sling.testing.clients.ClientException - If something fails during request/response cycle