共用方式為


TestResourceNamer Class

public class TestResourceNamer
extends ResourceNamer

Provides random string names. If the test mode is PLAYBACK, then names are fetched from the recording. If the test mode is RECORD, then the names are randomly generated and persisted to the recording.

Constructor Summary

Constructor Description
TestResourceNamer(TestContextManager testContextManager, RecordedData storage)

Constructor of TestResourceNamer

TestResourceNamer(TestContextManager testContextManager, Consumer<String> storeVariable, Supplier<String> getVariable)

Constrctor of TestResourceNamer

TestResourceNamer(String name, TestMode testMode, RecordedData storage)

Deprecated

Constructor of TestResourceNamer

Method Summary

Modifier and Type Method and Description
OffsetDateTime now()

Gets an OffsetDateTime of UTC now.

String randomName(String prefix, int maxLen)

Gets a random name.

String randomUuid()

Gets a random UUID.

String recordValueFromConfig(String value)

Record the value into storage, and pop it up when playback.

Methods inherited from ResourceNamer

Methods inherited from java.lang.Object

Constructor Details

TestResourceNamer

public TestResourceNamer(TestContextManager testContextManager, RecordedData storage)

Constructor of TestResourceNamer

Parameters:

testContextManager - Contextual information about the test being ran, such as test name, TestMode, and others.
storage - the recorded data with list of network call

TestResourceNamer

public TestResourceNamer(TestContextManager testContextManager, Consumer storeVariable, Supplier getVariable)

Constrctor of TestResourceNamer

Parameters:

testContextManager - Contextual information about the test being run, such as test name, TestMode, and others.
storeVariable - A Consumer for storing random variables into a recording.
getVariable - a Supplier for retrieving random variables from a recording.

TestResourceNamer

@Deprecated
public TestResourceNamer(String name, TestMode testMode, RecordedData storage)

Deprecated

Constructor of TestResourceNamer

Parameters:

name - test name as prefix
testMode - The TestMode which the test is running in.
storage - the recorded data with list of network call

Method Details

now

public OffsetDateTime now()

Gets an OffsetDateTime of UTC now.

Returns:

OffsetDateTime of UTC now.

randomName

public String randomName(String prefix, int maxLen)

Gets a random name.

Overrides:

TestResourceNamer.randomName(String prefix, int maxLen)

Parameters:

prefix - the prefix to be used if possible
maxLen - the max length for the random generated name

Returns:

the random name

randomUuid

public String randomUuid()

Gets a random UUID.

Overrides:

TestResourceNamer.randomUuid()

Returns:

A random UUID.

recordValueFromConfig

public String recordValueFromConfig(String value)

Record the value into storage, and pop it up when playback.

Parameters:

value - the value needs to record.

Returns:

the recorded value.

Applies to