Record Class ConnectionTestResult

java.lang.Object
java.lang.Record
com.xebialabs.xlrelease.osgi.api.configuration.ConnectionTestResult
Record Components:
successful - whether the test succeeded
message - shown to the release author on success or failure; must never contain secrets
exception - present for failures that carry a cause

public record ConnectionTestResult(boolean successful, String message, Optional<Exception> exception) extends Record
The outcome of one ConnectionTestExtension.test(com.xebialabs.deployit.plugin.api.udm.ConfigurationItem) call. message is rendered to the release author who clicked Test Connection, on both success and failure - never put a configuration value (a URL with embedded credentials, a token from an HTTP error body, ...) in it, exactly as TaskExecutionContext.log(java.lang.String) already warns for task execution logs.
  • Field Details

    • DEFAULT_FAILURE_MESSAGE

      public static final String DEFAULT_FAILURE_MESSAGE
      Safe fallback for failures that do not provide an explicit public message.

      Attached exception details are for server-side diagnostics only and are not used to build client-facing messages.

      See Also:
  • Constructor Details

    • ConnectionTestResult

      public ConnectionTestResult(boolean successful, String message)
      Success or failure with a message but no attached exception.
      Parameters:
      successful - whether the test succeeded
      message - shown to the release author; must never contain secrets
    • ConnectionTestResult

      public ConnectionTestResult(boolean successful, String message, Exception exception)
      Result carrying both a message and an exception.
      Parameters:
      successful - whether the test succeeded
      message - shown to the release author
      exception - the cause
    • ConnectionTestResult

      public ConnectionTestResult(boolean successful, Exception e)
      Uses DEFAULT_FAILURE_MESSAGE as the result message. The exception remains attached for server-side diagnostics and does not contribute to the client-facing message.
      Parameters:
      successful - whether the test succeeded
      e - the exception to attach
    • ConnectionTestResult

      public ConnectionTestResult(Exception e)
      Failure carrying the given exception and the DEFAULT_FAILURE_MESSAGE. The exception remains available for server-side diagnostics only.
      Parameters:
      e - the exception to attach
    • ConnectionTestResult

      public ConnectionTestResult(String message)
      Successful result with the given message.
      Parameters:
      message - shown to the release author
    • ConnectionTestResult

      public ConnectionTestResult(boolean successful, String message, Optional<Exception> exception)
      Creates an instance of a ConnectionTestResult record class.
      Parameters:
      successful - the value for the successful record component
      message - the value for the message record component
      exception - the value for the exception record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • successful

      public boolean successful()
      Returns the value of the successful record component.
      Returns:
      the value of the successful record component
    • message

      public String message()
      Returns the value of the message record component.
      Returns:
      the value of the message record component
    • exception

      public Optional<Exception> exception()
      Returns the value of the exception record component.
      Returns:
      the value of the exception record component