}
private QualityProfileDto doCreate(DbSession dbSession, QProfileName name) {
+ if (StringUtils.isEmpty(name.getName())) {
+ throw new BadRequestException("quality_profiles.profile_name_cant_be_blank");
+ }
Date now = new Date();
for (int i = 0; i < 20; i++) {
String key = Slug.slugify(String.format("%s %s %s", name.getLanguage(), name.getName(), RandomStringUtils.randomNumeric(5)));
import static org.fest.assertions.Assertions.assertThat;
import static org.fest.assertions.Fail.fail;
-import static org.sonar.server.qualityprofile.QProfileTesting.*;
+import static org.sonar.server.qualityprofile.QProfileTesting.XOO_P1_KEY;
+import static org.sonar.server.qualityprofile.QProfileTesting.XOO_P2_KEY;
+import static org.sonar.server.qualityprofile.QProfileTesting.XOO_P3_KEY;
public class QProfileFactoryMediumTest {
assertThat(db.qualityProfileDao().findAll(dbSession)).hasSize(1);
}
+ @Test
+ public void fail_to_create_if_name_empty() {
+ QProfileName name = new QProfileName("xoo", null);
+ try {
+ factory.create(dbSession, name);
+ fail();
+ } catch (BadRequestException e) {
+ assertThat(e).hasMessage("quality_profiles.profile_name_cant_be_blank");
+ }
+
+ name = new QProfileName("xoo", "");
+ try {
+ factory.create(dbSession, name);
+ fail();
+ } catch (BadRequestException e) {
+ assertThat(e).hasMessage("quality_profiles.profile_name_cant_be_blank");
+ }
+ }
+
+
@Test
public void fail_to_create_if_already_exists() {
QProfileName name = new QProfileName("xoo", "P1");