java.lang.Object
org.eclipse.lemminx.customservice.synapse.mediator.TryOutUtils

public class TryOutUtils extends Object
  • Method Details

    • isExpectedBreakpoint

      public static boolean isExpectedBreakpoint(com.google.gson.JsonObject actual, com.google.gson.JsonObject expected)
      This method is used to check whether the actual breakpoint is the expected breakpoint.
      Parameters:
      actual - the actual breakpoint data
      expected - the expected breakpoint data
      Returns:
      true if the actual breakpoint matches the expected breakpoint, false otherwise
    • isExpectedBreakpoint

      public static boolean isExpectedBreakpoint(com.google.gson.JsonObject actual, List<com.google.gson.JsonObject> expected)
      This method is used to check whether the actual breakpoint is one of the expected breakpoints.
      Parameters:
      actual - the actual breakpoint data
      expected - the list of expected breakpoints
      Returns:
      true if the actual breakpoint matches any of the expected breakpoints, false otherwise
    • relativizeAndResolvePath

      public static Path relativizeAndResolvePath(Path relativizeSourcePath, Path relativizeTargetPath, Path resolveSourcePath)
      Relativizes a target path against a given source path and then resolves it against another source path to produce a new path.

      This method first computes the relative path from relativizeSourcePath to relativizeTargetPath. It then resolves this relative path against resolveSourcePath.

      Parameters:
      relativizeSourcePath - the base path against which relativizeTargetPath will be relativized
      relativizeTargetPath - the target path to be relativized against relativizeSourcePath
      resolveSourcePath - the path against which the computed relative path will be resolved
      Returns:
      the resulting path obtained by resolving the relative path between relativizeSourcePath and relativizeTargetPath against resolveSourcePath
      Throws:
      IllegalArgumentException - if relativizeSourcePath and relativizeTargetPath are not of the same type (both relative or both absolute)
    • cloneAndPreprocessProject

      public static Path cloneAndPreprocessProject(String projectUri, MediatorTryoutRequest request, Path tempFolder) throws IOException
      This method is used to clone and preprocess the project.
      Parameters:
      projectUri - the project URI
      request - the tryout request
      tempFolder - the temporary folder to clone the project
      Returns:
      the path of the file in which the edits are applied
      Throws:
      IOException
    • doEdits

      public static void doEdits(Edit[] edits, Path editFilePath) throws IOException
      This method is used to apply the edits to the file.
      Parameters:
      edits - the edits to be applied
      editFilePath - the file in which the edits are applied
      Throws:
      IOException
    • doEdit

      public static void doEdit(Edit edit, Path editFilePath) throws IOException
      This method is used to apply the edit to the file.
      Parameters:
      edit - the edit to be applied
      editFilePath - the file in which the edit is applied
      Throws:
      IOException
    • addNewLogMediator

      public static void addNewLogMediator(DOMDocument document, int insertOffset, Path editFilePath) throws BadLocationException, IOException
      This method is used to add a new log mediator to the sequence.
      Parameters:
      document - the document
      insertOffset - the offset to insert the log mediator
      editFilePath - the file in which the log mediator is added
      Throws:
      BadLocationException
      IOException
    • getInvocationInfo

      public static InvocationInfo getInvocationInfo(Path apiPath, MediatorTryoutRequest request, List<com.google.gson.JsonObject> activeBreakpoints, String host, int port) throws IOException
      Extracts the invocation info to invoke the API for the given position.
      Parameters:
      apiPath - the path of the API
      request - the mediator tryout request
      activeBreakpoints - the active breakpoints
      host - the host
      port - the port
      Returns:
      the invocation info
      Throws:
      IOException
    • processURLParams

      public static String processURLParams(String serviceUrl, List<Property> queryParams, List<Property> pathParams)
    • isApi

      public static boolean isApi(String projectUri, String file)
      Check whether the given file is an API.
      Parameters:
      projectUri -
      file -
      Returns:
    • createMediatorInfo

      public static MediatorInfo createMediatorInfo(List<String> properties)
      Create mediator info for the given property JSON String from the debugger.
      Parameters:
      properties -
      Returns:
    • getBodyContent

      public static String getBodyContent(String xmlContent) throws Exception
      Throws:
      Exception
    • createAPI

      public static String createAPI(Mediator mediator, String tempPath) throws InvalidConfigurationException
      Creates an API for executing the given mediator.
      Parameters:
      mediator -
      tempPath -
      Returns:
      the path of the created API
      Throws:
      InvalidConfigurationException
    • getMediatorPosition

      public static org.eclipse.lsp4j.Position getMediatorPosition(String apiPath, int resourceIndex, int mediatorIndex) throws IOException
      Returns the position of the mediator in the given resourceIndex and mediatorIndex.
      Parameters:
      apiPath -
      resourceIndex -
      mediatorIndex -
      Returns:
      the position of the mediator
      Throws:
      IOException - if an error occurs while getting the mediator position or if the api is not found
    • findCAPP

      public static Path findCAPP(Path targetPath) throws ArtifactDeploymentException
      Throws:
      ArtifactDeploymentException