Class TestResourceNamer
- java.lang.Object
-
- com.azure.android.core.test.utils.ResourceNamer
-
- com.azure.android.core.test.utils.TestResourceNamer
-
public class TestResourceNamer extends ResourceNamer
Provides random string names. If the test mode isTestMode.PLAYBACK
, then names are fetched fromRecordedData
. If the test mode isTestMode.RECORD
, then the names are randomly generated and persisted toRecordedData
.
-
-
Constructor Summary
Constructors Constructor Description TestResourceNamer(TestContextManager testContextManager, RecordedData recordedData)
Constructor of TestResourceNamerTestResourceNamer(java.lang.String name, TestMode testMode, RecordedData recordedData)
Deprecated.UseTestResourceNamer(TestContextManager, RecordedData)
instead.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.threeten.bp.OffsetDateTime
now()
Gets an OffsetDateTime of UTC now.java.lang.String
randomName(java.lang.String prefix, int maxLen)
Gets a random name.java.lang.String
randomUuid()
Gets a random UUID.java.lang.String
recordValueFromConfig(java.lang.String value)
Record the value into recordedData, and pop it up when playback.
-
-
-
Constructor Detail
-
TestResourceNamer
@Deprecated public TestResourceNamer(java.lang.String name, TestMode testMode, RecordedData recordedData)
Deprecated.UseTestResourceNamer(TestContextManager, RecordedData)
instead.Constructor of TestResourceNamer- Parameters:
name
- test name as prefixtestMode
- TheTestMode
which the test is running in.recordedData
- the recorded data with list of network call
-
TestResourceNamer
public TestResourceNamer(TestContextManager testContextManager, RecordedData recordedData)
Constructor of TestResourceNamer- Parameters:
testContextManager
- Contextual information about the test being ran, such as test name,TestMode
, and others.recordedData
- the recorded data with list of network call- Throws:
java.lang.NullPointerException
- IftestMode
isn'tTestMode.LIVE
,doNotRecord
isfalse
, andrecordedData
isnull
.
-
-
Method Detail
-
randomName
public java.lang.String randomName(java.lang.String prefix, int maxLen)
Gets a random name.- Overrides:
randomName
in classResourceNamer
- Parameters:
prefix
- the prefix to be used if possiblemaxLen
- the max length for the random generated name- Returns:
- the random name
-
randomUuid
public java.lang.String randomUuid()
Gets a random UUID.- Overrides:
randomUuid
in classResourceNamer
- Returns:
- A random UUID.
-
now
public org.threeten.bp.OffsetDateTime now()
Gets an OffsetDateTime of UTC now.- Returns:
- OffsetDateTime of UTC now.
-
recordValueFromConfig
public java.lang.String recordValueFromConfig(java.lang.String value)
Record the value into recordedData, and pop it up when playback.- Parameters:
value
- the value needs to record.- Returns:
- the recorded value.
-
-