Class RestCallTemplate

java.lang.Object
edu.university.ecs.lab.common.models.enums.RestCallTemplate

public class RestCallTemplate extends Object
Enum to represent Spring methodName and HttpMethod combinations and determine HttpMethod from methodName.
  • Field Details

    • REST_OBJECTS

      public static final Set<String> REST_OBJECTS
    • REST_METHODS

      public static final Set<String> REST_METHODS
    • UNKNOWN_VALUE

      private static final String UNKNOWN_VALUE
      See Also:
    • url

      private final String url
    • httpMethod

      private final HttpMethod httpMethod
    • cu

      private final com.github.javaparser.ast.CompilationUnit cu
    • mce

      private final com.github.javaparser.ast.expr.MethodCallExpr mce
  • Constructor Details

    • RestCallTemplate

      public RestCallTemplate(com.github.javaparser.ast.expr.MethodCallExpr mce, MethodCall mc, com.github.javaparser.ast.CompilationUnit cu)
  • Method Details

    • getHttpFromName

      public HttpMethod getHttpFromName(com.github.javaparser.ast.expr.MethodCallExpr mce)
      Find the RestTemplate by the method name.
      Parameters:
      mce - the method call
      Returns:
      the RestTemplate found (null if not found)
    • getHttpMethodForExchange

      public HttpMethod getHttpMethodForExchange(String arguments)
      Get the HTTP method for the JSF exchange() method call.
      Parameters:
      arguments - the arguments of the exchange() method
      Returns:
      the HTTP method extracted
    • parseURL

      private String parseURL(com.github.javaparser.ast.expr.Expression exp)
      Find the URL from the given expression.
      Parameters:
      exp - the expression to extract url from
      Returns:
      the URL found
    • backupParseURL

      private String backupParseURL(com.github.javaparser.ast.expr.Expression exp)
      Find the URL from the given expression.
      Parameters:
      exp - the expression to extract url from
      Returns:
      the URL found
    • cleanURL

      private static String cleanURL(String str)
      Shorten URLs to only endpoint query
      Parameters:
      str - full url
      Returns:
      url query
    • parseFieldValue

      private String parseFieldValue(String fieldName)
    • preParseURL

      private String preParseURL(com.github.javaparser.ast.expr.MethodCallExpr mce, MethodCall mc)
    • simplifyEndpointURL

      public static String simplifyEndpointURL(String url)
      Simplifies all path arguments to {?}.
      Parameters:
      url - the endpoint URL
      Returns:
      the simplified endpoint URL