I do have the following Test Plan
The "If Controller" raises the following exception :
018-05-30 14:32:30,822 ERROR o.a.j.t.JMeterThread: Test failed!
java.lang.ClassCastException: java.lang.Integer cannot be cast to
java.lang.String
How I can do the int validation ?
Single equal sign is assigning a variable, you need double equal signs to check equality, see If Controller examples
use the condition: ${__jexl3(${VAR} == 23)}
And use similar approach:
${__jexl3(${myCounter} == 24)}
Related
On the attached image - is also a description, i got an null reference exception. I think is very weird
(1) I have declared an Enum (as var) currentBrand. It´s throw an exception.
var currentBrand = _brandService.GetCurrentBrand();
" 'currentBrand' threw an exception of type 'System.NullReferenceException' "
But when i do the same in VS immediate window, it works perfectly.
(2) I call the service and the method, and it return "LB"
_brandService.GetCurrentBrand();
LB
(3) I call the service again and save it in a currentBrandNew Enum variable
var currentBrandNew = _brandService.GetCurrentBrand();
(4) I print the value of currentBrandNew, and the result is as expected.
"LB"
I no idea why (1), the original code throws an exception.
I hope some could point me to some interest way, to figured out this very weird problem (for me :-) )
My Image, with the problem
As result I want to have method with only one string argument (expression A).
But B and C expressions are with same property.
It means 'where date property is null or less_or_equal today'.
So, what I have is this method:
List<EntityObject> findByMyDateIsNullAndMyStringOrMyStringAndMyDateLessThanEqual(Date myDate, String myString);
default List<EntityObject> findByMyDateIsNullAndMyStringOrMyStringAndMyDateLessThanEqual(String myString) {
return findByMyDateIsNullAndMyStringOrMyStringAndMyDateLessThanEqual(Date.valueOf(LocalDate.now()),myString);
}
But, when I try to install in maven, because of test, I get this error:
Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List MyItemRepository.findByMyDateIsNullAndMyStringOrMyStringAndMyDateLessThanEqual(java.sql.Date,java.lang.String)! null
I know the other way is to use #Query with customized query but I prefer this one.
Is it possible?
My colleague helped me, so...
First of all I forget findAll, because it could be more...
Second of all, I need for date IsLessThanEqual...
And third, I need 3 arguments. Only 3 because one is already defined in method name with 'IsNull'. So, I need 2 string arguments and 1 date argument
List<EntityObject> findAllByMyDateIsNullAndMyStringOrMyStringAndMyDateIsLessThanEqual(Date myDate, String myString1, String myString2);
And then I have to call it with predefined value for date less or equal today date
default List<EntityObject> findAllByMyDateIsNullAndMyStringOrMyStringAndMyDateIsLessThanEqual(String string) {
return findAllByMyDateIsNullAndMyStringOrMyStringAndMyDateIsLessThanEqual(Date.valueOf(LocalDate.now()),string,string);
}
I've created this method:
Long getAttributesAfterTimeSent(String x, String y, Long timeSent) {
return repository.countByXAndYAndZTypesAndTimeSentGreaterThanEqual(
x,
y,
new ArrayList<String>() {{ add("attribute1"); add("attribute2"); }},
timeSent);
}
The signature of this method in the repository is as follows:
Long countByXAndYAndZTypesAndTimeSentGreaterThanEqual(String x, String y, Collection<String> attributeTypes, timeSent);
When I run it, i get the following error:
13:18:40.784 [main] INFO o.h.h.i.QueryTranslatorFactoryInitiator - HHH000397: Using ASTQueryTranslatorFactory
13:18:41.014 [main] WARN o.h.e.jdbc.spi.SqlExceptionHelper - SQL Error: 1797, SQLState: 42000
13:18:41.014 [main] ERROR o.h.e.jdbc.spi.SqlExceptionHelper - SQL error: 1797 ORA-01797: this operator must be followed by ANY or ALL
javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
Any pointers?
Figured out the answer.
One of my types was a non-scalar type the: ArrayList.
For cases like this we need to use the IN keyword in the JPA method.
So when changing the method from
countByXAndYAndZTypesAndTimeSentGreaterThanEqual
to
countByXAndYAndZTypesInAndTimeSentGreaterThanEqual
it worked like charm.
This almost certainly has nothing to do with the number of AND phrases in your method.
The limit is only implicit through something like maximum method name length, maximum query length, maximum number of parameters.
It will be way higher than anything any sane person will try to cram in a single method name.
The cause of the exception you are seeing is:
CAUSE:
equal operator = followed by multiple value like (1,2)
This probably means: one of the parameters or maybe some of the attributes is not of scalar type, but some kind of collection or array.
If these leads you toward something you can't easily express through a method name use a #Query annotation and provide the exact query you need to execute.
I pass Integer.MIN_VALUE in some Javascript that just returns the input. However, it seems that when I compare the result of the Javascript by using ScriptValueConverter.unwrapValue(returnedObject), the value is the same but the type is a double while I am expecting an integer.
However when I pass Integer.MAX_VALUE in, I do get an integer.
From what I understand, Nashorn uses optimistic type casting so in my eyes, MIN_VALUE can still be an int, there's no need for it to be a double
I suppose that the problem is not Nashorn itself but the javascript code you are running or the third party converter you are using (ScriptValueConverter is neither a javax.script nor a jdk.nashorn class).
I've run the following code:
ScriptEngine jsEngine = new ScriptEngineManager().getEngineByName("nashorn");
jsEngine.eval("function identity(x) {return x;}");
System.out.println("Integer.MIN_VALUE:" + ((Invocable) jsEngine).invokeFunction("identity", Integer.MIN_VALUE).getClass());
System.out.println("Integer.MAX_VALUE:" +((Invocable) jsEngine).invokeFunction("identity", Integer.MAX_VALUE).getClass());
and the output is:
Integer.MIN_VALUE: class java.lang.Integer
Integer.MAX_VALUE: class java.lang.Integer
Here you can find a brief explanation about nashorn type conversions.
This is the declaration for save_g
public static IsolatedStorageSettings save_g = IsolatedStorageSettings.ApplicationSettings;
here cons.term[7] is of type string
save_g[cons.term[7]] = (double)save_g[cons.term[7]] + 1;
The statement above executes with no problem on the emulator. But when I run it on device (Lumia 820) it gives error.
A first chance exception of type 'System.InvalidCastException' occurred in PhoneApp2.DLL
An exception of type 'System.InvalidCastException' occurred in PhoneApp2.DLL but was not handled in user code
And I have no idea whats wrong.
Plz help.
The invalid cast exception means that save_g[cons.term[7]] isn't a double. The value is most likely null. You should check the part of the code that assigns a value to save_g[cons.term[7]] for the first time.
If it's the only place where you assign this value, you should add code to handle this case:
double value = save_g[cons.term[7]] == null ? 0 : save_g[cons.term[7]];
save_g[cons.term[7]] = value + 1;