mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-12-23 03:43:48 +01:00
add new label test
This commit is contained in:
parent
8462e54293
commit
d111c54f15
@ -636,7 +636,7 @@ public class MindmapController extends BaseController {
|
||||
mindmapService.removeLabel(mindmap, delegated);
|
||||
}
|
||||
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/labels/maps", consumes = {"application/json"})
|
||||
@RequestMapping(method = RequestMethod.POST, value = "/labels/maps", consumes = { "application/xml","application/json"})
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public void addLabel(@RequestBody RestLabel restLabel, @RequestParam(required = true) String ids) throws WiseMappingException {
|
||||
int labelId = restLabel.getId();
|
||||
|
@ -18,6 +18,7 @@ public class RestHelper {
|
||||
public static final String HOST_PORT = "http://localhost:8080";
|
||||
public static final String BASE_REST_URL = HOST_PORT + "/service";
|
||||
public static final String ADMIN_CREDENTIALS = "admin@wisemapping.org" + ":" + "admin";
|
||||
public static final String COLOR = "#000000";
|
||||
|
||||
static HttpHeaders createHeaders(@NotNull MediaType mediaType) {
|
||||
List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
|
||||
|
@ -54,7 +54,7 @@ public class RestLabelITCase {
|
||||
// Check that the label has been created ...
|
||||
final RestLabelList restLabelList = getLabels(requestHeaders, template);
|
||||
|
||||
// Validate that the two maps are there ...
|
||||
// Validate that the two labels are there ...
|
||||
final List<RestLabel> labels = restLabelList.getLabels();
|
||||
|
||||
boolean found1 = false;
|
||||
@ -71,7 +71,7 @@ public class RestLabelITCase {
|
||||
|
||||
}
|
||||
|
||||
private RestLabelList getLabels(HttpHeaders requestHeaders, RestTemplate template) {
|
||||
static RestLabelList getLabels(HttpHeaders requestHeaders, RestTemplate template) {
|
||||
final HttpEntity findLabelEntity = new HttpEntity(requestHeaders);
|
||||
final ResponseEntity<RestLabelList> response = template.exchange(BASE_REST_URL + "/labels", HttpMethod.GET, findLabelEntity, RestLabelList.class);
|
||||
return response.getBody();
|
||||
|
@ -2,6 +2,10 @@ package com.wisemapping.test.rest;
|
||||
|
||||
|
||||
import com.wisemapping.exceptions.WiseMappingException;
|
||||
import com.wisemapping.model.Label;
|
||||
import com.wisemapping.model.User;
|
||||
import com.wisemapping.rest.model.RestLabel;
|
||||
import com.wisemapping.rest.model.RestLabelList;
|
||||
import com.wisemapping.rest.model.RestMindmap;
|
||||
import com.wisemapping.rest.model.RestMindmapInfo;
|
||||
import com.wisemapping.rest.model.RestMindmapList;
|
||||
@ -24,6 +28,7 @@ import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import static com.wisemapping.test.rest.RestHelper.BASE_REST_URL;
|
||||
import static com.wisemapping.test.rest.RestHelper.COLOR;
|
||||
import static com.wisemapping.test.rest.RestHelper.HOST_PORT;
|
||||
import static com.wisemapping.test.rest.RestHelper.createHeaders;
|
||||
import static com.wisemapping.test.rest.RestHelper.createTemplate;
|
||||
@ -239,6 +244,35 @@ public class RestMindmapITCase {
|
||||
assertEquals(response.getBody().getProperties(), mapToUpdate.getProperties());
|
||||
}
|
||||
|
||||
@Test(dataProviderClass = RestHelper.class, dataProvider="ContentType-Provider-Function")
|
||||
public void addLabelToMindmap(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||
final RestTemplate template = createTemplate(userEmail);
|
||||
|
||||
// Create a new label
|
||||
final String titleLabel = "Label 1 - " + mediaType.toString();
|
||||
final URI labelUri = RestLabelITCase.addNewLabel(requestHeaders, template, titleLabel, COLOR);
|
||||
|
||||
// Create a sample map ...
|
||||
final String mapTitle = "Maps 1 - " + mediaType.toString();
|
||||
final URI mindmapUri = addNewMap(requestHeaders, template, mapTitle);
|
||||
final String mapId = mindmapUri.getPath().replace("/service/maps/", "");
|
||||
|
||||
final RestLabel restLabel = new RestLabel();
|
||||
restLabel.setColor(COLOR);
|
||||
String labelId = labelUri.getPath().replace("/service/labels/", "");
|
||||
restLabel.setId(Integer.parseInt(labelId));
|
||||
restLabel.setTitle(titleLabel);
|
||||
|
||||
HttpEntity<RestLabel> labelEntity = new HttpEntity<>(restLabel, requestHeaders);
|
||||
template.postForLocation(BASE_REST_URL + "/labels/maps?ids=" + mapId, labelEntity);
|
||||
|
||||
// Load map again ..
|
||||
final RestMindmap withLabel = findMap(requestHeaders, template, mindmapUri);
|
||||
|
||||
// assertTrue(withLabel.getDelegated().getLabels().size() == 1);
|
||||
}
|
||||
|
||||
private RestMindmap findMap(HttpHeaders requestHeaders, RestTemplate template, URI resourceUri) {
|
||||
final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
||||
final ResponseEntity<RestMindmap> response = template.exchange(HOST_PORT + resourceUri.toString(), HttpMethod.GET, findMapEntity, RestMindmap.class);
|
||||
|
Loading…
Reference in New Issue
Block a user