Compare a Context inside Adapter with an Activity's context - android-adapter

I'm tring to evaluate if the Context inside the WordAdapter at a given time is the same as the Context of a given activity.
For me, the expression inside the 'If' should evaluate to 'TRUE', but it is not. How should I do this?

Alright! I got a way to do what i need:

Related

Use IF function to check if parameter is set without having to also create a condition

I want to do this: https://cloudonaut.io/optional-parameter-in-cloudformation/
Basically just want to use IF to check if a parameter was set at deploy time
But I really resent having to create this weird middle-man "condition" for this. It's very convoluted, not readable, and I'll need to do it for every param I add that I want this behaviour for, so it's not scalable either.
Is there any way to just set the default value of a param to False and use IF to see if it was set without creating this weird "condition" thing?
Unfortunately, this is not support. From docs Fn::If requires the first argument to be condition:
A reference to a condition in the Conditions section. Use the condition's name to reference it.

Jmeter: unable to use multiple conditional statements in If Controller

ANSWER TO THE QUESTION
Please, dear reader, if you wish, you can proceed further and read through the question. But at the most top I'm willing to provide Dmitri's answer, so that others won't waste time playing around with Jmeter If Controller.
If you wish to use multiple condition statement in If Controller,
specifically if you want to check that variables equal some strings,
DON'T USE ${__javaScript()} FUNTION!!! Dmitri suggested to use instead
${__groovy()} function, which worked in my situation. Correct syntax
below. Pay attention to opening parenthesis, comma location and closing curly brackets:
${__groovy((vars.get('yourVariable').equals('someString') &&
vars.get('yourAnotherVariable').equals('someOtherString')),)}
Addition
If you want to save your time while trying to make If Controller working with multiple conditions, always uncheck Interpret Condition as Variable Expression checkbox. Otherwise you will have to stuck with those __javaScript, __groovy or other functions, as there is no way to understand how the hell they suppose to work and why they don't resolve to true or false (log file is always clean at this situation). This is how you do without help of those "functions". Please see my example below
${yourVariable} != 'not_found' && ${youAnotherVariable_matchNr} == 1
That's it, no need to use any functions.
INITIAL QUESTION
In Jmeter v4.0 r 1823414 I can use If Controller only with single statement, but not with multiple. Example of using multiple statements I have taken from here and it was suggested to use
${__javaScript("${responsecode}"=="404")} &&
${__javaScript("${responseMessage}" == "Not Found")}
I have also checked blazemeter tutorial page, but it says nothing about multiple conditional statements inside If Controller.
Example of my Test Plan is below
In my Debug Sampler I can see following
At some place in the Test Plan I put IF Controller to check that both variables are equal to not_found...
${__javaScript(vars.get('manual_bug')=='not_found')} && ${__javaScript(vars.get('integration_bug')=='not_found')}
...so all the subsequent actions are executed. However, this IF Controller either never gets executed or always return FALSE. Not sure what's happening with it.
Before blaming me :-) that I didn't do enough research and rushed to ask a question on SO, I will provide below samples of what I've already tried and that didn't help:
With double quotes around variables
${__javaScript(vars.get("manual_bug")=="not_found")} && ${__javaScript(vars.get("integration_bug")=="not_found")}
With additional space between equal sign
${__javaScript(vars.get('manual_bug') == 'not_found')} &&
${__javaScript(vars.get('integration_bug') == 'not_found')}
Avoid using vars.get
${__javaScript(${manual_bug} == 'not_found')} && ${__javaScript(${integration_bug} == 'not_found')}
Using double quotes without vars.get
${__javaScript(${manual_bug} == "not_found")} && ${__javaScript(${integration_bug} == "not_found")}
My log file looks completely fine, no errors
Please advise if someone was able to execute multiple conditional statements in the Jmeter tool? Thanks!
In the link you're referencing the 2 clauses are in a single __javaScript() function and you have 2 different functions so JMeter doesn't know what does your && means especially given Interpret Condition as Variable Expression? default mode of the If Controller.
Also if you open If Controller GUI you will see the following warning:
For performance it is advised to check "Interpret Condition as Variable Expression"
and use __jexl3 or __groovy evaluating to true or false or a variable that contains true or false.
${JMeterThread.last_sample_ok} can be used to test if last sampler was successful
Therefore I would recommend reconsidering your approach and use __groovy() function, the relevant syntax would be:
${__groovy((vars.get('responseCode').equals('404') && vars.get('responseMessage').equals('Not Found')),)}
Demo:
The following syntax (with double quotes) works too, however it also requires that you uncheck the 'Interpret Condition as Variable Expression' setting.
"${yourVariable}" != "not_found" && "${youAnotherVariable_matchNr}" == "1"

Use of if controller for check condition in jmeter

I need to add a check condition for the search result page that, if a search result is found, the script should run further otherwise it should stop on the same step.
This is my Condition in if controller:
${__javaScript("${depdate}"=! null)}
Here depdate is the regex parameter. If search results are found then its value will be null otherwise it will display content. It's a part of a json string.
I have put all further step in the if controller, but not success. Can anyone help me out of this? What is the reason that this is not working.
What is wrong here with what I am performing?
The reason is that your "${depdate}" will never be null.
If ${depdate} variable is set - it will be variable value
If ${depdate} variable is not set - it will be default value (which is ${depdate}
Demo:
So change your expression to be `${__javaScript(vars.get("depdate") != null)} and everything should start working fine.
See How to Use JMeter's 'IF' Controller and get Pie guide for more information on using IF conditions in your JMeter test.

Regular Expression Extractor not maintaining the variable value

Regex Extractor is working fine at first. I can get it to pull the correct value - a groupID - from the response in the previous HTTP request. And, I turn around and use the variable in the HTTP request immediately after the Extractor. That works great as well. I can see the value in the response was the same as the one placed in the post for the next request.
Few requests later I try to use the variable again when I need the groupID passed again. But, when I look I see the default value I put in the Extractor instead of the value from the response.
My question is two fold: is this extractor only expected to generate a temporary variable?
And, if so, is there a way to plug this variable into something else for later reuse?
Or, did I just miss something?
Well, I found my mistake. It would have helped if I read the information under the post-processor section before I read about the extractor...
I did not have the extractor as a child of the HTTP request. I had it as the next step.
Once I nested it as a child all was right with the world. The variable stays as it was and is not changing after every step.
Lesson learned - RTFM. Or, at least the online documentation a bit more thoroughly!
Jamie

How to check for a value's datatype inside django template?

I want to get the datatype of a value in django template. I am sure there is a way because when you do
value|date:"Y-m-d"
django template understands that the value is timestamp. How does django do it?
the "|date" you see is called a template filter and is a built-in function of django
you may want to create one of your own (here's how) that takes something as input and returns its datatype.
but, imo, it's not a best-practice, since a template should mostly be used to just display and format data. if you need an evaluation on the type i suggest you move that inside a view and return the result in the context, eventually