use of com.axway.ats.agent.core.threading.data.config.UsernameDataConfig in project ats-framework by Axway.
the class LoadClient method executeQueuedActions.
/**
* Execute all queued actions
*
* @throws AgentException
*/
@PublicAtsApi
public void executeQueuedActions() throws AgentException {
configureAgentLoaders();
boolean isThereUsernameConfigurator = false;
boolean isThereUsernameParam = false;
for (ParameterDataConfig dataConfig : loaderDataConfig.getParameterConfigurations()) {
// check if UsernameDataConfigurator is used more than once
if (isThereUsernameConfigurator) {
throw new ActionExecutionException("You have used Username Data Configurator more than once. This is not allowed.");
}
if (dataConfig instanceof UsernameDataConfig) {
isThereUsernameConfigurator = true;
// user names are specified
((UsernameDataConfig) dataConfig).verifyUsernamesAreWEnough(threadingPattern.getThreadCount());
} else if ("username".equals(dataConfig.getParameterName())) {
isThereUsernameParam = true;
}
}
if (isThereUsernameConfigurator && isThereUsernameParam) {
throw new ActionExecutionException("The parameter \"username\" can not be used for another data configurator " + "when Username data configurator is used.");
}
actionQueue.executeQueuedActions(new ArrayList<String>(this.loaderAddresses), threadingPattern, loaderDataConfig);
}
use of com.axway.ats.agent.core.threading.data.config.UsernameDataConfig in project ats-framework by Axway.
the class ParameterDataProviderFactory method createDataProvider.
/**
* Create a data provider based on a configuration provider
*
* @param parameterConfig the configuration based on which to create the provider
* @return the newly created provider
* @throws ParameterDataProviderNotSupportedException if the provider is not supported
* @throws ParameterDataProviderInitalizationException if there is an error during provider initialization
*/
public static ParameterDataProvider createDataProvider(ParameterDataConfig parameterConfig) throws ParameterDataProviderNotSupportedException, ParameterDataProviderInitalizationException {
ParameterDataProvider parameterDataProvider;
Class<?> parameterConfigClass = parameterConfig.getClass();
if (parameterConfigClass == RangeDataConfig.class) {
RangeDataConfig rangeDataConfig = (RangeDataConfig) parameterConfig;
//choose the right one, based on the arguments
if (rangeDataConfig.getStaticValue() != null) {
parameterDataProvider = new StringRangeParameterDataProvider(rangeDataConfig.getParameterName(), rangeDataConfig.getStaticValue(), (Integer) rangeDataConfig.getRangeStart(), (Integer) rangeDataConfig.getRangeEnd(), parameterConfig.getParameterProviderLevel());
} else {
parameterDataProvider = new IntegerRangeParameterDataProvider(rangeDataConfig.getParameterName(), (Integer) rangeDataConfig.getRangeStart(), (Integer) rangeDataConfig.getRangeEnd(), parameterConfig.getParameterProviderLevel());
}
} else if (parameterConfigClass == ListDataConfig.class) {
ListDataConfig listDataConfig = (ListDataConfig) parameterConfig;
parameterDataProvider = new ListParameterDataProvider(listDataConfig.getParameterName(), listDataConfig.getValues(), listDataConfig.getParameterProviderLevel());
} else if (parameterConfigClass == FileNamesDataConfig.class) {
FileNamesDataConfig fileNamesDataConfig = (FileNamesDataConfig) parameterConfig;
parameterDataProvider = new FileNamesParameterDataProvider(fileNamesDataConfig.getParameterName(), fileNamesDataConfig.getFileContainers(), fileNamesDataConfig.getRecursiveSearch(), fileNamesDataConfig.getReturnFullPath(), fileNamesDataConfig.getParameterProviderLevel());
} else if (parameterConfigClass == UsernameDataConfig.class) {
UsernameDataConfig nameDataConfig = (UsernameDataConfig) parameterConfig;
if (nameDataConfig.getValues() != null) {
parameterDataProvider = new ListParameterDataProvider(nameDataConfig.getParameterName(), nameDataConfig.getValues(), nameDataConfig.getParameterProviderLevel(), UsernameDataConfig.class);
} else {
parameterDataProvider = new StringRangeParameterDataProvider(nameDataConfig.getParameterName(), nameDataConfig.getStaticValue(), (Integer) nameDataConfig.getRangeStart(), (Integer) nameDataConfig.getRangeEnd(), parameterConfig.getParameterProviderLevel(), UsernameDataConfig.class);
}
} else if (parameterConfigClass.getGenericSuperclass() == CustomParameterDataConfig.class) {
// custom data provider
CustomParameterDataConfig customDataConfig = (CustomParameterDataConfig) parameterConfig;
try {
// find the constructor of the custom data provider
Constructor<? extends CustomParameterDataProvider> constructor = customDataConfig.getDataProviderClass().getDeclaredConstructor(String.class, Map.class, ParameterProviderLevel.class);
// call the constructor of the custom data provider
parameterDataProvider = (CustomParameterDataProvider) constructor.newInstance(customDataConfig.getParameterName(), customDataConfig.getControlTokens(), customDataConfig.getParameterProviderLevel());
} catch (Exception e) {
throw new ParameterDataProviderNotSupportedException(parameterConfigClass);
}
} else {
throw new ParameterDataProviderNotSupportedException(parameterConfigClass);
}
//initialize the newly created provider
parameterDataProvider.initialize();
//and return it back to the caller
return parameterDataProvider;
}
Aggregations