diff --git a/wise-webapp/src/main/java/com/wisemapping/validator/LabelValidator.java b/wise-webapp/src/main/java/com/wisemapping/validator/LabelValidator.java index f7f0083f..2dbc2f9a 100644 --- a/wise-webapp/src/main/java/com/wisemapping/validator/LabelValidator.java +++ b/wise-webapp/src/main/java/com/wisemapping/validator/LabelValidator.java @@ -37,6 +37,7 @@ public class LabelValidator implements Validator { private void validateLabel(@NotNull final Label label, @NotNull final Errors errors) { ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", Messages.FIELD_REQUIRED); ValidationUtils.rejectIfEmptyOrWhitespace(errors, "color", Messages.FIELD_REQUIRED); + ValidationUtils.rejectIfEmptyOrWhitespace(errors, "icon", Messages.FIELD_REQUIRED); final String title = label.getTitle(); ValidatorUtils.rejectIfExceeded( errors, diff --git a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestLabelITCase.java b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestLabelITCase.java index 00d7ffcc..0a35304f 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestLabelITCase.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestLabelITCase.java @@ -30,6 +30,7 @@ public class RestLabelITCase { private String userEmail; private static final String COLOR = "#000000"; + private static final String ICON = "glyphicon glyphicon-tag"; @BeforeClass void createUser() { @@ -45,11 +46,11 @@ public class RestLabelITCase { // Create a new label final String title1 = "Label 1 - " + mediaType.toString(); - addNewLabel(requestHeaders, template, title1, COLOR); + addNewLabel(requestHeaders, template, title1, COLOR, ICON); // Create a new label final String title2 = "Label 2 - " + mediaType.toString(); - addNewLabel(requestHeaders, template, title2, COLOR); + addNewLabel(requestHeaders, template, title2, COLOR, ICON); // Check that the label has been created ... final RestLabelList restLabelList = getLabels(requestHeaders, template); @@ -83,7 +84,7 @@ public class RestLabelITCase { final RestTemplate template = RestHelper.createTemplate( userEmail + ":" + "admin"); try { - addNewLabel(requestHeaders, template, null, COLOR); + addNewLabel(requestHeaders, template, null, COLOR, ICON); fail("Wrong response"); } catch (HttpClientErrorException e) { final String responseBodyAsString = e.getResponseBodyAsString(); @@ -91,12 +92,21 @@ public class RestLabelITCase { } try { - addNewLabel(requestHeaders, template, "title12345", null); + addNewLabel(requestHeaders, template, "title12345", null, ICON); fail("Wrong response"); } catch (HttpClientErrorException e) { final String responseBodyAsString = e.getResponseBodyAsString(); assert (responseBodyAsString.contains("Required field cannot be left blank")); } + + try { + addNewLabel(requestHeaders, template, "title12345", COLOR, null); + fail("Wrong response"); + } catch (HttpClientErrorException e) { + final String responseBodyAsString = e.getResponseBodyAsString(); + assert (responseBodyAsString.contains("Required field cannot be left blank")); + } + } @Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function") @@ -105,7 +115,7 @@ public class RestLabelITCase { final RestTemplate template = RestHelper.createTemplate( userEmail + ":" + "admin"); final String title = "title to delete"; - final URI resourceUri = addNewLabel(requestHeaders, template, title, COLOR); + final URI resourceUri = addNewLabel(requestHeaders, template, title, COLOR, ICON); // Now remove it ... template.delete(RestHelper.HOST_PORT + resourceUri.toString()); @@ -119,7 +129,7 @@ public class RestLabelITCase { } - static URI addNewLabel(@NotNull HttpHeaders requestHeaders, @NotNull RestTemplate template, @Nullable String title, @Nullable String color ) throws IOException, WiseMappingException { + static URI addNewLabel(@NotNull HttpHeaders requestHeaders, @NotNull RestTemplate template, @Nullable String title, @Nullable String color, @Nullable String icon) throws IOException, WiseMappingException { final RestLabel restLabel = new RestLabel(); if (title != null) { restLabel.setTitle(title); @@ -127,6 +137,9 @@ public class RestLabelITCase { if (color != null) { restLabel.setColor(color); } + if (icon != null) { + restLabel.setIcon(icon); + } // Create a new label ... HttpEntity createUserEntity = new HttpEntity(restLabel, requestHeaders); diff --git a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapITCase.java b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapITCase.java index b083feb2..7316dfff 100644 --- a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapITCase.java +++ b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapITCase.java @@ -40,6 +40,7 @@ import static org.testng.Assert.fail; public class RestMindmapITCase { private String userEmail = "admin@wisemapping.com"; + private static final String ICON = "glyphicon glyphicon-tag"; @BeforeClass void createUser() { @@ -251,7 +252,7 @@ public class RestMindmapITCase { // Create a new label final String titleLabel = "Label 1 - " + mediaType.toString(); - final URI labelUri = RestLabelITCase.addNewLabel(requestHeaders, template, titleLabel, COLOR); + final URI labelUri = RestLabelITCase.addNewLabel(requestHeaders, template, titleLabel, COLOR, ICON); // Create a sample map ... final String mapTitle = "Maps 1 - " + mediaType.toString();