mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-25 23:44:54 +01:00
fix tests
This commit is contained in:
parent
1a7bae563e
commit
0f3d4856d2
@ -37,6 +37,7 @@ public class LabelValidator implements Validator {
|
|||||||
private void validateLabel(@NotNull final Label label, @NotNull final Errors errors) {
|
private void validateLabel(@NotNull final Label label, @NotNull final Errors errors) {
|
||||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", Messages.FIELD_REQUIRED);
|
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", Messages.FIELD_REQUIRED);
|
||||||
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "color", Messages.FIELD_REQUIRED);
|
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "color", Messages.FIELD_REQUIRED);
|
||||||
|
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "icon", Messages.FIELD_REQUIRED);
|
||||||
final String title = label.getTitle();
|
final String title = label.getTitle();
|
||||||
ValidatorUtils.rejectIfExceeded(
|
ValidatorUtils.rejectIfExceeded(
|
||||||
errors,
|
errors,
|
||||||
|
@ -30,6 +30,7 @@ public class RestLabelITCase {
|
|||||||
|
|
||||||
private String userEmail;
|
private String userEmail;
|
||||||
private static final String COLOR = "#000000";
|
private static final String COLOR = "#000000";
|
||||||
|
private static final String ICON = "glyphicon glyphicon-tag";
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
void createUser() {
|
void createUser() {
|
||||||
@ -45,11 +46,11 @@ public class RestLabelITCase {
|
|||||||
|
|
||||||
// Create a new label
|
// Create a new label
|
||||||
final String title1 = "Label 1 - " + mediaType.toString();
|
final String title1 = "Label 1 - " + mediaType.toString();
|
||||||
addNewLabel(requestHeaders, template, title1, COLOR);
|
addNewLabel(requestHeaders, template, title1, COLOR, ICON);
|
||||||
|
|
||||||
// Create a new label
|
// Create a new label
|
||||||
final String title2 = "Label 2 - " + mediaType.toString();
|
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 ...
|
// Check that the label has been created ...
|
||||||
final RestLabelList restLabelList = getLabels(requestHeaders, template);
|
final RestLabelList restLabelList = getLabels(requestHeaders, template);
|
||||||
@ -83,7 +84,7 @@ public class RestLabelITCase {
|
|||||||
final RestTemplate template = RestHelper.createTemplate( userEmail + ":" + "admin");
|
final RestTemplate template = RestHelper.createTemplate( userEmail + ":" + "admin");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
addNewLabel(requestHeaders, template, null, COLOR);
|
addNewLabel(requestHeaders, template, null, COLOR, ICON);
|
||||||
fail("Wrong response");
|
fail("Wrong response");
|
||||||
} catch (HttpClientErrorException e) {
|
} catch (HttpClientErrorException e) {
|
||||||
final String responseBodyAsString = e.getResponseBodyAsString();
|
final String responseBodyAsString = e.getResponseBodyAsString();
|
||||||
@ -91,12 +92,21 @@ public class RestLabelITCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
addNewLabel(requestHeaders, template, "title12345", null);
|
addNewLabel(requestHeaders, template, "title12345", null, ICON);
|
||||||
fail("Wrong response");
|
fail("Wrong response");
|
||||||
} catch (HttpClientErrorException e) {
|
} catch (HttpClientErrorException e) {
|
||||||
final String responseBodyAsString = e.getResponseBodyAsString();
|
final String responseBodyAsString = e.getResponseBodyAsString();
|
||||||
assert (responseBodyAsString.contains("Required field cannot be left blank"));
|
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")
|
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||||
@ -105,7 +115,7 @@ public class RestLabelITCase {
|
|||||||
final RestTemplate template = RestHelper.createTemplate( userEmail + ":" + "admin");
|
final RestTemplate template = RestHelper.createTemplate( userEmail + ":" + "admin");
|
||||||
|
|
||||||
final String title = "title to delete";
|
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 ...
|
// Now remove it ...
|
||||||
template.delete(RestHelper.HOST_PORT + resourceUri.toString());
|
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();
|
final RestLabel restLabel = new RestLabel();
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
restLabel.setTitle(title);
|
restLabel.setTitle(title);
|
||||||
@ -127,6 +137,9 @@ public class RestLabelITCase {
|
|||||||
if (color != null) {
|
if (color != null) {
|
||||||
restLabel.setColor(color);
|
restLabel.setColor(color);
|
||||||
}
|
}
|
||||||
|
if (icon != null) {
|
||||||
|
restLabel.setIcon(icon);
|
||||||
|
}
|
||||||
|
|
||||||
// Create a new label ...
|
// Create a new label ...
|
||||||
HttpEntity<RestLabel> createUserEntity = new HttpEntity<RestLabel>(restLabel, requestHeaders);
|
HttpEntity<RestLabel> createUserEntity = new HttpEntity<RestLabel>(restLabel, requestHeaders);
|
||||||
|
@ -40,6 +40,7 @@ import static org.testng.Assert.fail;
|
|||||||
public class RestMindmapITCase {
|
public class RestMindmapITCase {
|
||||||
|
|
||||||
private String userEmail = "admin@wisemapping.com";
|
private String userEmail = "admin@wisemapping.com";
|
||||||
|
private static final String ICON = "glyphicon glyphicon-tag";
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
void createUser() {
|
void createUser() {
|
||||||
@ -251,7 +252,7 @@ public class RestMindmapITCase {
|
|||||||
|
|
||||||
// Create a new label
|
// Create a new label
|
||||||
final String titleLabel = "Label 1 - " + mediaType.toString();
|
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 ...
|
// Create a sample map ...
|
||||||
final String mapTitle = "Maps 1 - " + mediaType.toString();
|
final String mapTitle = "Maps 1 - " + mediaType.toString();
|
||||||
|
Loading…
Reference in New Issue
Block a user