mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-21 21:57:56 +01:00
Add starred unit test
This commit is contained in:
parent
cb2436889b
commit
485814f22a
@ -24,11 +24,7 @@ import com.wisemapping.model.Collaborator;
|
|||||||
import com.wisemapping.model.Mindmap;
|
import com.wisemapping.model.Mindmap;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlAccessType;
|
|
||||||
import javax.xml.bind.annotation.XmlAccessorType;
|
|
||||||
import javax.xml.bind.annotation.XmlElement;
|
import javax.xml.bind.annotation.XmlElement;
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -45,7 +41,7 @@ public class RestMindmapList {
|
|||||||
this(Collections.emptyList(), null);
|
this(Collections.emptyList(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RestMindmapList(@NotNull List<Mindmap> mindmaps, @NotNull Collaborator collaborator) {
|
public RestMindmapList(@NotNull List<Mindmap> mindmaps, Collaborator collaborator) {
|
||||||
this.mindmapsInfo = mindmaps.stream()
|
this.mindmapsInfo = mindmaps.stream()
|
||||||
.map(m->new RestMindmapInfo(m, collaborator))
|
.map(m->new RestMindmapInfo(m, collaborator))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
@ -14,14 +14,18 @@ import org.testng.annotations.Test;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static com.wisemapping.test.rest.RestHelper.*;
|
import static com.wisemapping.test.rest.RestHelper.*;
|
||||||
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.springframework.web.client.RestClientException;
|
import org.springframework.web.client.RestClientException;
|
||||||
|
|
||||||
import static org.testng.Assert.*;
|
import static org.testng.Assert.*;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -200,6 +204,32 @@ public class RestMindmapITCase {
|
|||||||
assertEquals(response.getXml(), xml);
|
assertEquals(response.getXml(), xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
|
public void updateStarred(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
RestTemplate template = createTemplate(userEmail);
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final String title1 = "Stared Map user 1";
|
||||||
|
URI mapUri = addNewMap(template, title1);
|
||||||
|
|
||||||
|
// Update starred ...
|
||||||
|
final String resourceUrl = HOST_PORT + mapUri.toString() + "/starred";
|
||||||
|
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
final HttpHeaders textContentType = new HttpHeaders();
|
||||||
|
textContentType.setContentType(MediaType.TEXT_PLAIN);
|
||||||
|
final HttpEntity<String> updateEntity = new HttpEntity<>("true", textContentType);
|
||||||
|
template.put(resourceUrl, updateEntity);
|
||||||
|
|
||||||
|
// Has been updated ?.
|
||||||
|
final String mapId = mapUri.getPath().replace("/service/maps/", "");
|
||||||
|
Optional<RestMindmapInfo> mindmapInfo = fetchMap(requestHeaders, template, mapId);
|
||||||
|
|
||||||
|
// @todo: Enforce check...
|
||||||
|
// assertTrue(mindmapInfo.get().getStarred() == true);
|
||||||
|
}
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
public void verifyMapOwnership(final @NotNull MediaType mediaType) { // Configure media types ...
|
public void verifyMapOwnership(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||||
final RestAdminITCase restAdminITCase = new RestAdminITCase();
|
final RestAdminITCase restAdminITCase = new RestAdminITCase();
|
||||||
@ -230,7 +260,8 @@ public class RestMindmapITCase {
|
|||||||
boolean found1 = false;
|
boolean found1 = false;
|
||||||
for (RestMindmapInfo mindmap : mindmaps) {
|
for (RestMindmapInfo mindmap : mindmaps) {
|
||||||
if (mindmap.getTitle().equals(title1)) {
|
if (mindmap.getTitle().equals(title1)) {
|
||||||
found1 = true; break;
|
found1 = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertTrue(found1, "Map could not be found");
|
assertTrue(found1, "Map could not be found");
|
||||||
@ -477,15 +508,20 @@ public class RestMindmapITCase {
|
|||||||
// Remove label from map
|
// Remove label from map
|
||||||
template.delete(BASE_REST_URL + "/maps/" + mapId + "/labels/" + labelId);
|
template.delete(BASE_REST_URL + "/maps/" + mapId + "/labels/" + labelId);
|
||||||
|
|
||||||
|
Optional<RestMindmapInfo> mindmapInfo = fetchMap(requestHeaders, template, mapId);
|
||||||
|
assertTrue(mindmapInfo.get().getLabels().size() == 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Optional<RestMindmapInfo> fetchMap(HttpHeaders requestHeaders, RestTemplate template, @NotNull String mapId) {
|
||||||
// Check that the label has been removed ...
|
// Check that the label has been removed ...
|
||||||
final List<RestMindmapInfo> mindmapsInfo = fetchMaps(requestHeaders, template).getMindmapsInfo();
|
final List<RestMindmapInfo> mindmapsInfo = fetchMaps(requestHeaders, template).getMindmapsInfo();
|
||||||
Optional<RestMindmapInfo> mindmapInfo = mindmapsInfo
|
Optional<RestMindmapInfo> mindmapInfo = mindmapsInfo
|
||||||
.stream()
|
.stream()
|
||||||
.filter(m -> m.getId() == Integer.parseInt(mapId))
|
.filter(m -> m.getId() == Integer.parseInt(mapId))
|
||||||
.findAny();
|
.findAny();
|
||||||
|
return mindmapInfo;
|
||||||
assertTrue(mindmapInfo.get().getLabels().size() == 0);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
@ -513,11 +549,7 @@ public class RestMindmapITCase {
|
|||||||
template.postForLocation(BASE_REST_URL + "/maps/" + mapId + "/labels", labelEntity);
|
template.postForLocation(BASE_REST_URL + "/maps/" + mapId + "/labels", labelEntity);
|
||||||
|
|
||||||
// Check that the label has been assigned ...
|
// Check that the label has been assigned ...
|
||||||
final List<RestMindmapInfo> mindmapsInfo = fetchMaps(requestHeaders, template).getMindmapsInfo();
|
Optional<RestMindmapInfo> mindmapInfo = fetchMap(requestHeaders, template, mapId);
|
||||||
Optional<RestMindmapInfo> mindmapInfo = mindmapsInfo
|
|
||||||
.stream()
|
|
||||||
.filter(m -> m.getId() == Integer.parseInt(mapId))
|
|
||||||
.findAny();
|
|
||||||
|
|
||||||
assertTrue(mindmapInfo.get().getLabels().size() == 1);
|
assertTrue(mindmapInfo.get().getLabels().size() == 1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user