Passing list of values to Cucumber scenario outline - cucumber

I have a scenario to validate 100 employee names, The QueryString will return them in xml format.All I want to do is to validate all the employee names in an Assertion statement like given below. Instead of adding each name in the Scenario Outline Example, Is it possible to send a list of 100 employee names as input so that I can Iterate through them in java and could easily validate in Assertion condition. Please advice.
Scenario Outline: When the User queries for employee information, the correct records are returned
Given the webservice is running
When the User queries for employee information "<QueryString>"
Then the User receives correct data "<Name>"
Examples:
|QueryString|Name|
|Some localhost url|Peter|
|Some localhost url|Sam|
.
.
#Then("^the User receives correct data\"([^\"]*)\"$")
public void the_user_receives_correct_data(String arg1) throws Throwable {
queryResultPage = selenium.getPageSource();
assertTrue(queryResultPage.contains(arg1));
}

so i will answere here to LINGS comment
What you can do, is use these filenames in your step definition to load the files in your code. Cucumber doesnt support direct file loading as far as i know.
i use something like this to locate full ressource pathes for my relative path file names:
public static String getAbsoluteResourcePath(String resourcePath) {
if (SystemUtils.IS_OS_WINDOWS) {
return Utils.class.getResource(resourcePath).getPath().substring(1).replace("/", File.separator);
} else {
return Utils.class.getResource(resourcePath).getPath().replace("/", File.separator);
}
}
The resourcePath should then be your relative file path

What you are looking for is external test data support, which is supported with QAF. You can use any inbuilt data provider with interceptor to modify data set or custom data provider.
If you are using cucumber version 5+ you can use qaf-cucumber that will give you all qaf features with cucumber. For lower version you can run your existing feature files with QAF runner.

Related

Cucumber - gherkin : Scenario outliner : scenario.log for each outliner iteration

