Class ObjectStepLogger

java.lang.Object
io.getlime.security.powerauth.lib.cmd.logging.ObjectStepLogger
All Implemented Interfaces:
StepLogger

public class ObjectStepLogger extends Object implements StepLogger
Object-based step logger useful for tests.
Author:
Roman Strobl, roman.strobl@wultra.com
  • Constructor Details

    • ObjectStepLogger

      public ObjectStepLogger()
      Default constructor with no logging.
    • ObjectStepLogger

      public ObjectStepLogger(OutputStream out)
      Constructor with output stream.
      Parameters:
      out - Output stream for logging.
  • Method Details

    • start

      public void start()
      Description copied from interface: StepLogger
      Start the object streaming, outputs start of the result object:
      Specified by:
      start in interface StepLogger
    • writeItem

      public void writeItem(String id, String name, String description, String status, Object object)
      Writes an object representing the step of the execution.
      Specified by:
      writeItem in interface StepLogger
      Parameters:
      id - Step ID.
      name - Step name.
      description - Step detailed description.
      status - Step status result.
      object - Custom object associated with the step.
    • writeServerCall

      public void writeServerCall(String id, String uri, String method, Object requestObject, byte[] requestBytes, Map<String,?> headers)
      Write the information about the server call. Uses "writeItem" method under the hood.
      Specified by:
      writeServerCall in interface StepLogger
      Parameters:
      id - Step ID.
      uri - URI that will be called.
      method - HTTP method of the call.
      requestObject - Request object, in case of the POST, PUT, DELETE method.
      requestBytes - Request bytes, in case of the POST, PUT, DELETE method.
      headers - HTTP request headers.
    • writeServerCallOK

      public void writeServerCallOK(String id, Object responseObject, Map<String,?> headers)
      Write information about the successful server request. Uses "writeItem" method under the hood.
      Specified by:
      writeServerCallOK in interface StepLogger
      Parameters:
      id - Step ID.
      responseObject - HTTP response object.
      headers - HTTP response headers.
    • writeServerCallError

      public void writeServerCallError(String id, int statusCode, Object responseObject, Map<String,?> headers)
      Write information about the service call error.
      Specified by:
      writeServerCallError in interface StepLogger
      Parameters:
      id - Step ID.
      statusCode - HTTP response status code.
      responseObject - HTTP response object.
      headers - HTTP response headers.
    • close

      public void close()
      Description copied from interface: StepLogger
      Closes the logger output, writes code to close the array and opened object
      Specified by:
      close in interface StepLogger
    • writeServerCallConnectionError

      public void writeServerCallConnectionError(String id, Exception e)
      Write information about service call network connection error.
      Specified by:
      writeServerCallConnectionError in interface StepLogger
      Parameters:
      id - Step ID.
      e - Exception that caused the error.
    • writeError

      public void writeError(String id, String errorMessage)
      Write information about an error.
      Specified by:
      writeError in interface StepLogger
      Parameters:
      id - Step ID.
      errorMessage - Error message.
    • writeError

      public void writeError(String id, Exception exception)
      Write information about an error.
      Specified by:
      writeError in interface StepLogger
      Parameters:
      id - Step ID.
      exception - Exception that caused the error.
    • writeError

      public void writeError(String id, String name, String errorMessage)
      Write information about an error.
      Specified by:
      writeError in interface StepLogger
      Parameters:
      id - Step ID.
      name - Error item name.
      errorMessage - Error message.
    • writeError

      public void writeError(String id, String name, String errorMessage, Exception exception)
      Write information about an error.
      Specified by:
      writeError in interface StepLogger
      Parameters:
      id - Step ID.
      name - Error item name.
      errorMessage - Error message.
      exception - Exception that caused the error.
    • writeDoneOK

      public void writeDoneOK(String id)
      Write information about a successful completion.
      Specified by:
      writeDoneOK in interface StepLogger
      Parameters:
      id - Step ID.
    • writeDoneFailed

      public void writeDoneFailed(String id)
      Write error about a failed execution.
      Specified by:
      writeDoneFailed in interface StepLogger
      Parameters:
      id - Step ID.
    • getItems

      public List<StepItem> getItems()
      Get step items.
      Returns:
      Step items.
    • getFirstItem

      public StepItem getFirstItem(String id)
      Get first StepItem with given ID.
      Parameters:
      id - Item ID.
      Returns:
      First StepItem with given id or null if logger doesn't contain such item.
    • getFirstItemByName

      public StepItem getFirstItemByName(String itemName)
      Get first StepItem with given name.
      Parameters:
      itemName - Item name.
      Returns:
      First StepItem with given name or null if logger doesn't contain such item.
    • getErrors

      public List<StepError> getErrors()
      Get step errors.
      Returns:
      Step errors.
    • getFirstError

      public StepError getFirstError(String id)
      Get first StepError with given name.
      Parameters:
      id - Error ID.
      Returns:
      First StepError with given ID or null if logger doesn't contain such error.
    • getFirstErrorByName

      public StepError getFirstErrorByName(String errorName)
      Get first StepError with given name.
      Parameters:
      errorName - Error name.
      Returns:
      First StepError with given name or null if logger doesn't contain such error.
    • getRequest

      public StepRequest getRequest()
      Get request.
      Returns:
      Request.
    • getResponse

      public StepResponse getResponse()
      Get response.
      Returns:
      Response.
    • getResult

      public StepResult getResult()
      Get step result.
      Returns:
      Step result.