Use multiple tags in Cucumber without RunWith annotation [duplicate] - tags

This question already has answers here:
Cucumber tags: Type mismatch: cannot convert from String[] to String
(2 answers)
Closed 1 year ago.
I have prepared one runner class, where I don't want to use JUnit
#CucumberOptions(
plugin = {"pretty",
"html:target/cucumber-reports/cucumber.html",
"json:target/cucumber-reports/cucumber.json"
},
features = {"src/test/resources/features"},
glue = {"test.demo.steps"},
tags = "#world", "#hello"
)
public class TestRunner extends AbstractTestNGCucumberTests {
}
Here if I write
tags = {"#world", "#hello"} then error is Type mismatch: cannot convert from String[] to String
and if I write
tags = "#world", "#hello", then it doesn't not work and gives error Syntax error on token ""#hello"", invalid MemberValuePair .
So, how can I use multiple tags?

You have to use a tag expression. See the docs: https://cucumber.io/docs/cucumber/api/#tags

Related

Dart initializer in constructor [duplicate]

This question already has an answer here:
Is there a difference in how member variables are initialized in Dart?
(1 answer)
Closed 9 months ago.
It looks easy, but not working. I have model in Dart like this:
class FormTab {
String caption;
FormTab(dynamic m) { // where m will be Map
this.caption = m['caption'] ?? "No caption";
}
}
But still I have error message: Non-nullable instance field 'caption' must be initialized. Try adding an initializer expression, or add a field initializer in this constructor, or mark it 'late'.
What is wrong? I set value caption, but still I have error. I tried caption
The body of a constructor in Dart is not part of the initializers. You need to put that into the initializer list:
class FormTab {
String caption;
FormTab(dynamic m) : caption = m['caption'] ?? "No caption";
}
Please note that if you know it's going to be a map, it might be better to make it a map. The earlier you switch from dynamic to actual types, the easier it is to catch errors.

Declaring private variables in a class Google Apps Script V8 [duplicate]

This question already has answers here:
How to declare Class fields
(3 answers)
Closed last year.
I am trying to declare a class with a private variable in Google Apps Script V8 runtime.
Here is the code:
class Exam{
var examName = "";
getExamName(){
return this.examName;
}
}
When I go to save this, I get the following syntax error:
Syntax error: SyntaxError: Unexpected identifier line: 2 file: Code.gs
What am I doing wrong?
That syntax isn't really valid: https://v8.dev/features/class-fields#es2015-class-syntax
So using the correct syntax, your snippet could become:
class Exam {
constructor() {
this._examName = "";
}
get examName() {
return this._examName;
}
set examName(value) {
this._examName = value;
}
}

Validating Proto3 with Scala using Akka-grpc

I am new to Scala. Developing my first scala App with Akka-grpc.
I have defined my proto as below :
message ApiRequest {
string email = 1;
string phone_number = 2;
int32 size = 3;
}
I want to validate my request parameters as here only email is mandatory, rest are optional parameters.
proto2 was having option as required/optional.
So, with proto3 what could be a good and efficient solution to validate those parameters.
Can case class be considered or mapping parameters to Map() and then validating using loop?

Wicket NumberTextField in Kotlin throws ClassCastException when submitted