I would like to log on to the cucumber report ids generate on the cucumber steps.
to do this I have saved the scenario on the Hook files
public void beforeUITest(Scenario scenario) {
test.scenario = scenario;
and later in the code, I use the code to log the ids that I need :
test.scenario.log(ids);
this work perfectly if we are using simple scenario.
But when Scenario outliner is used all the ids is logged under the same example and not splitted on different execution
Scenario Outline AAAA <testDetails>
Hooks
Steps
When a new file FileName
Output 1
E2EDHZBPBWW
E2EGQZ2UHJA
E2E5FFFHMLG
E2ECIKJXRHX
E2ETR6BAXOV
Then a dddd
the above ids must be once for each example

Does jOOQ support putting names on SQL statements?

Is there a way to "tag" or put names on SQL statements in jOOQ so when I look at the Performance Insights of AWS RDS, I can see something more meaningful than the first 500 chars of the statement?
For example, Performance Insights shows that this query is taking a toll in my DB:
select "my_schema"."custs"."id", "my_schema"."custs"."other_id", "my_schema"."custs"."cid_id", "my_schema"."custs"."valid_since", "my_schema"."custs"."valid_until", "my_schema"."custs"."address", "my_schema"."custs"."address_id_1", "my_schema"."pets"."id", "my_schema"."pets"."cst_id", "my_schema"."pets"."tag", "my_schema"."pets"."name", "my_schema"."pets"."description", "my_schema"."pets"."owner", "my_schema"."pets"."created_on", "my_schema"."pets"."created_by", "my_schema"."pets"."modified_on",
But as it comes chopped, it's not straight-forward to know which jOOQ code generated this.
I would prefer to see something like this:
Customer - Pet Lookup
or:
(Customer - Pet Lookup) select "my_schema"."custs"."id", "my_schema"."custs"."other_id", "my_schema"."custs"."cid_id", "my_schema"."custs"."valid_since", "my_schema"."custs"."valid_until", "my_schema"."custs"."address", "my_schema"."custs"."address_id_1", "my_schema"."pets"."id", "my_schema"."pets"."cst_id", "my_schema"."pets"."tag", "my_schema"."pets"."name", "my_schema"."pets"."description", "my_schema"."pets"."owner", "my_schema"."pets"."created_on", "my_schema"."pets"."created_by", "my_schema"."pets"."modified_on",
There are at least two out of the box approaches to what you want to achieve, both completely vendor agnostic:
1. Use "hints"
jOOQ supports Oracle style hints using the hint() method, at least for SELECT statements. Write something like:
ctx.select(T.A, T.B)
.hint("/* my tag */")
.from(T)
.where(...)
The limitation here is the location of the hint, which is going to be right after the SELECT keyword. Not sure if this will work for your RDBMS.
2. Use an ExecuteListener
You can supply your Configuration with an ExecuteListener, which patches your generated SQL strings with whatever you need to be added:
class MyListener extends DefaultExecuteListener {
// renderEnd() is called after the SQL string is generated, but
// before the prepared statement is created, let alone executed
#Override
public void renderEnd​(ExecuteContext ctx) {
if (mechanismToDetermineIfTaggingIsNeeded())
ctx.sql("/* My tag */ " + ctx.sql());
}
}
Using regular expressions, you can place that tag at any specific location within your SQL string.

Maximo: can i filter the list on multiple criteria of Status field

when i list the inventory, the default setting filters the Status field with "!=OBSOLETE".
Can I put in a command that will not list any items with status of obsolete or pendobs.
or filter the list on 2 different status'
You can filter the list to two different statuses. For that you put something like (without the quotes) "=status1, =status2".
That same trick never worked for me to filter out more than one status. "!=status1, !=status2", for example, would not work.
Saved and default queries can help take care of that if you wish.
If you have access to the Where Clause, you could edit there query to state something like this:
status not in ('obsolete', 'pendobs')
This is the best way I've found to do an exclusive query as opposed to the standard inclusive query.
Out of the box, you can add PENDOBS to the filter so you exclude OBSOLETE and PENDOBS. If you want the behavior of the application to change, you have to edit the Java .class file in this case. Some modules allow you to edit this from Application Designer, but it is strange that Inventory module, requires editing the .class file.
c:\IBM\SMP\maximo\applications\maximo\maximouiweb\webmodule\WEB-INF\classes\psdi\webclient\beans\item\ItemAppBean.class
Below is the relevant Java code. You'd have to edit the Java file and rebuild your maximo.ear for the List view to exclude PENDOBS from the list view.
public void initializeApp()
throws MXException, RemoteException
{
DataBean resultsBean = app.getResultsBean();
Translate translate = MXServer.getMXServer().getMaximoDD().getTranslator();
String status = (new StringBuilder()).append("!=").append(translate.toExternalDefaultValue("ITEMSTATUS", "OBSOLETE", null, null)).toString();
resultsBean.setQbe("status", status);
resultsBean.reset();
super.initializeApp();
}

Incremental loading in Azure Mobile Services

Given the following code:
listView.ItemsSource =
App.azureClient.GetTable<SomeTable>().ToIncrementalLoadingCollection();
We get incremental loading without further changes.
But what if we modify the read.js server side script to e.g. use mssql to query another table instead. What happens to the incremental loading? I'm assuming it breaks; if so, what's needed to support it again?
And what if the query used the untyped version instead, e.g.
App.azureClient.GetTable("SomeTable").ReadAsync(...)
Could incremental loading be somehow supported in this case, or must it be done "by hand" somehow?
Bonus points for insights on how Azure Mobile Services implements incremental loading between the server and the client.
The incremental loading collection works by sending the $top and $skip query parameters (those are also sent when you do a query by using the .Take and .Skip methods in the table). So if you want to modify the read script to do something other than the default behavior, while still maintaining the ability to use that table with an incremental loading collection, you need to take those values into account.
To do that, you can ask for the query components, which will contain the values, as shown below:
function read(query, user, request) {
var queryComponents = query.getComponents();
console.log('query components: ', queryComponents); // useful to see all information
var top = queryComponents.take;
var skip = queryComponents.skip;
// do whatever you want with those values, then call request.respond(...)
}
The way it's implemented at the client is by using a class which implements the ISupportIncrementalLoading interface. You can see it (and the full source code for the client SDKs) in the GitHub repository, or more specifically the MobileServiceIncrementalLoadingCollection class (the method is added as an extension in the MobileServiceIncrementalLoadingCollectionExtensions class).
And the untyped table does not have that method - as you can see in the extension class, it's only added to the typed version of the table.

Storage in LWUIT

Please can someone give me a small sample of how to use the Storage class in LWUIT? I have tried implementing by emulating the system used in the Recipe Hands-on-Lab, but my application does not need to have multiple objects, as it is within the sample.
Recipe sample allows user to add more and more samples, but all I want to do is add ONE entry of information.
Also how do I retrieve the info stored?
com.sun.lwuit.io.Storage.init("MobileApplication1");
if(com.sun.lwuit.io.Storage.isInitialized()) {
com.sun.lwuit.io.Storage.getInstance().writeObject("MobileApplication1","My first string");
String myStr = (String)com.sun.lwuit.io.Storage.getInstance().readObject("MobileApplication1");
System.out.println(myStr);
} else {
System.out.println("Storage not initialized");
}
The above code will create a storage of name 'MobileApplication1', add an object 'My first string' and reads the string.
You can use J2ME record store as well and your record store will always have only 1 record.

Resources