Merge branch 'develop'

This commit is contained in:
Paulo Gustavo Veiga 2022-02-11 18:09:30 -08:00
commit d567caa61c
6 changed files with 72 additions and 89 deletions

View File

@ -4,7 +4,7 @@
http://maven.apache.org/xsd/maven-4.0.0.xsd"> http://maven.apache.org/xsd/maven-4.0.0.xsd">
<properties> <properties>
<com.wisemapping.version>5.0.2</com.wisemapping.version> <com.wisemapping.version>5.0.4</com.wisemapping.version>
<superpom.dir>${project.basedir}/wise-webapps</superpom.dir> <superpom.dir>${project.basedir}/wise-webapps</superpom.dir>
</properties> </properties>
@ -16,7 +16,7 @@
<groupId>org.wisemapping</groupId> <groupId>org.wisemapping</groupId>
<artifactId>wisemapping</artifactId> <artifactId>wisemapping</artifactId>
<name>WiseMapping Project</name> <name>WiseMapping Project</name>
<version>5.0.2</version> <version>5.0.4</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<licenses> <licenses>

View File

@ -12,7 +12,7 @@
<groupId>org.wisemapping</groupId> <groupId>org.wisemapping</groupId>
<artifactId>wisemapping</artifactId> <artifactId>wisemapping</artifactId>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
<version>5.0.2</version> <version>5.0.4</version>
</parent> </parent>
<build> <build>
@ -33,7 +33,7 @@
</exec> </exec>
<exec executable="tar" dir="target"> <exec executable="tar" dir="target">
<arg value="-xvzf"/> <arg value="-xvzf"/>
<arg value="wisemapping-mindplot-5.0.3.tgz"/> <arg value="wisemapping-mindplot-5.0.4.tgz"/>
<arg value="-C"/> <arg value="-C"/>
<arg value="wisemapping-mindplot"/> <arg value="wisemapping-mindplot"/>
</exec> </exec>
@ -46,7 +46,7 @@
</exec> </exec>
<exec executable="tar" dir="target"> <exec executable="tar" dir="target">
<arg value="-xvzf"/> <arg value="-xvzf"/>
<arg value="wisemapping-webapp-5.0.3.tgz"/> <arg value="wisemapping-webapp-5.0.4.tgz"/>
<arg value="-C"/> <arg value="-C"/>
<arg value="wisemapping-webapp"/> <arg value="wisemapping-webapp"/>
</exec> </exec>

View File

@ -9,7 +9,7 @@
<groupId>org.wisemapping</groupId> <groupId>org.wisemapping</groupId>
<artifactId>wisemapping</artifactId> <artifactId>wisemapping</artifactId>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
<version>5.0.2</version> <version>5.0.4</version>
</parent> </parent>
<repositories> <repositories>

View File

