Class TestProjectResolvers

java.lang.Object
org.elasticsearch.cluster.project.TestProjectResolvers

public final class TestProjectResolvers extends Object
An implementation of ProjectResolver that handles multiple projects for testing purposes. Not usable in production
  • Field Details

    • DEFAULT_PROJECT_ONLY

      public static final ProjectResolver DEFAULT_PROJECT_ONLY
  • Constructor Details

    • TestProjectResolvers

      public TestProjectResolvers()
  • Method Details

    • allProjects

      public static ProjectResolver allProjects()
      Returns:
      a ProjectResolver that must only be used in a cluster context. It throws in single project related methods.
    • mustExecuteFirst

      public static ProjectResolver mustExecuteFirst()
      This method returns a ProjectResolver that is unable to provide the project-id unless explicitly specified with the executeOnProject method.
    • alwaysThrow

      public static ProjectResolver alwaysThrow()
      This method returns a ProjectResolver that always throw for all methods. This is mostly useful in places where we just need a placeholder to satisfy the constructor signature.
    • singleProject

      public static ProjectResolver singleProject(ProjectId projectId)
      This method returns a ProjectResolver that gives back the specified project-id when its getProjectId method is called. The ProjectResolver can work with cluster state containing multiple projects and its supportsMultipleProjects returns true.
    • singleProject

      public static ProjectResolver singleProject(Supplier<ProjectId> projectId)
      This method returns a ProjectResolver that gives back the specified project-id when its getProjectId method is called. The ProjectResolver can work with cluster state containing multiple projects and its supportsMultipleProjects returns true.
    • singleProjectOnly

      public static ProjectResolver singleProjectOnly(ProjectId projectId)
      This method returns a ProjectResolver that returns the given ProjectId. It also assumes it is the only project in the cluster state and throws if that is not the case. In addition, the ProjectResolvers returns false for supportsMultipleProjects.
    • usingRequestHeader

      public static ProjectResolver usingRequestHeader(ThreadContext threadContext)