diff --git a/wise-editor/src/main/webapp/html/drag.html b/wise-editor/src/main/webapp/html/drag.html
index 86bd96cc..de394295 100644
--- a/wise-editor/src/main/webapp/html/drag.html
+++ b/wise-editor/src/main/webapp/html/drag.html
@@ -205,7 +205,6 @@
Text Node !!
-
diff --git a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapList.java b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapList.java
index 5e8f4569..c110070b 100644
--- a/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapList.java
+++ b/wise-webapp/src/main/java/com/wisemapping/rest/model/RestMindmapList.java
@@ -5,6 +5,7 @@ import com.wisemapping.model.MindMap;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.jetbrains.annotations.NotNull;
+import org.springframework.util.CollectionUtils;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@@ -12,6 +13,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
@XmlRootElement(name = "maps")
@@ -25,7 +27,7 @@ public class RestMindmapList {
private List mindmaps;
public RestMindmapList() {
- this(null);
+ this(Collections.emptyList());
}
public RestMindmapList(@NotNull List mindmaps) {
diff --git a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapTCase.java b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapTCase.java
index 920721b3..4ebe61f9 100644
--- a/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapTCase.java
+++ b/wise-webapp/src/test/java/com/wisemapping/test/rest/RestMindmapTCase.java
@@ -2,6 +2,7 @@ package com.wisemapping.test.rest;
import com.wisemapping.rest.model.RestMindmap;
+import com.wisemapping.rest.model.RestMindmapList;
import com.wisemapping.rest.model.RestUser;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -21,6 +22,7 @@ import java.util.ArrayList;
import java.util.List;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@@ -28,7 +30,7 @@ import static org.testng.Assert.fail;
public class RestMindmapTCase {
private String userEmail = "admin@wisemapping.com";
- private static final String HOST_PORT = "http://localhost:8080";
+ private static final String HOST_PORT = "http://127.0.0.1:8080";
private static final String BASE_REST_URL = HOST_PORT + "/service";
@BeforeClass
@@ -38,42 +40,75 @@ public class RestMindmapTCase {
userEmail = restAdminITCase.createNewUser(MediaType.APPLICATION_JSON);
}
+ @Test(dataProvider = "ContentType-Provider-Function")
+ public void listMaps(final @NotNull MediaType mediaType) { // Configure media types ...
+ final HttpHeaders requestHeaders = createHeaders(mediaType);
+ final RestTemplate templateRest = createTemplate();
+
+ // Create a sample map ...
+ final String title1 = "List Maps 1 - " + mediaType.toString();
+ addNewMap(requestHeaders, templateRest, title1);
+
+ final String title2 = "List Maps 2 - " + mediaType.toString();
+ addNewMap(requestHeaders, templateRest, title2);
+
+ // Check that the map has been created ...
+ final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
+ final ResponseEntity response = templateRest.exchange(BASE_REST_URL + "/maps", HttpMethod.GET, findMapEntity, RestMindmapList.class);
+
+ // Validate that the two maps are there ...
+ final RestMindmapList body = response.getBody();
+ final List mindmaps = body.getMindmaps();
+
+ boolean found1 = false;
+ boolean found2 = false;
+ for (RestMindmap mindmap : mindmaps) {
+ if (mindmap.getTitle().equals(title1)) {
+ found1 = true;
+ }
+ if (mindmap.getTitle().equals(title2)) {
+ found2 = true;
+ }
+ }
+ assertTrue(found1 && found2, "Map could not be found");
+
+ }
+
+ private URI addNewMap(HttpHeaders requestHeaders, RestTemplate templateRest, String title) {
+ final RestMindmap restMindmap = new RestMindmap();
+ restMindmap.setTitle(title);
+ restMindmap.setDescription("My Map Desc");
+ // Create a new map ...
+ HttpEntity createUserEntity = new HttpEntity(restMindmap, requestHeaders);
+ return templateRest.postForLocation(BASE_REST_URL + "/maps", createUserEntity);
+
+
+ }
+
+
@Test(dataProvider = "ContentType-Provider-Function")
public void createMap(final @NotNull MediaType mediaType) { // Configure media types ...
final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate templateRest = createTemplate();
// Create a sample map ...
- final RestMindmap restMindmap = new RestMindmap();
final String title = "My Map " + mediaType.toString();
- restMindmap.setTitle(title);
- restMindmap.setDescription("My Map Desc");
-
- // Create a new map ...
- HttpEntity createUserEntity = new HttpEntity(restMindmap, requestHeaders);
- final URI resourceLocation = templateRest.postForLocation(BASE_REST_URL + "/maps", createUserEntity);
+ final URI resourceLocation = addNewMap(requestHeaders, templateRest, title);
// Check that the map has been created ...
- HttpEntity findUserEntity = new HttpEntity(requestHeaders);
- final ResponseEntity response = templateRest.exchange(HOST_PORT + resourceLocation.toString(), HttpMethod.GET, findUserEntity, RestMindmap.class);
+ final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
+ final ResponseEntity response = templateRest.exchange(HOST_PORT + resourceLocation.toString(), HttpMethod.GET, findMapEntity, RestMindmap.class);
assertEquals(response.getBody().getTitle(), title);
}
-
@Test(dataProvider = "ContentType-Provider-Function")
public void updateMapXml(final @NotNull MediaType mediaType) throws IOException { // Configure media types ...
final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate templateRest = createTemplate();
// Create a sample map ...
- final RestMindmap restMindmap = new RestMindmap();
final String title = "Update XML sample " + mediaType.toString();
- restMindmap.setTitle(title);
- restMindmap.setDescription("My Map Desc");
-
- // Create a new map ...
- HttpEntity createUserEntity = new HttpEntity(restMindmap, requestHeaders);
- final URI resourceLocation = templateRest.postForLocation(BASE_REST_URL + "/maps", createUserEntity);
+ final URI resourceLocation = addNewMap(requestHeaders, templateRest, title);
// Update map xml content ...
final String resourceUrl = HOST_PORT + resourceLocation.toString();
@@ -83,8 +118,8 @@ public class RestMindmapTCase {
templateRest.put(resourceUrl + "/xml", updateEntity);
// Check that the map has been updated ...
- HttpEntity findUserEntity = new HttpEntity(requestHeaders);
- final ResponseEntity response = templateRest.exchange(HOST_PORT + resourceLocation.toString(), HttpMethod.GET, findUserEntity, RestMindmap.class);
+ final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
+ final ResponseEntity response = templateRest.exchange(HOST_PORT + resourceLocation.toString(), HttpMethod.GET, findMapEntity, RestMindmap.class);
assertEquals(response.getBody().getXml(), newXmlContent);
}
@@ -95,14 +130,8 @@ public class RestMindmapTCase {
final RestTemplate templateRest = createTemplate();
// Create a sample map ...
- final RestMindmap newRestMindmap = new RestMindmap();
final String title = "Update sample " + mediaType.toString();
- newRestMindmap.setTitle(title);
- newRestMindmap.setDescription("My Map Desc");
-
- // Create a new map ...
- final HttpEntity createUserEntity = new HttpEntity(newRestMindmap, requestHeaders);
- final URI resourceLocation = templateRest.postForLocation(BASE_REST_URL + "/maps", createUserEntity);
+ final URI resourceLocation = addNewMap(requestHeaders, templateRest, title);
// Build map to update ...
final RestMindmap mapToUpdate = new RestMindmap();