@ -74,7 +74,7 @@ public class MindmapController extends BaseController {
List<Mindmap> mindmaps = mindmapService.findMindmapsByUser(user); List<Mindmap> mindmaps = mindmapService.findMindmapsByUser(user);
mindmaps = mindmaps mindmaps = mindmaps
.stream() .stream()
.filter(m->filter.accept(m, user)) .filter(m -> filter.accept(m, user))
.collect(Collectors.toUnmodifiableList()); .collect(Collectors.toUnmodifiableList());
return new RestMindmapList(mindmaps, user); return new RestMindmapList(mindmaps, user);
@ -495,47 +495,41 @@ public class MindmapController extends BaseController {
mindmapService.removeMindmap(mindmap, user); mindmapService.removeMindmap(mindmap, user);
} }
} }
@RequestMapping(method = RequestMethod.POST, value = "/maps", consumes = {"application/xml", "application/json"})
@RequestMapping(method = RequestMethod.POST, value = "/maps", consumes = {"application/xml", "application/json", "application/wisemapping+xml"})
@ResponseStatus(value = HttpStatus.CREATED) @ResponseStatus(value = HttpStatus.CREATED)
public void createMap(@RequestBody(required = false) RestMindmap restMindmap, @NotNull HttpServletResponse response, @RequestParam(required = false) String title, @RequestParam(required = false) String description) throws IOException, WiseMappingException { public void createMap(@RequestBody(required = false) String mapXml, @NotNull HttpServletResponse response, @RequestParam(required = false) String title, @RequestParam(required = false) String description) throws IOException, WiseMappingException {
// If a default maps has not been defined, just create one ...
if (restMindmap == null) { final Mindmap mindmap = new Mindmap();
restMindmap = new RestMindmap(); if (title != null && !title.isEmpty()) {
mindmap.setTitle(title);
} }
// Overwrite title and description if they where specified by parameter.
if (title != null && !title.isEmpty()) {
restMindmap.setTitle(title);
}
if (description != null && !description.isEmpty()) { if (description != null && !description.isEmpty()) {
restMindmap.setDescription(description); mindmap.setDescription(description);
} else { }else {
restMindmap.setDescription(""); mindmap.setDescription("description");
} }
// Validate ... // Validate ...
final BindingResult result = new BeanPropertyBindingResult(restMindmap, ""); final BindingResult result = new BeanPropertyBindingResult(mindmap, "");
new MapInfoValidator(mindmapService).validate(restMindmap.getDelegated(), result); new MapInfoValidator(mindmapService).validate(mindmap, result);
if (result.hasErrors()) { if (result.hasErrors()) {
throw new ValidationException(result); throw new ValidationException(result);
} }
// If the user has not specified the xml content, add one ... // If the user has not specified the xml content, add one ...
final Mindmap delegated = restMindmap.getDelegated(); if (mapXml == null || mapXml.isEmpty()) {
String xml = restMindmap.getXml(); mapXml = Mindmap.getDefaultMindmapXml(mindmap.getTitle());
if (xml == null || xml.isEmpty()) {
xml = Mindmap.getDefaultMindmapXml(restMindmap.getTitle());
} }
delegated.setXmlStr(xml); mindmap.setXmlStr(mapXml);
// Add new mindmap ... // Add new mindmap ...
final User user = Utils.getUser(); final User user = Utils.getUser();
mindmapService.addMindmap(delegated, user); mindmapService.addMindmap(mindmap, user);
// Return the new created map ... // Return the new created map ...
response.setHeader("Location", "/service/maps/" + delegated.getId()); response.setHeader("Location", "/service/maps/" + mindmap.getId());
response.setHeader("ResourceId", Integer.toString(delegated.getId())); response.setHeader("ResourceId", Integer.toString(mindmap.getId()));
} }
@RequestMapping(method = RequestMethod.POST, value = "/maps/{id}", consumes = {"application/xml", "application/json"}, produces = {"application/xml", "application/json", "text/plain"}) @RequestMapping(method = RequestMethod.POST, value = "/maps/{id}", consumes = {"application/xml", "application/json"}, produces = {"application/xml", "application/json", "text/plain"})
@ -578,9 +572,9 @@ public class MindmapController extends BaseController {
return new ValidationException(result); return new ValidationException(result);
} }
@RequestMapping(method = RequestMethod.DELETE, value = "/maps/{id}/labels/{lid)}") @RequestMapping(method = RequestMethod.DELETE, value = "/maps/{id}/labels/{lid}")
@ResponseStatus(value = HttpStatus.NO_CONTENT) @ResponseStatus(value = HttpStatus.NO_CONTENT)
public void removeLabelFromMap(@PathVariable int id, @RequestBody int lid) throws WiseMappingException { public void removeLabelFromMap(@PathVariable int id, @PathVariable int lid) throws WiseMappingException {
final User user = Utils.getUser(); final User user = Utils.getUser();
final Mindmap mindmap = findMindmapById(id); final Mindmap mindmap = findMindmapById(id);
final Label label = labelService.findLabelById(lid, user); final Label label = labelService.findLabelById(lid, user);
@ -590,7 +584,7 @@ public class MindmapController extends BaseController {
} }
mindmap.removeLabel(label); mindmap.removeLabel(label);
mindmapService.updateMindmap(mindmap,false); mindmapService.updateMindmap(mindmap, false);
} }
@RequestMapping(method = RequestMethod.POST, value = "/maps/{id}/labels", consumes = {"application/xml", "application/json"}) @RequestMapping(method = RequestMethod.POST, value = "/maps/{id}/labels", consumes = {"application/xml", "application/json"})
@ -604,6 +598,6 @@ public class MindmapController extends BaseController {
final Mindmap mindmap = findMindmapById(id); final Mindmap mindmap = findMindmapById(id);
mindmap.addLabel(label); mindmap.addLabel(label);
mindmapService.updateMindmap(mindmap,false); mindmapService.updateMindmap(mindmap, false);
} }
} }

