Class NCTestClientBuilder
- java.lang.Object
-
- org.apache.nlpcraft.model.tools.test.NCTestClientBuilder
-
public class NCTestClientBuilder extends Object
Test client builder forNCTestClient
instances. Note that all configuration values have sensible defaults. Most of the time only usercredentials
will have to be changed if not testing with default account.
-
-
Field Summary
Fields Modifier and Type Field Description static String
DFLT_BASEURL
Default public REST API URL (endpoint).static String
DFLT_EMAIL
Default client email.static boolean
DFLT_EMBEDDED
Default embedded mode flag.static long
DFLT_MAX_WAIT_TIME
Maximum test time.static String
DFLT_PASSWORD
Default client password.static boolean
DFLT_RESP_LOG
Default response log flag.
-
Constructor Summary
Constructors Constructor Description NCTestClientBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NCTestClient
build()
Build new configured test client instance.NCTestClientBuilder
newBuilder()
Creates new builder instance with all defaults set.NCTestClientBuilder
setBaseUrl(String baseUrl)
Sets non-default API base URL.NCTestClientBuilder
setEmbeddedMode(boolean embedded)
Sets the embedded probe mode flag.NCTestClientBuilder
setHttpClientSupplier(Supplier<org.apache.http.impl.client.CloseableHttpClient> cliSup)
Sets non-defaultCloseableHttpClient
custom supplier.NCTestClientBuilder
setRequestConfig(org.apache.http.client.config.RequestConfig reqCfg)
Sets optional HTTP REST client configuration parameters.NCTestClientBuilder
setResponseLog(boolean respLog)
Sets whether or not to log responses from the probe.NCTestClientBuilder
setUser(String email, String pswd)
Sets non-default user credentials.
-
-
-
Field Detail
-
DFLT_BASEURL
public static final String DFLT_BASEURL
Default public REST API URL (endpoint).- See Also:
- Constant Field Values
-
DFLT_EMAIL
public static final String DFLT_EMAIL
Default client email.- See Also:
- Constant Field Values
-
DFLT_PASSWORD
public static final String DFLT_PASSWORD
Default client password.- See Also:
- Constant Field Values
-
DFLT_EMBEDDED
public static final boolean DFLT_EMBEDDED
Default embedded mode flag.- See Also:
- Constant Field Values
-
DFLT_RESP_LOG
public static final boolean DFLT_RESP_LOG
Default response log flag.- See Also:
- Constant Field Values
-
DFLT_MAX_WAIT_TIME
public static final long DFLT_MAX_WAIT_TIME
Maximum test time.- See Also:
- Constant Field Values
-
-
Method Detail
-
newBuilder
public NCTestClientBuilder newBuilder()
Creates new builder instance with all defaults set.- Returns:
- Builder instance.
-
setRequestConfig
public NCTestClientBuilder setRequestConfig(org.apache.http.client.config.RequestConfig reqCfg)
Sets optional HTTP REST client configuration parameters.- Parameters:
reqCfg
- HTTP REST client configuration parameters.- Returns:
- Builder instance for chaining calls.
-
setHttpClientSupplier
public NCTestClientBuilder setHttpClientSupplier(Supplier<org.apache.http.impl.client.CloseableHttpClient> cliSup)
Sets non-defaultCloseableHttpClient
custom supplier. By default,CloseableHttpClient
created withHttpClients.createDefault()
.- Parameters:
cliSup
-CloseableHttpClient
custom supplier.- Returns:
- Builder instance for chaining calls.
-
setBaseUrl
public NCTestClientBuilder setBaseUrl(String baseUrl)
Sets non-default API base URL. Only change it if your server is not running on localhost. By default,DFLT_BASEURL
is used.- Parameters:
baseUrl
- API base URL.- Returns:
- Builder instance for chaining calls.
-
setUser
public NCTestClientBuilder setUser(String email, String pswd)
Sets non-default user credentials. By default,DFLT_EMAIL
andDFLT_PASSWORD
are used and they match the default NLPCraft server user.- Parameters:
email
- User email.pswd
- User password.- Returns:
- Builder instance for chaining calls.
-
setEmbeddedMode
public NCTestClientBuilder setEmbeddedMode(boolean embedded)
Sets the embedded probe mode flag. Default value isDFLT_EMBEDDED
. If set totrue
the test client will expect theembedded probe
running in the same JVM and will use local callbacks for quicker results instead of a full REST round trip.- Parameters:
embedded
- Embedded probe mode flag.- Returns:
- Builder instance for chaining calls.
- See Also:
NCEmbeddedProbe
-
setResponseLog
public NCTestClientBuilder setResponseLog(boolean respLog)
Sets whether or not to log responses from the probe. Default value isDFLT_RESP_LOG
.- Parameters:
respLog
-true
to log responses,false
otherwise.- Returns:
- Builder instance for chaining calls.
-
build
public NCTestClient build()
Build new configured test client instance.- Returns:
- Newly built test client instance.
-
-