I'm having some issues with a Wicket (8.0.0-M4) NumberTextField in Kotlin (1.1.0).
My stripped-down form looks like this:
class Test : AbstractWebPage() {
val housenumberModel: Model<Int> = Model<Int>()
val housenumber = NumberTextField<Int>("housenumberModel", housenumberModel)
val form: Form<Unit> = object : Form<Unit>("adressForm") {}
override fun onInitialize() {
super.onInitialize()
form.add(housenumber.setRequired(false))
form.add(object : SubmitLink("submit") {
override fun onSubmit() {
super.onSubmit()
println(housenumberModel.`object`) // this is line 28
}
})
add(form)
}
}
After submitting the form I get the following stacktrace:
java.lang.ClassCastException: java.lang.String cannot be cast to
java.lang.Number
at com.mycompany.test.pages.Test$onInitialize$1.onSubmit(Test.kt:28)
at org.apache.wicket.markup.html.form.Form.delegateSubmit(Form.java:1312)
at org.apache.wicket.markup.html.form.Form.process(Form.java:979)
at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:802)
at org.apache.wicket.markup.html.form.Form.onRequest(Form.java:715)
at org.apache.wicket.core.request.handler.ListenerRequestHandler.internalInvoke(ListenerRequestHandler.java:301)
at org.apache.wicket.core.request.handler.ListenerRequestHandler.invoke(ListenerRequestHandler.java:250)
at org.apache.wicket.core.request.handler.ListenerRequestHandler.invokeListener(ListenerRequestHandler.java:210)
at org.apache.wicket.core.request.handler.ListenerRequestHandler.respond(ListenerRequestHandler.java:203)
at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:912)
at org.apache.wicket.request.RequestHandlerExecutor.execute(RequestHandlerExecutor.java:65)
at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:283)
at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:253)
at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:221)
at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:262)
at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:204)
at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:286)
[...]
If I use
val housenumberModel: Model<Int> = Model.of(0)
instead of
val housenumberModel: Model<Int> = Model<Int>()
everything works fine. But since my NumberTextField is optional I don't want to have it pre-initialized with 0.
Me and my colleagues were trying to change the type signature of the Model in every way we could imagine but came to no solution. A co-worker suggested to write a custom Wicket converter since Kotlins Int is represendeted as a primitive type (From the docs: "On the JVM, non-nullable values of this type are represented as values of the primitive type int.") Even though I don't know yet if this would work it seems like an overkill for me.
Another hack I could think of: writing some JavaScript to delete the zero from the input field. Also not really something I would want to do.
Question: Is there a simple solution to my problem?
(And as a bonus-question: has already anyone written a larger Wicket application in Kotlin and could tell me if this combination is ready for prime time to develop a critical project with this stack or is my problem just the tip of the iceberg?)
[edit]
Solution as pointed out by svenmeier:
Using
val housenumber = NumberTextField<Int>("housenumberModel", housenumberModel, Int::class.java)
works.
Or as an alternative:
val housenumbervalue: Int? = null
val housenumberModel: IModel<Int> = PropertyModel<Int>(this, "housenumbervalue")
val housenumber = NumberTextField<Int>("housenumberModel", housenumberModel)
Because of type erasure your NumberTextField cannot detect the generic type parameter of your model. Since your model object is null, it cannot be used to derive the type either.
In this case Wicket assumes a String model object type :/.
Either provide the type to the NumberTextField explicitly, or use a model that keeps its generic information, e.g. a PropertyModel.
There is a way to tell wicket about the type you want, it is by adding the type in the constructor. More here.
In Java it looks like this:
new NumberTextField<Integer>("housenumberModel", housenumberModel, Integer.class);

How to generate multiple values for a class level annotation using JDT

We are using JDT for generating java source code. We are stuck in generating a class where the class itself is annotated as belows:
#SomeAnnotation({Class1.class, Class2.class})
Please let me know how this can be achieved. I am using NormalAnnotation class for this but could not set the expression accordingly. Though String literals can be set but Class cannot be.
I was able to do this using NormalAnnotation class, here is the code:
// values contains the class names.
NormalAnnotation normalAnnotation = ast.newNormalAnnotation();
Name name = ast.newName(annotationName);
normalAnnotation.setTypeName(name);
ArrayInitializer arrayInit = ast.newArrayInitializer();
for(String value : values){
TypeLiteral tL = ast.newTypeLiteral();
tL.setType(ast.newSimpleType(ast.newName(value)));
arrayInit.expressions().add(tL);
}
MemberValuePair memberValuePair = ast.newMemberValuePair();
memberValuePair.setName(ast.newSimpleName("value"));
memberValuePair.setValue(arrayInit);
normalAnnotation.values().add(memberValuePair);