Unable to parse Responce using json path Tester-Jmeter - jmeter

Unable to parse the response which contains "\",
{"Content":"[{\"SummaryID\":\"402014189352\",\"PeriodID\":\"3079\",\"PeriodName\":\"Q3 16\",\"SummaryData\":[{\"SummaryID\":\"402014189352\",\"Date\":\"11\/11\/2016\",\"RawMatrixData\":\"{\\\"LstEstimateInfo\\\":[{\\\"TemplateID\\\":402014189251,\\\"SummaryID\\\":402014189352,\\\"TemplateName\\\":\\\"Template_201611119\\\",\\\"TemplateDate\\\":\\\"11\/11\/2016 08:48:09\\\",\\\"SelfServe\\\":true}],\\\"LstPeriodList\\\":[{\\\"PeriodName\\\":\\\"Q1

Try using Regular Expression Extractor and BeanShell Post Processor.
Steps As follows:
Add the following regex in the Regular Expression Extractor (to retrieve date value):
"Date\\":\\"(.*?)"
Add BeanShell Code as follows (to remove "\", in the first match):
String str1=vars.get("date_1").toString();
log.info("Before " + str1);
String temp = str1.replace("\\","");
log.info("After " + temp);
vars.put("date_formatted", temp);
Image references:
1. RegEx Extractor
2. BeanShell
3. View Results Tree

String str1=vars.get("SummaryID").toString();
String str2=vars.get("TemplateID").toString();
log.info("Before " + str1);
log.info("Before " + str2);
java.lang.String temp = str1.replace("\\","");
java.lang.String temp1 = str2.replace("\\","");
log.info("After " + temp);
log.info("After " + temp1);
vars.put("date_format1", temp);
vars.put("date_format2", temp1);
Tried above code, remove "\", when i want to pass ${SummaryID_1} then post request doesnt works.

Related

cypress use value outside .then() block

i have a case where i enter a searchTerm to a search field. Then I want to count the results shown to randomly select one of the entries. But I cannot realize it with cypress
let countOfElements = "";
cy.get(this.SEARCH_RESULT + ' > a').then($elements => {
countOfElements = $elements.length;
cy.log(countOfElements)
cy.log("Found " + countOfElements + " results for search term + " + searchTerm)
});
cy.get(this.SEARCH_RESULT + ' > a').invoke('val').as('searchEntries')
//This is obviosly not working, but I don't get how to fix this.
let randomNumber = this.getRandomNumberBetweenTwoValues(0, cy.get('#searchEntries')));
cy.get(this.SEARCH_RESULT + ' > a').eq(randomNumber).click()
I tried different things, like storing the value with .as() but I never seem to have access to the value outside a .then() block. So how I can use the value in my "getRandomNumber..." function to decide with entry in the result list shall be selected?
Pls help. thx
let countOfElements = "";
cy.get(this.SEARCH_RESULT + ' > a').then($elements => {
countOfElements = $elements.length;
cy.log(countOfElements)
cy.log("Found " + countOfElements + " results for search term + " + searchTerm)
});
cy.get(this.SEARCH_RESULT + ' > a').invoke('val').as('searchEntries')
//This is obviosly not working, but I don't get how to fix this.
let randomNumber = getRandomNumberBetweenTwoValues(0, this.searchEntries);
cy.get(this.SEARCH_RESULT + ' > a').eq(randomNumber).click()
Something like this could work. If this.searchEntries give undefined error then make the block function(){} instead of ()=>{}

Elasticsearch 5.x setQuery deprecated

I have a question regarding the last version of Elasticsearch.
Until the previous version I was using the following Java API search:
SearchRequestBuilder request = client.prepareSearch(index).setSource(jsonQuery)
Now setSource is deprecated and it is recommended to use setQuery(QueryBuilder) instead.
Is it possible to pass the whole json query as before?
This is the query syntax I was using and I would like to keep if it is possible:
"{"
+ "\"query\": {"
+ " \"bool\": {"
+ " \"filter\": { ... }"
+ " }"
+ " },"
+ " \"fields\": ["
+ " \"xxx\","
+ " ],"
+ " \"size\": 1000"
+ "}";
I do not want to split body, fields and size using:
setQuery(QueryBuilders.wrapperQuery(jsonQuery)).setSize(size).storedFields(fields)
Yes, you can use QueryBuilders.wrapperQuery() which will create an instance of WrapperQueryBuilder in order to achieve this:
SearchRequestBuilder request = client.prepareSearch(index)
.setQuery(QueryBuilders.wrapperQuery(jsonQuery))
.setSize(1000)
.fields("xxx1", "xxx2");

Wrong Answer while doing concatenation in an ashx page

string name = id + '_' + pos + '_' + nextid;
This is my code in an .ashx page. My expected result is name=1_12_2 and i am getting it as name=2062.

SELECT * INTO Incomplete Query Clause

I seem to be doing something wrong in my OleDbCommand, but I don't know what it is. I am trying to create another table in my access database that is exactly the same as the first but with a different name, by copying everything from one and using SELECT INTO. I don't know why it doesn't work.
OleDbCommand copyAttendanceCommand = new OleDbCommand("SELECT * INTO '" + "Attendance " + DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + DateTime.Now.Year + "' FROM Attendance",loginForm.connection);
copyAttendanceCommand.ExecuteNonQuery();
The Error message that I get says "Syntax error in query. Incomplete query clause." Does anyone know what that means?
Table or field names with spaces are not specified with '' around them, but with square brackets.
Your command should be:
"SELECT * INTO [Attendance " + DateTime.Now.Day + "/" + DateTime.Now.Month + "/"
+ DateTime.Now.Year + "] FROM Attendance"
You may even format your date to make the code more readable:
string today = DateTime.Today.ToString("d'/'M'/'yyyy");
string sql ="SELECT * INTO [Attendance " + today + "] FROM Attendance";
OleDbCommand copyAttendanceCommand = new OleDbCommand(sql, loginForm.connection);
copyAttendanceCommand.ExecuteNonQuery();

How to insert line break in a return statement for D3

I have the following code d3 code:
tooltip.select("#popupCount").text(function(){
if (varToGraph == "rough_top_cost"){
return " " + textValue + ": $" + addCommas(allCountyData[countyName][varToGraph]) + "\n" +
"Count:"
}})
I want the word count to appear on a new line. However, the above code results in everything being on one line. How can I get the output to be on two lines?
Thanks,
AH
Untested answer, but FWIW this may get close;
tooltip.select("#popupCount").html(function(){
if (varToGraph == "rough_top_cost"){
return " " + textValue + ": <br/>$" + addCommas(allCountyData[countyName][varToGraph]) + "\n" +
"Count:"
}})
Working from the example provided on page 80 of D3 Tips and Tricks which includes tooltips with line breaks.
Uses html element instead of text which allows line breaks. Check out the document for more detail.

Resources