You can use the same step but you need to adjust a bit:
For e.g.
@When("I try and set the status to $status)
public void tryAndSetStatus(String statuts) {
// do some stuff you need
ResponseEntity<UserResource> updatedUserResponse = // your post with status
Serenity.setSession("updatedUser").to(updatedUserResponse.getBody());
Serenity.setSession("statusCode").to(updatedUserResponse.getStatusCode());
} catch (HttpClientErrorException e) {
Serenity.setSession("statusCode").to(getStatusCode());
}
}
@Then("The status is changed correctly")
public void thenTheStatusIsChangedCorrectly() {
HttpStatus statusCode = (HttpStatus) Serenity.getCurrentSession().get("statusCode");
assertEquals(HttpStatus.OK, statusCode);
// other asserts ... probably on the updatedUser resource data
}
@Then("The status change request fails with a bad request")
public void thenIGetABadRequest() {
HttpStatus statusCode = (HttpStatus) Serenity.getCurrentSession().get("statusCode");
assertEquals(HttpStatus.BAD_REQUEST, statusCode);
}
I don't know if this is exactly what you are looking for but you can user the when step with any of the 2 then steps and depending on the param you send you can get a positive or a negative test case. Hope this helps.