private GenerateWsRequest toCreateWsRequest(Request request) {
GenerateWsRequest generateWsRequest = new GenerateWsRequest()
.setLogin(request.param(PARAM_LOGIN))
- .setName(request.mandatoryParam(PARAM_NAME));
+ .setName(request.mandatoryParam(PARAM_NAME).trim());
if (generateWsRequest.getLogin() == null) {
generateWsRequest.setLogin(userSession.getLogin());
}
+ checkRequest(!generateWsRequest.getName().isEmpty(), "The '%s' parameter must not be blank", PARAM_NAME);
+
return generateWsRequest;
}
newRequest("unknown-login", "any-name");
}
+ @Test
+ public void fail_if_name_is_blank() {
+ expectedException.expect(BadRequestException.class);
+ expectedException.expectMessage("The 'name' parameter must not be blank");
+
+ newRequest(GRACE_HOPPER, " ");
+ }
+
@Test
public void fail_if_token_with_same_login_and_name_exists() {
newRequest(GRACE_HOPPER, TOKEN_NAME);