Fix label test.

This commit is contained in:
Paulo Gustavo Veiga 2024-01-23 22:31:46 -08:00
parent 740da238fa
commit 1059643b0f
4 changed files with 10 additions and 15 deletions

View File

@ -90,7 +90,7 @@ public class Label implements Serializable {
return color;
}
public void setColor(@NotNull String color) {
public void setColor(String color) {
this.color = color;
}

View File

@ -56,7 +56,7 @@ public class RestLabel {
label.setTitle(title);
}
public void setColor(@NotNull final String color) {
public void setColor(final String color) {
label.setColor(color);
}

View File

@ -63,18 +63,13 @@ public class LabelValidator implements Validator {
title,
Constants.MAX_LABEL_NAME_LENGTH);
ValidatorUtils.rejectIfEmptyOrWhitespace(
errors,
"title",
"Label title can not be empty",
title);
final User user = com.wisemapping.security.Utils.getUser();
assert user != null;
if (user != null && title != null) {
final Label foundLabel = service.getLabelByTitle(title, user);
if (foundLabel != null) {
errors.rejectValue("title", Messages.LABEL_TITLE_ALREADY_EXISTS);
}
}
}
}

View File

@ -94,14 +94,14 @@ public class RestLabelControllerTest {
addNewLabel(requestHeaders, restTemplate, null, COLOR);
fail("Wrong response");
} catch (IllegalStateException e) {
assertTrue(e.getMessage().contains("Required field cannot be left blank"));
assertTrue(e.getMessage().contains("Required field cannot be left blank"), e.getMessage());
}
try {
addNewLabel(requestHeaders, restTemplate, "title12345", null);
fail("Wrong response");
} catch (IllegalStateException e) {
assertTrue(e.getMessage().contains("Required field cannot be left blank"));
assertTrue(e.getMessage().contains("Required field cannot be left blank"), e.getMessage());
}
}