Class MockRestClient.Builder
- All Implemented Interfaces:
BeanStoreOverridable<MockRestClient.Builder>
- Enclosing class:
- MockRestClient
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the object.contextPath(String value) Identifies the context path for the REST resource.copy()Copy creator.debug()Sets the value for theDebug request header on all requests.overridingBeanStore(BeanStore value) Installs aBeanStoreas theoverridingParentof theRestContext's bean store, so test-time overrides (e.g.Parsers.Add resolved path variables to this client.Add resolved path variables to this client.Specifies theRest-annotated bean class or instance to test against.restContext(RestContext value) Specifies theRestContextcreated for the REST bean.serializers(Class<? extends Serializer>... value) Serializers.servletPath(String value) Identifies the servlet path for the REST resource.Suppress logging on this client.Methods inherited from class org.apache.juneau.rest.client.classic.RestClient.Builder
accept, acceptCharset, addBeanTypes, addInterceptorFirst, addInterceptorFirst, addInterceptorLast, addInterceptorLast, addRootType, allowAddressRanges, allowPrivateUrls, backoffManager, basicAuth, bson, callHandler, callHandler, clientVersion, connectionBackoffStrategy, connectionManager, connectionManagerShared, connectionReuseStrategy, connectionTimeToLive, console, contentDecoderRegistry, contentType, createCallHandler, createConnectionManager, createFormData, createHeaderData, createHttpClient, createHttpClientBuilder, createParsers, createPartParser, createPartSerializer, createPathData, createQueryData, createSerializers, createUrlEncodingSerializer, debugOutputLines, defaultAuthSchemeRegistry, defaultConnectionConfig, defaultCookieSpecRegistry, defaultCookieStore, defaultCredentialsProvider, defaultRequestConfig, defaultSocketConfig, detectLeaks, detectRecursions, disableAuthCaching, disableAutomaticRetries, disableConnectionState, disableContentCompression, disableCookieManagement, disableRedirectHandling, errorCodes, evictExpiredConnections, evictIdleConnections, executorService, formData, formData, formData, formData, formDataDefault, getRootUri, getRootUrlSupplier, header, header, headers, headers, headersDefault, html, htmlDoc, htmlStrippedDoc, httpClient, httpClientBuilder, httpClientBuilder, httpProcessor, ignoreErrors, ignoreRecursions, initialDepth, interceptors, interceptors, jcs, json, json5, keepAliveStrategy, keepHttpClientOpen, keepNullProperties, logger, logRequests, logToConsole, marshaller, marshallers, maxConnPerRoute, maxConnTotal, maxDepth, maxIndent, mediaType, mediaType, msgPack, noTrace, oapiCollectionFormat, oapiFormat, openApi, paramFormat, paramFormatPlain, parser, parser, parsers, parsers, parserSessionOptionsHeader, parserSessionOptionsHeader, parserSessionOptionsQueryDefault, parserSessionOptionsQueryDefault, partParser, partParser, partParser, partSerializer, partSerializer, partSerializer, pathData, pathData, pathData, pathData, pathDataDefault, plainText, pooled, proxy, proxyAuthenticationStrategy, publicSuffixMatcher, queryData, queryData, queryData, queryData, queryDataDefault, quoteChar, redirectStrategy, requestExecutor, retryHandler, rootUrl, rootUrl, routePlanner, schemePortResolver, serializer, serializer, serializers, serializers, serializerSessionOptionsHeader, serializerSessionOptionsHeader, serializerSessionOptionsQueryDefault, serializerSessionOptionsQueryDefault, serviceUnavailableRetryStrategy, skipEmptyFormData, skipEmptyFormData, skipEmptyHeaderData, skipEmptyHeaderData, skipEmptyQueryData, skipEmptyQueryData, sortCollections, sortMaps, sq, sslContext, sslHostnameVerifier, sslSocketFactory, targetAuthenticationStrategy, trimEmptyCollections, trimEmptyMaps, trimStringsOnRead, trimStringsOnWrite, universal, uon, uriContext, uriRelativity, uriResolution, urlEnc, urlEncodingSerializer, userTokenHandler, useSystemProperties, useWhitespace, ws, xmlMethods inherited from class org.apache.juneau.marshall.MarshallingContextable.Builder
activeView, annotations, beanClassVisibility, beanConstructorVisibility, beanDictionary, beanFieldVisibility, beanInterceptor, beanMapPutReturnsOldValue, beanMethodVisibility, beanProperties, beanProperties, beanProperties, beanPropertiesExcludes, beanPropertiesExcludes, beanPropertiesExcludes, beanPropertiesReadOnly, beanPropertiesReadOnly, beanPropertiesReadOnly, beanPropertiesWriteOnly, beanPropertiesWriteOnly, beanPropertiesWriteOnly, beansRequireDefaultConstructor, beansRequireSerializable, beansRequireSettersForGetters, bigNumberFormat, binaryFormat, bitSetFormat, booleanFormat, calendarFormat, classFormat, classLoader, currencyFormat, dateFormat, dictionaryOn, disableBeansRequireSomeProperties, disableDefaultViewInclusion, disableIgnoreMissingSetters, disableIgnoreTransientFields, disableIgnoreUnknownNullBeanProperties, disableInterfaceProxies, durationFormat, enumFormat, example, example, findFluentSetters, findFluentSetters, floatFormat, hashKey, ignoreInvocationExceptionsOnGetters, ignoreInvocationExceptionsOnSetters, ignoreUnknownBeanProperties, ignoreUnknownEnumValues, implClass, implClasses, interfaceClass, interfaces, locale, localeFormat, marshallingContext, marshallingContext, marshallingContext, marshallingContext, notBeanClasses, notBeanPackages, periodFormat, propertyNamer, propertyNamer, recordComponentOrder, stopClass, swap, swap, swaps, swaps, temporalFormat, timeZone, timeZoneFormat, typeName, typePropertyName, typePropertyName, unsortedProperties, unsortedProperties, useJavaBeanIntrospector, uuidFormat, validateSchema, validateSchemaMethods inherited from class org.apache.juneau.marshall.Context.Builder
annotations, apply, applyAnnotations, applyAnnotations, asSubtype, build, cache, canApply, copyOrNull, debug, getApplied, getType, impl, isDebug, registerBuilders, self, type
-
Constructor Details
-
Builder
protected Builder()No-arg constructor.Provided so that this class can be easily subclassed.
-
-
Method Details
-
build
Description copied from class:Context.BuilderBuild the object.- Overrides:
buildin classRestClient.Builder<MockRestClient.Builder>- Returns:
- The built object.
-
contextPath
Identifies the context path for the REST resource.This value is used to deconstruct the request URL and set the appropriate URL getters on the
HttpServletRequestobject correctly.Should either be a value such as
"/foo" or an empty string.The following fixes are applied to non-conforming strings.
nulls and"/" are converted to empty strings.- Trailing slashes are trimmed.
- Leading slash is added if needed.
- Parameters:
value- The context path.- Returns:
- This object.
-
copy
Description copied from class:Context.BuilderCopy creator.- Overrides:
copyin classRestClient.Builder<MockRestClient.Builder>- Returns:
- A new mutable copy of this builder.
-
debug
Description copied from class:RestClient.BuilderSets the value for theDebug request header on all requests.This is a shortcut for calling
headerData().append(Debug. .of (value ))- Overrides:
debugin classRestClient.Builder<MockRestClient.Builder>- Returns:
- This object.
- See Also:
-
parsers
Description copied from class:RestClient.BuilderParsers.Associates the specified
Parserswith the HTTP client.The parsers are used to parse the HTTP response body into a POJO.
The parser that best matches the
Accept header will be used to parse the response body.
If noAccept header is specified, the first parser in the list will be used.Notes:
- When using this method that takes in classes, the parsers can be configured using any of the parser property setters (e.g.
MarshallingContextable.Builder.ignoreUnknownBeanProperties()) or bean context property setters (e.g.MarshallingContextable.Builder.swaps(Class...)) defined on this builder class.
Example:
// Create a client that uses JSON and XML transport for response bodies. RestClientclient = RestClient .create () .parser(JsonParser.class , XmlParser.class ) .build();- Overrides:
parsersin classRestClient.Builder<MockRestClient.Builder>- Parameters:
value- The new value for this setting.
The default value isJsonParser.DEFAULT.- Returns:
- This object.
- When using this method that takes in classes, the parsers can be configured using any of the parser property setters (e.g.
-
pathVars
Add resolved path variables to this client.Allows you to add resolved parent path variables when performing tests on child resource classes.
Example:
// A parent class with a path variable. @Rest ( path="/parent/{foo}" , children={ Child.class } )public class Parent { ... }// A child class that uses the parent path variable. @Rest public class Child {@RestGet public String get(@Path ("foo" ) Stringfoo ) {return foo ; } }// Test the method that uses the parent path variable. MockRestClient .create (Child.class ) .json5() .pathVars("foo" ,"bar" ) .build() .get("/" ) .run() .assertStatus().asCode().is(200) .assertContent().is("bar" );Needs review - Parameters:
value- The path variables.- Returns:
- This object.
- See Also:
-
pathVars
Add resolved path variables to this client.Identical to
pathVars(Map)but allows you to specify as a list of key/value pairs.- Parameters:
pairs- The key/value pairs. Must be an even number of parameters.- Returns:
- This object.
-
restBean
Specifies theRest-annotated bean class or instance to test against.- Parameters:
value- TheRest-annotated bean class or instance.- Returns:
- This object.
-
restContext
Specifies theRestContextcreated for the REST bean.- Parameters:
value- TheRestContextcreated for the REST bean.- Returns:
- This object.
-
overridingBeanStore
Installs aBeanStoreas theoverridingParentof theRestContext's bean store, so test-time overrides (e.g.TestBeanStore) resolve at tier 1 of the lookup chain — above the resource's local@Beanfactory entries.Setting this disables the per-resource
RestContextcache for the duration of this build, so the overlay is not silently shared with a previously-cached instance.- Specified by:
overridingBeanStorein interfaceBeanStoreOverridable<MockRestClient.Builder>- Parameters:
value- The override layer. Can benull to clear a previously-set value.- Returns:
- This object.
- Since:
- 10.0.0
-
serializers
Description copied from class:RestClient.BuilderSerializers.Associates the specified
Serializerswith the HTTP client.The serializer is used to serialize POJOs into the HTTP request body.
The serializer that best matches the
Content-Type header will be used to serialize the request body.
If noContent-Type header is specified, the first serializer in the list will be used.Notes:
- When using this method that takes in classes, the serializers can be configured using any of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.MarshallingContextable.Builder.swaps(Class...)) defined on this builder class.
Example:
// Create a client that uses JSON and XML transport for request bodies. RestClientclient = RestClient .create () .serializers(JsonSerializer.class , XmlSerializer.class ) .sortCollections()// Sort any collections being serialized. .build();- Overrides:
serializersin classRestClient.Builder<MockRestClient.Builder>- Parameters:
value- The new value for this setting.
The default isJsonSerializer.- Returns:
- This object.
- When using this method that takes in classes, the serializers can be configured using any of the serializer property setters (e.g.
-
servletPath
Identifies the servlet path for the REST resource.This value is used to deconstruct the request URL and set the appropriate URL getters on the
HttpServletRequestobject correctly.Should either be a value such as
"/foo" or an empty string.The following fixes are applied to non-conforming strings.
nulls and"/" are converted to empty strings.- Trailing slashes are trimmed.
- Leading slash is added if needed.
- Parameters:
value- The context path.- Returns:
- This object.
-
suppressLogging
Suppress logging on this client.- Returns:
- This object.
-