Interface DataProvider
- All Known Implementing Classes:
GroovyDataProvider
public interface DataProvider
DataProvider is a facility used for getting (reading/generating) data for
Contract test suite.
- Author:
- Dan Vernon
-
Method Summary
Modifier and TypeMethodDescriptionvoid
dispose()
free the allocated resourcesgenerates a random string dynamically.Random generator uses a pattern to generate a random sequence based on given pattern.Gets data value by the specified parametersget
(Class<?> dataTypeName, String name, String componentName, int sequenceNumber, boolean isMultivalue) Gets data value by the specified parametersAcquire a property value for given nameAquire a property value marked with given iteration, for example i1.testPropertygetAttributeSet
(String propertySetName) converts the given property submap to Attribute set.getConnectorAttribute
(String propName) Gets data value by the specified parametersGets data value by the specified parametersGets data value by the specified parametersgetTestSuiteAttribute
(String propName) Gets test suite attributegetTestSuiteAttribute
(String propName, String testName) Gets test suite attributevoid
loadConfiguration
(String propertyName, Configuration cfg) adds to 'cfg' the complete map defined by property 'propertyName'
-
Method Details
-
get
Object get(Class<?> dataTypeName, String name, String componentName, int sequenceNumber, boolean isMultivalue) Gets data value by the specified parameters- Parameters:
dataTypeName
-name
-componentName
-sequenceNumber
-isMultivalue
- switch between single and multivalue query- Returns:
- Throws:
ObjectNotFoundException
-
get
Gets data value by the specified parameters- Parameters:
dataTypeName
-name
-componentName
-- Returns:
- Throws:
ObjectNotFoundException
-
getString
Gets data value by the specified parameters- Parameters:
name
-componentName
-sequenceNumber
-- Returns:
- Throws:
ObjectNotFoundException
-
getString
Gets data value by the specified parameters- Parameters:
name
-componentName
-- Returns:
- Throws:
ObjectNotFoundException
-
getConnectorAttribute
Gets data value by the specified parameters- Parameters:
propName
-- Returns:
- Throws:
ObjectNotFoundException
-
getTestSuiteAttribute
Gets test suite attribute- Parameters:
propName
-- Returns:
- Throws:
ObjectNotFoundException
-
getTestSuiteAttribute
Gets test suite attribute- Parameters:
propName
-- Returns:
- Throws:
ObjectNotFoundException
-
get
Acquire a property value for given name -
get
Aquire a property value marked with given iteration, for example i1.testProperty- Parameters:
name
- the suffixsequenceNumber
-- Returns:
- the property value
-
generate
Random generator uses a pattern to generate a random sequence based on given pattern.
the supported characters are (can appear in pattern string):
- # - numeric
- a - lowercase letter
- A - uppercase letter
- ? - lowercase and uppercase letter
- . - any character
Any other character inside the pattern is directly printed to the output.
Backslash is used to escape any character. For instance pattern "###\\.##" prints a floating point random number
- Parameters:
pattern
- the pattern for generationclazz
- the type of returned random object- Returns:
- randomly generated object with content based on given type.
-
generate
generates a random string dynamically.generate(String, Class)
-
loadConfiguration
adds to 'cfg' the complete map defined by property 'propertyName'- Parameters:
propertyName
- the name of property which represents the submap that will be converted to configurationcfg
- the configuration that will be updated by information from property 'propertyName'Sample usage:
static final String DEFAULT_CONFIGURATINON = "configuration.init" // attempt to create the database in the directory.. config = new ConnectorConfiguration(); // LOAD THE submap in 'configuration' prefix to 'config' object. dataProvider.loadConfiguration(DEFAULT_CONFIGURATINON, config); //////// The groovy configuration // account configurations configuration{ init.driver="foo" init.hostName="bar" init.port="boo" }
- Throws:
NoSuchMethodException
- the Setter method for the property in the configuration does not existIllegalAccessException
InvocationTargetException
SecurityException
-
getAttributeSet
converts the given property submap to Attribute set.- Parameters:
propertySetName
- the property that marks the submap for conversion.- Returns:
- the converted attribute set
Sample usage:
createAttrs = dataProvider.getAttributeSet("account.create"); //////// The groovy configuration // account sets account{ create.driver="foo" create.hostName="bar" create.port="boo" update.driver="foo2" update.hostName="bar2" update.port="boo2" }
-
dispose
void dispose()free the allocated resources
-