View File

@ -38,7 +38,6 @@
var readOnly = ${readOnlyMode}; var readOnly = ${readOnlyMode};
var lockTimestamp = '${lockTimestamp}'; var lockTimestamp = '${lockTimestamp}';
var lockSession = '${lockSession}'; var lockSession = '${lockSession}';
var locale = '${locale}';
var mindmapLocked = ${mindmapLocked}; var mindmapLocked = ${mindmapLocked};
var mindmapLockedMsg = '<spring:message code="MINDMAP_LOCKED" arguments="${lockInfo.user.fullName},${lockInfo.user.email}"/>'; var mindmapLockedMsg = '<spring:message code="MINDMAP_LOCKED" arguments="${lockInfo.user.fullName},${lockInfo.user.email}"/>';
var userOptions = ${mindmap.properties}; var userOptions = ${mindmap.properties};

View File

@ -35,16 +35,16 @@ public class RestMindmapITCase {
} }
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void listMaps(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ... public void listMaps(final @NotNull MediaType mediaType) { // Configure media types ...
final HttpHeaders requestHeaders = createHeaders(mediaType); final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate template = createTemplate(userEmail); final RestTemplate template = createTemplate(userEmail);
// Create a sample map ... // Create a sample map ...
final String title1 = "List Maps 1 - " + mediaType; final String title1 = "List Maps 1 - " + mediaType;
addNewMap(requestHeaders, template, title1); addNewMap(template, title1);
final String title2 = "List Maps 2 - " + mediaType; final String title2 = "List Maps 2 - " + mediaType;
addNewMap(requestHeaders, template, title2); addNewMap(template, title2);
// Check that the map has been created ... // Check that the map has been created ...
final HttpEntity findMapEntity = new HttpEntity(requestHeaders); final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
@ -68,13 +68,13 @@ public class RestMindmapITCase {
} }
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void deleteMap(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ... public void deleteMap(final @NotNull MediaType mediaType) { // Configure media types ...
final HttpHeaders requestHeaders = createHeaders(mediaType); final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate template = createTemplate(userEmail); final RestTemplate template = createTemplate(userEmail);
// Create a sample map ... // Create a sample map ...
final String title1 = "Map to delete - " + mediaType; final String title1 = "Map to delete - " + mediaType;
final URI resourceUri = addNewMap(requestHeaders, template, title1); final URI resourceUri = addNewMap(template, title1);
// Now remove it ... // Now remove it ...
template.delete(HOST_PORT + resourceUri.toString()); template.delete(HOST_PORT + resourceUri.toString());
@ -84,21 +84,22 @@ public class RestMindmapITCase {
findMap(requestHeaders, template, resourceUri); findMap(requestHeaders, template, resourceUri);
fail("Map could not be removed:" + resourceUri); fail("Map could not be removed:" + resourceUri);
} catch (Exception e) { } catch (Exception e) {
// Ignore
} }
} }
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void changeMapTitle(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ... public void changeMapTitle(final @NotNull MediaType mediaType) { // Configure media types ...
final HttpHeaders requestHeaders = createHeaders(mediaType); final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate template = createTemplate(userEmail); final RestTemplate template = createTemplate(userEmail);
// Create a sample map ... // Create a sample map ...
final URI resourceUri = addNewMap(requestHeaders, template, "Map to change title - " + mediaType); final URI resourceUri = addNewMap(template, "Map to change title - " + mediaType);
// Change map title ... // Change map title ...
requestHeaders.setContentType(MediaType.TEXT_PLAIN); requestHeaders.setContentType(MediaType.TEXT_PLAIN);
final String newTitle = "New map to change title - " + mediaType; final String newTitle = "New map to change title - " + mediaType;
final HttpEntity<String> updateEntity = new HttpEntity<String>(newTitle, requestHeaders); final HttpEntity<String> updateEntity = new HttpEntity<>(newTitle, requestHeaders);
template.put(HOST_PORT + resourceUri + "/title", updateEntity); template.put(HOST_PORT + resourceUri + "/title", updateEntity);
// Load map again .. // Load map again ..
@ -107,22 +108,18 @@ public class RestMindmapITCase {
} }
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void validateMapsCreation(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ... public void validateMapsCreation(final @NotNull MediaType mediaType) { // Configure media types ...
final HttpHeaders requestHeaders = createHeaders(mediaType); final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate template = createTemplate(userEmail); final RestTemplate template = createTemplate(userEmail);
// Create a sample map ... // Create a sample map ...
final String title = "Map to Validate Creation - " + mediaType; final String title = "Map to Validate Creation - " + mediaType;
final URI resourceUri = addNewMap(requestHeaders, template, title); addNewMap(template, title);
// Try to create a map with the same title ..
final RestMindmap restMindmap = new RestMindmap();
restMindmap.setTitle(title);
restMindmap.setDescription("My Map Desc");
// Add map with same name ...
try { try {
HttpEntity<RestMindmap> createUserEntity = new HttpEntity<RestMindmap>(restMindmap, requestHeaders); HttpEntity<RestMindmap> createUserEntity = new HttpEntity<>(requestHeaders);
template.postForLocation(BASE_REST_URL + "/maps", createUserEntity); template.postForLocation(BASE_REST_URL + "/maps?title=" + title, createUserEntity);
} catch (HttpClientErrorException cause) { } catch (HttpClientErrorException cause) {
final String responseBodyAsString = cause.getResponseBodyAsString(); final String responseBodyAsString = cause.getResponseBodyAsString();
assert (responseBodyAsString.contains("You have already a map")); assert (responseBodyAsString.contains("You have already a map"));
@ -134,17 +131,17 @@ public class RestMindmapITCase {
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void changeMapDescription(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ... public void changeMapDescription(final @NotNull MediaType mediaType) { // Configure media types ...
final HttpHeaders requestHeaders = createHeaders(mediaType); final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate template = createTemplate(userEmail); final RestTemplate template = createTemplate(userEmail);
// Create a sample map ... // Create a sample map ...
final URI resourceUri = addNewMap(requestHeaders, template, "Map to change Description - " + mediaType); final URI resourceUri = addNewMap(template, "Map to change Description - " + mediaType);
// Change map title ... // Change map title ...
requestHeaders.setContentType(MediaType.TEXT_PLAIN); requestHeaders.setContentType(MediaType.TEXT_PLAIN);
final String newDescription = "New map to change description - " + mediaType; final String newDescription = "New map to change description - " + mediaType;
final HttpEntity<String> updateEntity = new HttpEntity<String>(newDescription, requestHeaders); final HttpEntity<String> updateEntity = new HttpEntity<>(newDescription, requestHeaders);
template.put(HOST_PORT + resourceUri + "/description", updateEntity); template.put(HOST_PORT + resourceUri + "/description", updateEntity);
// Load map again .. // Load map again ..
@ -153,19 +150,19 @@ public class RestMindmapITCase {
} }
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void updateMapXml(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ... public void updateMapXml(final @NotNull MediaType mediaType) throws IOException { // Configure media types ...
final HttpHeaders requestHeaders = createHeaders(mediaType); final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate template = createTemplate(userEmail); final RestTemplate template = createTemplate(userEmail);
// Create a sample map ... // Create a sample map ...
final String title = "Update XML sample " + mediaType; final String title = "Update XML sample " + mediaType;
final URI resourceUri = addNewMap(requestHeaders, template, title); final URI resourceUri = addNewMap(template, title);
// Update map xml content ... // Update map xml content ...
final String resourceUrl = HOST_PORT + resourceUri.toString(); final String resourceUrl = HOST_PORT + resourceUri.toString();
requestHeaders.setContentType(MediaType.TEXT_PLAIN); requestHeaders.setContentType(MediaType.TEXT_PLAIN);
final String newXmlContent = "<map>this is not valid</map>"; final String newXmlContent = "<map>this is not valid</map>";
HttpEntity<String> updateEntity = new HttpEntity<String>(newXmlContent, requestHeaders); HttpEntity<String> updateEntity = new HttpEntity<>(newXmlContent, requestHeaders);
template.put(resourceUrl + "/document/xml", updateEntity); template.put(resourceUrl + "/document/xml", updateEntity);
// Check that the map has been updated ... // Check that the map has been updated ...
@ -174,14 +171,14 @@ public class RestMindmapITCase {
} }
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void cloneMap(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ... public void cloneMap(final @NotNull MediaType mediaType) throws IOException { // Configure media types ...
final HttpHeaders requestHeaders = createHeaders(mediaType); final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate template = createTemplate(userEmail); final RestTemplate template = createTemplate(userEmail);
// Create a sample map ... // Create a sample map ...
final String title = "Map to clone sample " + mediaType; final String title = "Map to clone sample " + mediaType;
final String xml = "<map><node text='this is a cloned map'></map>"; final String xml = "<map><node text='this is a cloned map'></map>";
final URI newMapUri = addNewMap(requestHeaders, template, title, xml); final URI newMapUri = addNewMap(template, title, xml);
// Clone map ... // Clone map ...
final RestMindmapInfo restMindmap = new RestMindmapInfo(); final RestMindmapInfo restMindmap = new RestMindmapInfo();
@ -189,7 +186,7 @@ public class RestMindmapITCase {
restMindmap.setDescription("Cloned map desc"); restMindmap.setDescription("Cloned map desc");
// Create a new map ... // Create a new map ...
final HttpEntity<RestMindmapInfo> cloneEntity = new HttpEntity<RestMindmapInfo>(restMindmap, requestHeaders); final HttpEntity<RestMindmapInfo> cloneEntity = new HttpEntity<>(restMindmap, requestHeaders);
final URI clonedMapUri = template.postForLocation(HOST_PORT + newMapUri, cloneEntity); final URI clonedMapUri = template.postForLocation(HOST_PORT + newMapUri, cloneEntity);
// Check that the map has been updated ... // Check that the map has been updated ...
@ -198,7 +195,7 @@ public class RestMindmapITCase {
} }
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void verifyMapOwnership(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ... public void verifyMapOwnership(final @NotNull MediaType mediaType) { // Configure media types ...
throw new SkipException("missing test: removeUserShouldOnlyDeleteOnwedMap"); throw new SkipException("missing test: removeUserShouldOnlyDeleteOnwedMap");
} }
@ -213,7 +210,7 @@ public class RestMindmapITCase {
// Create a sample map ... // Create a sample map ...
final String title = "Update sample " + mediaType; final String title = "Update sample " + mediaType;
final URI resourceUri = addNewMap(requestHeaders, template, title); final URI resourceUri = addNewMap(template, title);
// Build map to update ... // Build map to update ...
final RestMindmap mapToUpdate = new RestMindmap(); final RestMindmap mapToUpdate = new RestMindmap();
@ -223,23 +220,23 @@ public class RestMindmapITCase {
// Update map ... // Update map ...
final String resourceUrl = HOST_PORT + resourceUri.toString() + "/document"; final String resourceUrl = HOST_PORT + resourceUri.toString() + "/document";
requestHeaders.setContentType(MediaType.APPLICATION_XML); requestHeaders.setContentType(MediaType.APPLICATION_XML);
final HttpEntity<RestMindmap> updateEntity = new HttpEntity<RestMindmap>(mapToUpdate, requestHeaders); final HttpEntity<RestMindmap> updateEntity = new HttpEntity<>(mapToUpdate, requestHeaders);
template.put(resourceUrl, updateEntity); template.put(resourceUrl, updateEntity);
// Check that the map has been updated ... // Check that the map has been updated ...
HttpEntity<RestUser> findMapEntity = new HttpEntity<RestUser>(requestHeaders); HttpEntity<RestUser> findMapEntity = new HttpEntity<>(requestHeaders);
final ResponseEntity<RestMindmap> response = template.exchange(HOST_PORT + resourceUri, HttpMethod.GET, findMapEntity, RestMindmap.class); final ResponseEntity<RestMindmap> response = template.exchange(HOST_PORT + resourceUri, HttpMethod.GET, findMapEntity, RestMindmap.class);
assertEquals(response.getBody().getXml(), mapToUpdate.getXml()); assertEquals(response.getBody().getXml(), mapToUpdate.getXml());
assertEquals(response.getBody().getProperties(), mapToUpdate.getProperties()); assertEquals(response.getBody().getProperties(), mapToUpdate.getProperties());
} }
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void addCollabs(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { public void addCollabs(final @NotNull MediaType mediaType) {
final HttpHeaders requestHeaders = createHeaders(mediaType); final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate template = createTemplate(userEmail); final RestTemplate template = createTemplate(userEmail);
// Create a sample map ... // Create a sample map ...
final URI resourceUri = addNewMap(requestHeaders, template, "Map for addCollabs - " + mediaType); final URI resourceUri = addNewMap(template, "Map for addCollabs - " + mediaType);
// Add a new collaboration ... // Add a new collaboration ...
requestHeaders.setContentType(MediaType.APPLICATION_JSON); requestHeaders.setContentType(MediaType.APPLICATION_JSON);
@ -270,12 +267,12 @@ public class RestMindmapITCase {
} }
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void updateCollabType(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { public void updateCollabType(final @NotNull MediaType mediaType) {
final HttpHeaders requestHeaders = createHeaders(mediaType); final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate template = createTemplate(userEmail); final RestTemplate template = createTemplate(userEmail);
// Create a sample map ... // Create a sample map ...
final URI resourceUri = addNewMap(requestHeaders, template, "Map for updateCollabType - " + mediaType); final URI resourceUri = addNewMap(template, "Map for updateCollabType - " + mediaType);
// Add a new collaboration ... // Add a new collaboration ...
requestHeaders.setContentType(MediaType.APPLICATION_JSON); requestHeaders.setContentType(MediaType.APPLICATION_JSON);
@ -310,12 +307,12 @@ public class RestMindmapITCase {
} }
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void deleteCollabs(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { public void deleteCollabs(final @NotNull MediaType mediaType) {
final HttpHeaders requestHeaders = createHeaders(mediaType); final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate template = createTemplate(userEmail); final RestTemplate template = createTemplate(userEmail);
// Create a sample map ... // Create a sample map ...
final URI resourceUri = addNewMap(requestHeaders, template, "Map for deleteCollabs - " + mediaType); final URI resourceUri = addNewMap(template, "Map for deleteCollabs - " + mediaType);
// Add a new collaboration ... // Add a new collaboration ...
requestHeaders.setContentType(MediaType.APPLICATION_JSON); requestHeaders.setContentType(MediaType.APPLICATION_JSON);
@ -355,13 +352,13 @@ public class RestMindmapITCase {
} }
@Test(dataProviderClass = RestHelper.class, expectedExceptions = {HttpClientErrorException.class}, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, expectedExceptions = {HttpClientErrorException.class}, dataProvider = "ContentType-Provider-Function")
public void addCollabsInvalidOwner(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { public void addCollabsInvalidOwner(final @NotNull MediaType mediaType) {
final HttpHeaders requestHeaders = createHeaders(mediaType); final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate template = createTemplate(userEmail); final RestTemplate template = createTemplate(userEmail);
// Create a sample map ... // Create a sample map ...
final URI resourceUri = addNewMap(requestHeaders, template, "Map for Collaboration - " + mediaType); final URI resourceUri = addNewMap(template, "Map for Collaboration - " + mediaType);
// Add a new collaboration ... // Add a new collaboration ...
requestHeaders.setContentType(MediaType.APPLICATION_JSON); requestHeaders.setContentType(MediaType.APPLICATION_JSON);
@ -380,12 +377,12 @@ public class RestMindmapITCase {
} }
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void removeLabelFromMindmap(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ... public void removeLabelFromMindmap(final @NotNull MediaType mediaType) { // Configure media types ...
throw new SkipException("missing test: label removal from map"); throw new SkipException("missing test: label removal from map");
} }
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function") @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
public void deleteMapAndCheckLabels(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ... public void deleteMapAndCheckLabels(final @NotNull MediaType mediaType) { // Configure media types ...
throw new SkipException("missing test: delete map should not affects others labels"); throw new SkipException("missing test: delete map should not affects others labels");
} }
@ -404,7 +401,7 @@ public class RestMindmapITCase {
// Create a sample map ... // Create a sample map ...
final String mapTitle = "Maps 1 - " + mediaType; final String mapTitle = "Maps 1 - " + mediaType;
final URI mindmapUri = addNewMap(requestHeaders, template, mapTitle); final URI mindmapUri = addNewMap(template, mapTitle);
final String mapId = mindmapUri.getPath().replace("/service/maps/", ""); final String mapId = mindmapUri.getPath().replace("/service/maps/", "");
// Assign label to map ... // Assign label to map ...
@ -432,22 +429,15 @@ public class RestMindmapITCase {
} }
private URI addNewMap(@NotNull HttpHeaders requestHeaders, @NotNull RestTemplate template, @NotNull String title, @Nullable String xml) throws IOException, WiseMappingException { private URI addNewMap(@NotNull RestTemplate template, @NotNull String title, @Nullable String xml) {
final RestMindmap restMindmap = new RestMindmap();
restMindmap.setTitle(title);
restMindmap.setDescription("My Map Desc");
if (xml != null) {
restMindmap.setXml(xml);
}
// Create a new map ... // Create a new map ...
HttpEntity<RestMindmap> createUserEntity = new HttpEntity<>(restMindmap, requestHeaders); final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_XML);
return template.postForLocation(BASE_REST_URL + "/maps", createUserEntity); HttpEntity<String> createUserEntity = new HttpEntity<>(xml, requestHeaders);
return template.postForLocation(BASE_REST_URL + "/maps?title=" + title, createUserEntity);
} }
private URI addNewMap(@NotNull HttpHeaders requestHeaders, @NotNull RestTemplate template, @NotNull String title) throws IOException, WiseMappingException { private URI addNewMap(@NotNull RestTemplate template, @NotNull String title) {
return addNewMap(requestHeaders, template, title, null); return addNewMap(template, title, null);
} }
} }