Package org.springframework.mock.web.server

# Class MockServerWebExchange.Builder

java.lang.Object
org.springframework.mock.web.server.MockServerWebExchange.Builder

Enclosing class:
  MockServerWebExchange

public static class MockServerWebExchange.Builder extends Object
Builder for a `MockServerWebExchange`.

Since:
  5.1

## Constructor Summary

Constructors
Constructor
Description
`Builder(MockServerHttpRequest request)`

## Method Summary

Modifier and Type
Method
Description
`MockServerWebExchange.Builder`
`applicationContext(org.springframework.context.ApplicationContext applicationContext)`
Provide the `ApplicationContext` to expose through the exchange.
`MockServerWebExchange`
`build()`
Build the `MockServerWebExchange` instance.
`MockServerWebExchange.Builder`
`principal(Principal principal)`
Provide a user to associate with the exchange.
`MockServerWebExchange.Builder`
`session(org.springframework.web.server.WebSession session)`
Set the session to use for the exchange.
`MockServerWebExchange.Builder`
`sessionManager(org.springframework.web.server.session.WebSessionManager sessionManager)`
Provide a `WebSessionManager` instance to use with the exchange.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### Builder

public Builder(MockServerHttpRequest request)

## Method Details

### session

public MockServerWebExchange.Builder session(org.springframework.web.server.WebSession session)
Set the session to use for the exchange.

This method is mutually exclusive with `sessionManager(WebSessionManager)`.

Parameters:
  `session` - the session to use
See Also:
  - `MockWebSession`

### sessionManager

public MockServerWebExchange.Builder sessionManager(org.springframework.web.server.session.WebSessionManager sessionManager)
Provide a `WebSessionManager` instance to use with the exchange.

This is mutually exclusive with `session(WebSession)`.

Parameters:
  `sessionManager` - the session manager to use

### applicationContext

public MockServerWebExchange.Builder applicationContext(org.springframework.context.ApplicationContext applicationContext)
Provide the `ApplicationContext` to expose through the exchange.

Parameters:
  `applicationContext` - the context to use
Since:
  6.2.5

### principal

public MockServerWebExchange.Builder principal(@Nullable Principal principal)
Provide a user to associate with the exchange.

Parameters:
  `principal` - the principal to use
Since:
  6.2.7

### build

public MockServerWebExchange build()
Build the `MockServerWebExchange` instance.