Class TryOutUtils
java.lang.Object
org.eclipse.lemminx.customservice.synapse.mediator.TryOutUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddNewLogMediator(DOMDocument document, int insertOffset, Path editFilePath) This method is used to add a new log mediator to the sequence.static PathcloneAndPreprocessProject(String projectUri, MediatorTryoutRequest request, Path tempFolder) This method is used to clone and preprocess the project.static StringCreates an API for executing the given mediator.static MediatorInfocreateMediatorInfo(List<String> properties) Create mediator info for the given property JSON String from the debugger.static voidThis method is used to apply the edit to the file.static voidThis method is used to apply the edits to the file.static Pathstatic StringgetBodyContent(String xmlContent) static InvocationInfogetInvocationInfo(Path apiPath, MediatorTryoutRequest request, List<com.google.gson.JsonObject> activeBreakpoints, String host, int port) Extracts the invocation info to invoke the API for the given position.static org.eclipse.lsp4j.PositiongetMediatorPosition(String apiPath, int resourceIndex, int mediatorIndex) Returns the position of the mediator in the given resourceIndex and mediatorIndex.static booleanCheck whether the given file is an API.static booleanisExpectedBreakpoint(com.google.gson.JsonObject actual, com.google.gson.JsonObject expected) This method is used to check whether the actual breakpoint is the expected breakpoint.static booleanisExpectedBreakpoint(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.static Stringstatic PathrelativizeAndResolvePath(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.
-
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 dataexpected- 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 dataexpected- 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
relativizeSourcePathtorelativizeTargetPath. It then resolves this relative path againstresolveSourcePath.- Parameters:
relativizeSourcePath- the base path against whichrelativizeTargetPathwill be relativizedrelativizeTargetPath- the target path to be relativized againstrelativizeSourcePathresolveSourcePath- the path against which the computed relative path will be resolved- Returns:
- the resulting path obtained by resolving the relative path between
relativizeSourcePathandrelativizeTargetPathagainstresolveSourcePath - Throws:
IllegalArgumentException- ifrelativizeSourcePathandrelativizeTargetPathare 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 URIrequest- the tryout requesttempFolder- the temporary folder to clone the project- Returns:
- the path of the file in which the edits are applied
- Throws:
IOException
-
doEdits
This method is used to apply the edits to the file.- Parameters:
edits- the edits to be appliededitFilePath- the file in which the edits are applied- Throws:
IOException
-
doEdit
This method is used to apply the edit to the file.- Parameters:
edit- the edit to be appliededitFilePath- 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 documentinsertOffset- the offset to insert the log mediatoreditFilePath- the file in which the log mediator is added- Throws:
BadLocationExceptionIOException
-
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 APIrequest- the mediator tryout requestactiveBreakpoints- the active breakpointshost- the hostport- the port- Returns:
- the invocation info
- Throws:
IOException
-
processURLParams
-
isApi
Check whether the given file is an API.- Parameters:
projectUri-file-- Returns:
-
createMediatorInfo
Create mediator info for the given property JSON String from the debugger.- Parameters:
properties-- Returns:
-
getBodyContent
- 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
- Throws:
ArtifactDeploymentException
-