You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've created a custom Task for a REST API interaction. In one instance, I want to send the request with a pathParameter (of the processInstanceId) only and in another instance, I want to send the request with the pathParameter (of the processInstanceId) as well as 2 query parameters (firstResult and maxResults). Now because I have these 2 slightly different situations, I want to be able to modify the value of the @Step annotation so that I don't see this in my report:
Below you can see my custom Task code and notice the stepString class attribute. I hoped that this solution would allow me to have a flexible @Step annotation, depending on which method (withId() or withIdAndQueryParams()) was called, but I get the error The value for annotation attribute Step.value must be a constant expression. Is there any way that I can modify the Step value depending on which method is called?
publicclassGetSubtasksForProcessInstanceimplementsTask {
privatestaticfinalStringSERVICE_BASEURL = {myServiceBaseUrl}
privatefinalStringprocessInstanceid;
privatefinalStringfirstResult;
privatefinalStringmaxResults;
privatefinalStringstepString;
publicGetSubtasksForProcessInstance(StringprocessInstanceid) {
this.processInstanceid = processInstanceid;
this.firstResult = null;
this.maxResults = null;
this.stepString = "{0} fetches the Subtasks associated with the process instance with id: #processInstanceid";
}
publicstaticGetSubtasksForProcessInstancewithId(StringprocessInstanceid) {
returninstrumented(GetSubtasksForProcessInstance.class, processInstanceid);
}
publicGetSubtasksForProcessInstance(StringprocessInstanceid, StringfirstResult, StringmaxResults) {
this.processInstanceid = processInstanceid;
this.firstResult = firstResult;
this.maxResults = maxResults;
this.stepString = "{0} fetches the Subtasks associated with the process instance with id:#processInstanceid and query parameters firstResult:#firstResult and maxResults:#maxResults";
}
publicstaticGetSubtasksForProcessInstancewithIdAndQueryParams(StringprocessInstanceid, StringfirstResult, StringmaxResults) {
returninstrumented(GetSubtasksForProcessInstance.class, processInstanceid, firstResult, maxResults);
}
@Override@Step(this.stepString)
public <TextendsActor> voidperformAs(Tactor) {
actor.can(CallAnApi.at(SERVICE_BASEURL));
if ((firstResult == null) && (maxResults == null)) {
actor.attemptsTo(
Get.resource("/{processInstanceId}/subtasks")
.with(request -> request
.pathParam("processInstanceId", processInstanceid)));
} else {
actor.attemptsTo(
Get.resource("/{processInstanceId}/subtasks")
.with(request -> request
.pathParam("processInstanceId", processInstanceid)
.queryParam("firstResult", firstResult)
.queryParam("maxResults", maxResults)));
}
}
}
The text was updated successfully, but these errors were encountered:
I've created a custom Task for a REST API interaction. In one instance, I want to send the request with a pathParameter (of the
processInstanceId
) only and in another instance, I want to send the request with the pathParameter (of theprocessInstanceId
) as well as 2 query parameters (firstResult
andmaxResults
). Now because I have these 2 slightly different situations, I want to be able to modify the value of the@Step
annotation so that I don't see this in my report:Below you can see my custom Task code and notice the
stepString
class attribute. I hoped that this solution would allow me to have a flexible@Step
annotation, depending on which method (withId()
orwithIdAndQueryParams()
) was called, but I get the errorThe value for annotation attribute Step.value must be a constant expression
. Is there any way that I can modify theStep
value depending on which method is called?The text was updated successfully, but these errors were encountered: