mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-12-22 11:33:47 +01:00
Compare commits
10 Commits
d03a9e5eea
...
56e4970861
Author | SHA1 | Date | |
---|---|---|---|
|
56e4970861 | ||
|
861b4f22fd | ||
|
cdbeaf5216 | ||
|
d49766463a | ||
|
27c310197e | ||
|
bbb6f362bd | ||
|
6ca26ffd10 | ||
|
a3022d36d2 | ||
|
f0bc9e53ea | ||
|
fc66a52232 |
5
pom.xml
5
pom.xml
@ -61,11 +61,6 @@
|
|||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.0</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>2.16</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
@ -47,15 +47,22 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>junit</groupId>
|
<groupId>org.junit.vintage</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit-vintage-engine</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- <dependency>-->
|
||||||
|
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||||
|
<!-- <artifactId>spring-boot-devtools</artifactId>-->
|
||||||
|
<!-- <optional>true</optional>-->
|
||||||
|
<!-- </dependency>-->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework</groupId>
|
<groupId>org.springframework</groupId>
|
||||||
<artifactId>spring-test</artifactId>
|
<artifactId>spring-test</artifactId>
|
||||||
@ -215,46 +222,11 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
</plugin>
|
<!-- <configuration>-->
|
||||||
<plugin>
|
<!-- <jvmArguments>-->
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<!-- -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005-->
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<!-- </jvmArguments>-->
|
||||||
<version>3.4.0</version>
|
<!-- </configuration>-->
|
||||||
<configuration>
|
|
||||||
<warName>wisemapping</warName>
|
|
||||||
<overlays>
|
|
||||||
<overlay>
|
|
||||||
<groupId>org.wisemapping</groupId>
|
|
||||||
<artifactId>wise-ui</artifactId>
|
|
||||||
<targetPath>/static/mindplot/</targetPath>
|
|
||||||
<includes>
|
|
||||||
<include>wisemapping-mindplot/package/dist/*</include>
|
|
||||||
</includes>
|
|
||||||
</overlay>
|
|
||||||
<overlay>
|
|
||||||
<groupId>org.wisemapping</groupId>
|
|
||||||
<artifactId>wise-ui</artifactId>
|
|
||||||
<targetPath>/static/webapp/</targetPath>
|
|
||||||
<includes>
|
|
||||||
<include>wisemapping-webapp/package/dist/*</include>
|
|
||||||
</includes>
|
|
||||||
</overlay>
|
|
||||||
</overlays>
|
|
||||||
<archiveClasses>true</archiveClasses>
|
|
||||||
<packagingExcludes>
|
|
||||||
WEB-INF/lib/commons-logging-*.jar,
|
|
||||||
</packagingExcludes>
|
|
||||||
<webResources>
|
|
||||||
<resource>
|
|
||||||
<directory>src/main/resources</directory>
|
|
||||||
<targetPath>WEB-INF</targetPath>
|
|
||||||
<includes>
|
|
||||||
<include>*.wsdl</include>
|
|
||||||
<include>*.xsd</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
|
||||||
</webResources>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
@ -31,6 +31,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import jakarta.persistence.*;
|
import jakarta.persistence.*;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
@ -51,7 +52,7 @@ public class Mindmap implements Serializable {
|
|||||||
@Column(name = "edition_date")
|
@Column(name = "edition_date")
|
||||||
private Calendar lastModificationTime;
|
private Calendar lastModificationTime;
|
||||||
|
|
||||||
@ManyToOne(fetch = FetchType.LAZY)
|
@ManyToOne(fetch = FetchType.EAGER)
|
||||||
@JoinColumn(name = "creator_id", unique = true)
|
@JoinColumn(name = "creator_id", unique = true)
|
||||||
private User creator;
|
private User creator;
|
||||||
|
|
||||||
|
@ -17,10 +17,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.wisemapping.rest;
|
package com.wisemapping.rest;
|
||||||
|
|
||||||
import com.wisemapping.exceptions.ClientException;
|
import com.wisemapping.exceptions.*;
|
||||||
import com.wisemapping.exceptions.OAuthAuthenticationException;
|
|
||||||
import com.wisemapping.exceptions.Severity;
|
|
||||||
import com.wisemapping.exceptions.ValidationException;
|
|
||||||
import com.wisemapping.model.User;
|
import com.wisemapping.model.User;
|
||||||
import com.wisemapping.rest.model.RestErrors;
|
import com.wisemapping.rest.model.RestErrors;
|
||||||
import com.wisemapping.security.Utils;
|
import com.wisemapping.security.Utils;
|
||||||
@ -100,6 +97,14 @@ public class BaseController {
|
|||||||
return new RestErrors(ex.getMessage(messageSource, locale), ex.getSeverity(), ex.getTechInfo());
|
return new RestErrors(ex.getMessage(messageSource, locale), ex.getSeverity(), ex.getTechInfo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ExceptionHandler(AccessDeniedSecurityException.class)
|
||||||
|
@ResponseBody
|
||||||
|
@ResponseStatus(HttpStatus.FORBIDDEN)
|
||||||
|
public RestErrors handleAccessDeniedSecurityException(@NotNull AccessDeniedSecurityException ex) {
|
||||||
|
return new RestErrors(ex.getMessage(), ex.getSeverity(), ex.getTechInfo());
|
||||||
|
}
|
||||||
|
|
||||||
@ExceptionHandler(OAuthAuthenticationException.class)
|
@ExceptionHandler(OAuthAuthenticationException.class)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public OAuthAuthenticationException handleOAuthErrors(@NotNull OAuthAuthenticationException ex, HttpServletResponse response) {
|
public OAuthAuthenticationException handleOAuthErrors(@NotNull OAuthAuthenticationException ex, HttpServletResponse response) {
|
||||||
|
@ -135,4 +135,14 @@ public class RestErrors {
|
|||||||
return gErrors;
|
return gErrors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "RestErrors{" +
|
||||||
|
"errors=" + errors +
|
||||||
|
", gErrors=" + gErrors +
|
||||||
|
", messageSource=" + messageSource +
|
||||||
|
", gSeverity=" + gSeverity +
|
||||||
|
", _debugInfo='" + _debugInfo + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,16 @@ SpringBoot Common
|
|||||||
##################################################################################
|
##################################################################################
|
||||||
|
|
||||||
# JPA
|
# JPA
|
||||||
spring.datasource.initialize=true
|
|
||||||
spring.main.allow-circular-references=true
|
spring.main.allow-circular-references=true
|
||||||
|
|
||||||
spring.jpa.open-in-view=true
|
spring.jpa.open-in-view=true
|
||||||
spring.jpa.hibernate.ddl-auto=none
|
spring.jpa.hibernate.ddl-auto=none
|
||||||
spring.jpa.properties.hibernate.current_session_context_class=thread
|
spring.jpa.properties.hibernate.current_session_context_class=thread
|
||||||
spring.jpa.properties.hibernate.format_sql=true
|
spring.jpa.properties.hibernate.format_sql=true
|
||||||
spring.sql.init.mode=always
|
spring.sql.init.mode=always
|
||||||
|
spring.sql.init.platform=hsqldb
|
||||||
|
|
||||||
# LOG
|
# LOG
|
||||||
|
logging.level.root=INFO
|
||||||
logging.level.root=TRACE
|
|
||||||
logging.level.org.apache.tomcat=INFO
|
logging.level.org.apache.tomcat=INFO
|
||||||
|
|
||||||
##################################################################################
|
##################################################################################
|
||||||
@ -125,10 +123,11 @@ security.oauth2.google.url=https//review
|
|||||||
# Database Configuration
|
# Database Configuration
|
||||||
##################################################################################
|
##################################################################################
|
||||||
|
|
||||||
spring.datasource.platform=hsqldb
|
|
||||||
database.base.url=/Users/veigap/
|
database.base.url=/Users/veigap/
|
||||||
spring.datasource.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping
|
spring.datasource.url=jdbc:hsqldb:file:${database.base.url}/db/wisemapping
|
||||||
spring.datasource.username=sa
|
spring.datasource.username=sa
|
||||||
spring.datasource.password=
|
spring.datasource.password=
|
||||||
|
|
||||||
spring.datasource.driver-class-name = org.hsqldb.jdbc.JDBCDriver
|
spring.datasource.driver-class-name = org.hsqldb.jdbc.JDBCDriver
|
||||||
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect
|
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.HSQLDialect
|
||||||
|
@ -1 +1 @@
|
|||||||
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURDATE());
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (2, 'admin@wisemapping.org', CURDATE());
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (2, 'Admin', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
COMMIT;
SHUTDOWN;
|
SET DATABASE SQL SYNTAX MYS TRUE;
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURDATE());
INSERT IGNORE INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (1, 'Test', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
INSERT INTO COLLABORATOR (id, email, creation_date) VALUES (1, 'test@wisemapping.org', CURDATE());
INSERT INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
INSERT IGNORE INTO USER (colaborator_id, firstname, lastname, password, activation_code, activation_date, allow_send_email,authentication_type)
VALUES (2, 'Admin', 'User', 'ENC:a94a8fe5ccb19ba61c4c0873d391e987982fbbd3', 1237, CURDATE(), 1,'D');
|
@ -1 +1 @@
|
|||||||
CREATE TABLE COLLABORATOR (
id INTEGER NOT NULL IDENTITY,
email VARCHAR(255) NOT NULL UNIQUE,
creation_date DATE
);
CREATE TABLE USER (
colaborator_id INTEGER NOT NULL IDENTITY,
authentication_type CHAR(1) NOT NULL,
authenticator_uri VARCHAR(255) NULL,
firstname VARCHAR(255) NOT NULL,
lastname VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
activation_code BIGINT NOT NULL,
activation_date DATE,
allow_send_email CHAR(1) NOT NULL,
locale VARCHAR(5),
google_sync BOOLEAN,
sync_code VARCHAR(255),
google_token VARCHAR(255),
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id)
);
CREATE TABLE MINDMAP (
id INTEGER NOT NULL IDENTITY,
title VARCHAR(255) NOT NULL,
description VARCHAR(255),
xml LONGVARBINARY NOT NULL,
public BOOLEAN NOT NULL,
creation_date DATETIME,
edition_date DATETIME,
creator_id INTEGER NOT NULL,
last_editor_id INTEGER NOT NULL
--FOREIGN KEY(creator_id) REFERENCES USER(colaborator_id)
);
CREATE TABLE LABEL (
id INTEGER NOT NULL PRIMARY KEY IDENTITY,
title VARCHAR(30),
creator_id INTEGER NOT NULL,
parent_label_id INTEGER,
color VARCHAR(7) NOT NULL,
--FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
);
CREATE TABLE R_LABEL_MINDMAP (
mindmap_id INTEGER NOT NULL,
label_id INTEGER NOT NULL,
PRIMARY KEY (mindmap_id, label_id),
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
FOREIGN KEY (label_id) REFERENCES LABEL (id) ON DELETE CASCADE ON UPDATE NO ACTION
);
creation_date DATE
CREATE TABLE USER (
id INTEGER NOT NULL IDENTITY,
xml LONGVARBINARY NOT NULL,
mindmap_id INTEGER NOT NULL,
creation_date DATETIME,
editor_id INTEGER NOT NULL,
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
);
CREATE TABLE COLLABORATION_PROPERTIES (
id INTEGER NOT NULL IDENTITY,
starred BOOLEAN NOT NULL,
mindmap_properties VARCHAR(512)
);
);
colaborator_id INTEGER NOT NULL IDENTITY,
id INTEGER NOT NULL IDENTITY,
colaborator_id INTEGER NOT NULL,
properties_id INTEGER NOT NULL,
mindmap_id INTEGER NOT NULL,
role_id INTEGER NOT NULL,
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
);
CREATE TABLE ACCESS_AUDITORY (
id INTEGER NOT NULL IDENTITY,
user_id INTEGER NOT NULL,
login_date DATE,
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
ON DELETE CASCADE
ON UPDATE NO ACTION
);
COMMIT;
|
CREATE TABLE IF NOT EXISTS COLLABORATOR (
id INTEGER NOT NULL IDENTITY,
email VARCHAR(255) NOT NULL UNIQUE,
creation_date DATE
);
CREATE TABLE USER (
);
colaborator_id INTEGER NOT NULL IDENTITY,
authentication_type CHAR(1) NOT NULL,
authenticator_uri VARCHAR(255) NULL,
firstname VARCHAR(255) NOT NULL,
lastname VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
activation_code BIGINT NOT NULL,
activation_date DATE,
allow_send_email CHAR(1) NOT NULL,
locale VARCHAR(5),
google_sync BOOLEAN,
sync_code VARCHAR(255),
google_token VARCHAR(255),
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id)
);
CREATE TABLE IF NOT EXISTS MINDMAP (
id INTEGER NOT NULL IDENTITY,
title VARCHAR(255) NOT NULL,
description VARCHAR(255),
xml LONGVARBINARY NOT NULL,
public BOOLEAN NOT NULL,
creation_date DATETIME,
edition_date DATETIME,
creator_id INTEGER NOT NULL,
last_editor_id INTEGER NOT NULL
--FOREIGN KEY(creator_id) REFERENCES USER(colaborator_id)
);
CREATE TABLE IF NOT EXISTS LABEL (
id INTEGER NOT NULL PRIMARY KEY IDENTITY,
title VARCHAR(30),
creator_id INTEGER NOT NULL,
parent_label_id INTEGER,
color VARCHAR(7) NOT NULL,
--FOREIGN KEY (creator_id) REFERENCES USER (colaborator_id)
);
CREATE TABLE IF NOT EXISTS R_LABEL_MINDMAP (
mindmap_id INTEGER NOT NULL,
label_id INTEGER NOT NULL,
PRIMARY KEY (mindmap_id, label_id),
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
FOREIGN KEY (label_id) REFERENCES LABEL (id) ON DELETE CASCADE ON UPDATE NO ACTION
);
CREATE TABLE USER (
authentication_type CHAR(1) NOT NULL,
id INTEGER NOT NULL IDENTITY,
xml LONGVARBINARY NOT NULL,
mindmap_id INTEGER NOT NULL,
creation_date DATETIME,
editor_id INTEGER NOT NULL,
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id)
);
CREATE TABLE IF NOT EXISTS COLLABORATION_PROPERTIES (
id INTEGER NOT NULL IDENTITY,
starred BOOLEAN NOT NULL,
mindmap_properties VARCHAR(512)
);
colaborator_id INTEGER NOT NULL IDENTITY,
COLLABORATOR (
id INTEGER NOT NULL IDENTITY,
colaborator_id INTEGER NOT NULL,
properties_id INTEGER NOT NULL,
mindmap_id INTEGER NOT NULL,
role_id INTEGER NOT NULL,
FOREIGN KEY (colaborator_id) REFERENCES COLLABORATOR (id),
FOREIGN KEY (mindmap_id) REFERENCES MINDMAP (id),
FOREIGN KEY (properties_id) REFERENCES COLLABORATION_PROPERTIES (id)
);
CREATE TABLE IF NOT EXISTS ACCESS_AUDITORY (
id INTEGER NOT NULL IDENTITY,
user_id INTEGER NOT NULL,
login_date DATE,
FOREIGN KEY (user_id) REFERENCES USER (colaborator_id)
ON DELETE CASCADE
ON UPDATE NO ACTION
);
|
@ -1,52 +1,68 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright [2022] [wisemapping]
|
* Copyright [2022] [wisemapping]
|
||||||
*
|
*
|
||||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||||
* "powered by wisemapping" text requirement on every single page;
|
* "powered by wisemapping" text requirement on every single page;
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the license at
|
* You may obtain a copy of the license at
|
||||||
*
|
*
|
||||||
* http://www.wisemapping.org/license
|
* http://www.wisemapping.org/license
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.wisemapping.test.rest;
|
package com.wisemapping.test.rest;
|
||||||
|
|
||||||
|
|
||||||
import com.wisemapping.config.Application;
|
import com.wisemapping.config.common.CommonConfig;
|
||||||
|
import com.wisemapping.config.rest.RestAppConfig;
|
||||||
|
import com.wisemapping.rest.AdminController;
|
||||||
|
import com.wisemapping.rest.MindmapController;
|
||||||
|
import com.wisemapping.rest.UserController;
|
||||||
import com.wisemapping.rest.model.RestUser;
|
import com.wisemapping.rest.model.RestUser;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Collection;
|
|
||||||
|
|
||||||
import static com.wisemapping.test.rest.RestHelper.*;
|
import static com.wisemapping.test.rest.RestHelper.*;
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
|
|
||||||
|
@SpringBootTest(classes = {RestAppConfig.class, CommonConfig.class, MindmapController.class, AdminController.class, UserController.class}, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
||||||
|
public class RestAccountControllerTest {
|
||||||
|
private static final String ADMIN_USER = "admin@wisemapping.org";
|
||||||
|
private static final String ADMIN_PASSWORD = "test";
|
||||||
|
|
||||||
@SpringBootTest(classes = Application.class)
|
@Autowired
|
||||||
public class RestAccountITCase {
|
private TestRestTemplate restTemplate;
|
||||||
|
|
||||||
|
static public RestAccountControllerTest create(@NotNull TestRestTemplate restTemplate) {
|
||||||
|
final RestAccountControllerTest result = new RestAccountControllerTest();
|
||||||
|
result.restTemplate = restTemplate;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
public void deleteUser() { // Configure media types ...
|
public void deleteUser() { // Configure media types ...
|
||||||
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final RestTemplate adminTemplate = createTemplate(ADMIN_CREDENTIALS);
|
final TestRestTemplate adminRestTemplate = this.restTemplate.withBasicAuth(ADMIN_USER, ADMIN_PASSWORD);
|
||||||
|
|
||||||
final RestUser dummyUser = createDummyUser();
|
final RestUser dummyUser = createDummyUser();
|
||||||
createUser(requestHeaders, adminTemplate, dummyUser);
|
createUser(requestHeaders, adminRestTemplate, dummyUser);
|
||||||
|
|
||||||
// Delete user ...
|
// Delete user ...
|
||||||
final RestTemplate dummyTemplate = createTemplate(dummyUser.getEmail() + ":fooPassword");
|
final TestRestTemplate dummyTemplate = this.restTemplate.withBasicAuth(dummyUser.getEmail(), "fooPassword");
|
||||||
dummyTemplate.delete(BASE_REST_URL + "/account");
|
dummyTemplate.delete(BASE_REST_URL + "/account");
|
||||||
|
|
||||||
// Is the user there ?
|
// Is the user there ?
|
||||||
@ -58,11 +74,11 @@ public class RestAccountITCase {
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public String createNewUser(final @NotNull MediaType mediaType) {
|
@Test
|
||||||
|
public RestUser createNewUser() {
|
||||||
// Configure media types ...
|
// Configure media types ...
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
final RestTemplate templateRest = createTemplate(ADMIN_CREDENTIALS);
|
final TestRestTemplate templateRest = this.restTemplate.withBasicAuth(ADMIN_USER, ADMIN_PASSWORD);
|
||||||
|
|
||||||
// Fill user data ...
|
// Fill user data ...
|
||||||
final RestUser restUser = createDummyUser();
|
final RestUser restUser = createDummyUser();
|
||||||
@ -78,26 +94,25 @@ public class RestAccountITCase {
|
|||||||
result = findUserByEmail(requestHeaders, templateRest, restUser.getEmail());
|
result = findUserByEmail(requestHeaders, templateRest, restUser.getEmail());
|
||||||
assertEquals(result.getBody().getEmail(), restUser.getEmail(), "Returned object object seems not be the same.");
|
assertEquals(result.getBody().getEmail(), restUser.getEmail(), "Returned object object seems not be the same.");
|
||||||
|
|
||||||
return restUser.getEmail();
|
return restUser;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ResponseEntity<RestUser> findUser(HttpHeaders requestHeaders, TestRestTemplate templateRest, URI location) {
|
||||||
private ResponseEntity<RestUser> findUser(HttpHeaders requestHeaders, RestTemplate templateRest, URI location) {
|
HttpEntity<RestUser> findUserEntity = new HttpEntity<>(requestHeaders);
|
||||||
HttpEntity<RestUser> findUserEntity = new HttpEntity<RestUser>(requestHeaders);
|
return templateRest.exchange(location.toString(), HttpMethod.GET, findUserEntity, RestUser.class);
|
||||||
final String url = HOST_PORT + location;
|
|
||||||
return templateRest.exchange(url, HttpMethod.GET, findUserEntity, RestUser.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ResponseEntity<RestUser> findUserByEmail(HttpHeaders requestHeaders, RestTemplate templateRest, final String email) {
|
private ResponseEntity<RestUser> findUserByEmail(HttpHeaders requestHeaders, TestRestTemplate templateRest, final String email) {
|
||||||
HttpEntity<RestUser> findUserEntity = new HttpEntity<RestUser>(requestHeaders);
|
HttpEntity<RestUser> findUserEntity = new HttpEntity<>(requestHeaders);
|
||||||
|
|
||||||
// Add extension only to avoid the fact that the last part is extracted ...
|
// Add extension only to avoid the fact that the last part is extracted ...
|
||||||
final String url = BASE_REST_URL + "/admin/users/email/{email}";
|
final String url = BASE_REST_URL + "/admin/users/email/{email}";
|
||||||
return templateRest.exchange(url, HttpMethod.GET, findUserEntity, RestUser.class, email);
|
return templateRest.exchange(url, HttpMethod.GET, findUserEntity, RestUser.class, email);
|
||||||
}
|
}
|
||||||
|
|
||||||
private URI createUser(HttpHeaders requestHeaders, RestTemplate templateRest, RestUser restUser) {
|
private URI createUser(@NotNull HttpHeaders requestHeaders, TestRestTemplate templateRest, RestUser restUser) {
|
||||||
HttpEntity<RestUser> createUserEntity = new HttpEntity< >(restUser, requestHeaders);
|
final HttpEntity<RestUser> createUserEntity = new HttpEntity<>(restUser, requestHeaders);
|
||||||
return templateRest.postForLocation(BASE_REST_URL + "/admin/users", createUserEntity);
|
return templateRest.postForLocation(BASE_REST_URL + "/admin/users", createUserEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,5 +126,4 @@ public class RestAccountITCase {
|
|||||||
restUser.setPassword("fooPassword");
|
restUser.setPassword("fooPassword");
|
||||||
return restUser;
|
return restUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,153 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright [2022] [wisemapping]
|
|
||||||
*
|
|
||||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
|
||||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
|
||||||
* "powered by wisemapping" text requirement on every single page;
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the license at
|
|
||||||
*
|
|
||||||
* http://www.wisemapping.org/license
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.wisemapping.test.rest;
|
|
||||||
|
|
||||||
|
|
||||||
import com.wisemapping.rest.model.RestUser;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.springframework.http.*;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
import static com.wisemapping.test.rest.RestHelper.*;
|
|
||||||
import static org.testng.Assert.assertEquals;
|
|
||||||
import static org.testng.Assert.fail;
|
|
||||||
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public class RestAdminITCase {
|
|
||||||
|
|
||||||
String authorisation = "admin@wisemapping.org" + ":" + "test";
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void changePassword(final @NotNull MediaType mediaType) { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate templateRest = createTemplate(authorisation);
|
|
||||||
|
|
||||||
// Fill user data ...
|
|
||||||
final RestUser restUser = createDummyUser();
|
|
||||||
|
|
||||||
// User has been created ...
|
|
||||||
final URI location = createUser(requestHeaders, templateRest, restUser);
|
|
||||||
|
|
||||||
// Check that the user has been created ...
|
|
||||||
ResponseEntity<RestUser> result = findUser(requestHeaders, templateRest, location);
|
|
||||||
|
|
||||||
// Change password ...
|
|
||||||
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
|
||||||
HttpEntity<String> createUserEntity = new HttpEntity<String>("some-new-password", requestHeaders);
|
|
||||||
templateRest.put(BASE_REST_URL + "/admin/users/{id}/password", createUserEntity, result.getBody().getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void deleteUser(final @NotNull MediaType mediaType) { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate templateRest = createTemplate(authorisation);
|
|
||||||
|
|
||||||
final RestUser restUser = createDummyUser();
|
|
||||||
|
|
||||||
// User has been created ...
|
|
||||||
final URI location = createUser(requestHeaders, templateRest, restUser);
|
|
||||||
|
|
||||||
// Check that the user has been created ...
|
|
||||||
ResponseEntity<RestUser> result = findUser(requestHeaders, templateRest, location);
|
|
||||||
|
|
||||||
// Delete user ...
|
|
||||||
templateRest.delete(BASE_REST_URL + "/admin/users/{id}", result.getBody().getId());
|
|
||||||
|
|
||||||
// Is the user there ?
|
|
||||||
// Check that the user has been created ...
|
|
||||||
try {
|
|
||||||
findUser(requestHeaders, templateRest, location);
|
|
||||||
fail("User could not be deleted !");
|
|
||||||
} catch (Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public RestUser createNewUserAndGetUser(final @NotNull MediaType mediaType) {
|
|
||||||
|
|
||||||
// Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate templateRest = createTemplate(authorisation);
|
|
||||||
|
|
||||||
// Fill user data ...
|
|
||||||
final RestUser restUser = createDummyUser();
|
|
||||||
|
|
||||||
// Create a new user ...
|
|
||||||
final URI location = createUser(requestHeaders, templateRest, restUser);
|
|
||||||
|
|
||||||
// Check that the user has been created ...
|
|
||||||
ResponseEntity<RestUser> result = findUser(requestHeaders, templateRest, location);
|
|
||||||
assertEquals(result.getBody().getEmail(), restUser.getEmail(), "Returned object object seems not be the same.");
|
|
||||||
|
|
||||||
return result.getBody();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String createNewUser(final @NotNull MediaType mediaType) {
|
|
||||||
|
|
||||||
// Fill user data ...
|
|
||||||
final RestUser restUser = createNewUserAndGetUser(mediaType);
|
|
||||||
// Find by email and check ...
|
|
||||||
// @todo: review find by email... It's failing with 406
|
|
||||||
// findUser(requestHeaders, templateRest, location);
|
|
||||||
// result = findUserByEmail(requestHeaders, templateRest, restUser.getEmail());
|
|
||||||
// assertEquals(result.getBody().getEmail(), restUser.getEmail(), "Returned object object seems not be the same.");
|
|
||||||
|
|
||||||
return restUser.getEmail();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void createUser(final @NotNull MediaType mediaType) {
|
|
||||||
this.createNewUser(mediaType);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ResponseEntity<RestUser> findUser(HttpHeaders requestHeaders, RestTemplate templateRest, URI location) {
|
|
||||||
HttpEntity<RestUser> findUserEntity = new HttpEntity<RestUser>(requestHeaders);
|
|
||||||
final String url = HOST_PORT + location;
|
|
||||||
return templateRest.exchange(url, HttpMethod.GET, findUserEntity, RestUser.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ResponseEntity<RestUser> findUserByEmail(HttpHeaders requestHeaders, RestTemplate templateRest, final String email) {
|
|
||||||
HttpEntity<RestUser> findUserEntity = new HttpEntity<>(requestHeaders);
|
|
||||||
|
|
||||||
// Add extension only to avoid the fact that the last part is extracted ...
|
|
||||||
final String url = BASE_REST_URL + "/admin/users/email/{email}";
|
|
||||||
return templateRest.exchange(url, HttpMethod.GET, findUserEntity, RestUser.class, email);
|
|
||||||
}
|
|
||||||
|
|
||||||
private URI createUser(HttpHeaders requestHeaders, RestTemplate templateRest, RestUser restUser) {
|
|
||||||
HttpEntity<RestUser> createUserEntity = new HttpEntity<RestUser>(restUser, requestHeaders);
|
|
||||||
return templateRest.postForLocation(BASE_REST_URL + "/admin/users", createUserEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
private RestUser createDummyUser() {
|
|
||||||
final RestUser restUser = new RestUser();
|
|
||||||
final String username = "foo-to-delete" + System.nanoTime();
|
|
||||||
final String email = username + "@example.org";
|
|
||||||
restUser.setEmail(email);
|
|
||||||
restUser.setFirstname("foo first name");
|
|
||||||
restUser.setLastname("foo last name");
|
|
||||||
restUser.setPassword("admin");
|
|
||||||
return restUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,24 +1,17 @@
|
|||||||
package com.wisemapping.test.rest;
|
package com.wisemapping.test.rest;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
import org.springframework.http.MediaType;
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
|
||||||
import org.springframework.security.crypto.codec.Base64;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.testng.annotations.DataProvider;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class RestHelper {
|
public class RestHelper {
|
||||||
|
public static final String BASE_REST_URL = "/api/restfull";
|
||||||
public static final String HOST_PORT = "http://localhost:8081";
|
|
||||||
public static final String BASE_REST_URL = HOST_PORT + "/api/restfull";
|
|
||||||
public static final String ADMIN_CREDENTIALS = "admin@wisemapping.org" + ":" + "test";
|
|
||||||
public static final String COLOR = "#000000";
|
|
||||||
|
|
||||||
static HttpHeaders createHeaders(@NotNull MediaType mediaType) {
|
static HttpHeaders createHeaders(@NotNull MediaType mediaType) {
|
||||||
List<MediaType> acceptableMediaTypes = new ArrayList<>();
|
List<MediaType> acceptableMediaTypes = new ArrayList<>();
|
||||||
@ -29,24 +22,4 @@ public class RestHelper {
|
|||||||
result.setContentType(mediaType);
|
result.setContentType(mediaType);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static RestTemplate createTemplate(@NotNull final String authorisation) {
|
|
||||||
SimpleClientHttpRequestFactory s = new SimpleClientHttpRequestFactory() {
|
|
||||||
@Override
|
|
||||||
protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
|
|
||||||
super.prepareConnection(connection, httpMethod);
|
|
||||||
|
|
||||||
byte[] encodedAuthorisation = Base64.encode(authorisation.getBytes());
|
|
||||||
connection.setRequestProperty("Authorization", "Basic " + new String(encodedAuthorisation));
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
return new RestTemplate(s);
|
|
||||||
}
|
|
||||||
|
|
||||||
@DataProvider(name = "ContentType-Provider-Function")
|
|
||||||
static Object[][] contentTypes() {
|
|
||||||
return new Object[][]{{MediaType.APPLICATION_JSON}};
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,831 @@
|
|||||||
|
package com.wisemapping.test.rest;
|
||||||
|
|
||||||
|
|
||||||
|
import com.wisemapping.config.common.CommonConfig;
|
||||||
|
import com.wisemapping.config.rest.RestAppConfig;
|
||||||
|
import com.wisemapping.exceptions.WiseMappingException;
|
||||||
|
import com.wisemapping.rest.AdminController;
|
||||||
|
import com.wisemapping.rest.MindmapController;
|
||||||
|
import com.wisemapping.rest.UserController;
|
||||||
|
import com.wisemapping.rest.model.*;
|
||||||
|
import jakarta.annotation.Nullable;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||||
|
import org.springframework.http.*;
|
||||||
|
import org.springframework.web.client.HttpClientErrorException;
|
||||||
|
import org.springframework.web.client.RestClientException;
|
||||||
|
import org.springframework.web.util.DefaultUriBuilderFactory;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static com.wisemapping.test.rest.RestHelper.createHeaders;
|
||||||
|
import static org.junit.jupiter.api.Assertions.*;
|
||||||
|
|
||||||
|
@SpringBootTest(classes = {RestAppConfig.class, CommonConfig.class, MindmapController.class, AdminController.class, UserController.class}, webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
|
||||||
|
public class RestMindmapControllerTest {
|
||||||
|
|
||||||
|
private RestUser user;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TestRestTemplate restTemplate;
|
||||||
|
|
||||||
|
private RestAccountControllerTest restAccount;
|
||||||
|
|
||||||
|
@BeforeEach
|
||||||
|
void createUser() {
|
||||||
|
|
||||||
|
// Remote debug ...
|
||||||
|
if (restTemplate == null) {
|
||||||
|
this.restTemplate = new TestRestTemplate();
|
||||||
|
this.restTemplate.setUriTemplateHandler(new DefaultUriBuilderFactory("http://localhost:8081/"));
|
||||||
|
}
|
||||||
|
this.restAccount = RestAccountControllerTest.create(restTemplate);
|
||||||
|
this.user = restAccount.createNewUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void listMaps() {
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final String title1 = "List Maps 1";
|
||||||
|
addNewMap(restTemplate, title1);
|
||||||
|
|
||||||
|
final String title2 = "List Maps 2";
|
||||||
|
addNewMap(restTemplate, title2);
|
||||||
|
|
||||||
|
// Validate that the two maps are there ...
|
||||||
|
final RestMindmapList body = fetchMaps(requestHeaders, restTemplate);
|
||||||
|
final List<RestMindmapInfo> mindmaps = body.getMindmapsInfo();
|
||||||
|
|
||||||
|
boolean found1 = false;
|
||||||
|
boolean found2 = false;
|
||||||
|
for (RestMindmapInfo mindmap : mindmaps) {
|
||||||
|
if (mindmap.getTitle().equals(title1)) {
|
||||||
|
found1 = true;
|
||||||
|
}
|
||||||
|
if (mindmap.getTitle().equals(title2)) {
|
||||||
|
found2 = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(found1 && found2, "Map could not be found");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void deleteMap() {
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final String title1 = "Map to delete";
|
||||||
|
final URI resourceUri = addNewMap(restTemplate, title1);
|
||||||
|
|
||||||
|
// Now remove it ...
|
||||||
|
restTemplate.delete(resourceUri.toString());
|
||||||
|
|
||||||
|
// Check that has been removed ...
|
||||||
|
try {
|
||||||
|
findMap(requestHeaders, restTemplate, resourceUri);
|
||||||
|
fail("Map could not be removed:" + resourceUri);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void changeMapTitle() {
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final URI resourceUri = addNewMap(restTemplate, "Map to change title");
|
||||||
|
final String newTitle = changeMapTitle(requestHeaders, MediaType.APPLICATION_JSON, restTemplate, resourceUri);
|
||||||
|
|
||||||
|
// Load map again ..
|
||||||
|
final RestMindmap map = findMap(requestHeaders, restTemplate, resourceUri);
|
||||||
|
assertEquals(newTitle, map.getTitle());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void validateMapsCreation() { // Configure media types ...
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
requestHeaders.set(HttpHeaders.ACCEPT_LANGUAGE, "en");
|
||||||
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final String title = "Map to Validate Creation";
|
||||||
|
addNewMap(restTemplate, title);
|
||||||
|
|
||||||
|
// Add map with same name ...
|
||||||
|
HttpEntity<RestMindmap> createUserEntity = new HttpEntity<>(requestHeaders);
|
||||||
|
final ResponseEntity<String> response = restTemplate.exchange("/api/restfull/maps?title=" + title, HttpMethod.POST, createUserEntity, String.class);
|
||||||
|
assertEquals(HttpStatus.BAD_REQUEST, response.getStatusCode());
|
||||||
|
assertTrue(Objects.requireNonNull(response.getBody()).contains("You have already a map with the same name"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void changeMapDescription() {
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final URI resourceUri = addNewMap(restTemplate, "Map to change Description ");
|
||||||
|
|
||||||
|
// Change map title ...
|
||||||
|
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||||
|
final String newDescription = "New map to change description ";
|
||||||
|
final HttpEntity<String> updateEntity = new HttpEntity<>(newDescription, requestHeaders);
|
||||||
|
restTemplate.put(resourceUri + "/description", updateEntity);
|
||||||
|
|
||||||
|
// Load map again ..
|
||||||
|
final RestMindmap map = findMap(requestHeaders, restTemplate, resourceUri);
|
||||||
|
assertEquals(newDescription, map.getDescription());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateMapXml() throws IOException { // Configure media types ...
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final String title = "Update XML sample";
|
||||||
|
final URI resourceUri = addNewMap(restTemplate, title);
|
||||||
|
|
||||||
|
// Update map xml content ...
|
||||||
|
final String resourceUrl = resourceUri.toString();
|
||||||
|
String newXmlContent = updateMapDocument(requestHeaders, restTemplate, resourceUrl, null);
|
||||||
|
|
||||||
|
// Check that the map has been updated ...
|
||||||
|
final RestMindmap response = findMap(requestHeaders, restTemplate, resourceUri);
|
||||||
|
assertEquals(response.getXml(), newXmlContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String updateMapDocument(final HttpHeaders requestHeaders, final TestRestTemplate template, final String resourceUrl, String content) throws RestClientException {
|
||||||
|
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||||
|
final String newXmlContent = content != null ? content : "<map>this is not valid</map>";
|
||||||
|
HttpEntity<String> updateEntity = new HttpEntity<>(newXmlContent, requestHeaders);
|
||||||
|
template.put(resourceUrl + "/document/xml", updateEntity);
|
||||||
|
return newXmlContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void cloneMap() throws IOException { // Configure media types ...
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final String title = "Map to clone sample ";
|
||||||
|
final String xml = "<map><node text='this is a cloned map'></map>";
|
||||||
|
final URI newMapUri = addNewMap(restTemplate, title, xml);
|
||||||
|
|
||||||
|
// Clone map ...
|
||||||
|
final RestMindmapInfo restMindmap = new RestMindmapInfo();
|
||||||
|
restMindmap.setTitle("Cloned map but with previous content.");
|
||||||
|
restMindmap.setDescription("Cloned map desc");
|
||||||
|
|
||||||
|
// Create a new map ...
|
||||||
|
final HttpEntity<RestMindmapInfo> cloneEntity = new HttpEntity<>(restMindmap, requestHeaders);
|
||||||
|
final URI clonedMapUri = restTemplate.postForLocation(newMapUri, cloneEntity);
|
||||||
|
|
||||||
|
// Check that the map has been updated ...
|
||||||
|
final RestMindmap response = findMap(requestHeaders, restTemplate, clonedMapUri);
|
||||||
|
assertEquals(response.getXml(), xml);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateStarred() { // Configure media types ...
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final String title1 = "Stared Map user 1";
|
||||||
|
URI mapUri = addNewMap(restTemplate, title1);
|
||||||
|
|
||||||
|
// Update starred ...
|
||||||
|
final String resourceUrl = 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);
|
||||||
|
restTemplate.put(resourceUrl, updateEntity);
|
||||||
|
|
||||||
|
// Has been updated ?.
|
||||||
|
|
||||||
|
final HttpEntity<String> findLabelEntity = new HttpEntity<>(createHeaders(MediaType.TEXT_PLAIN));
|
||||||
|
final ResponseEntity<String> response = restTemplate.exchange(resourceUrl, HttpMethod.GET, findLabelEntity, String.class);
|
||||||
|
|
||||||
|
assertTrue(Boolean.parseBoolean(response.getBody()), "Starred has been updated");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void verifyMapOwnership() {
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
final TestRestTemplate firstUser = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final String title1 = "verifyMapOwnership Map user 1";
|
||||||
|
addNewMap(firstUser, title1);
|
||||||
|
|
||||||
|
//create another user
|
||||||
|
final RestUser secondUser = RestAccountControllerTest.create(this.restTemplate).createNewUser();
|
||||||
|
final TestRestTemplate secondTemplate = this.restTemplate.withBasicAuth(secondUser.getEmail(), secondUser.getPassword());
|
||||||
|
|
||||||
|
final String title2 = "verifyMapOwnership Map user 2";
|
||||||
|
addNewMap(secondTemplate, title2);
|
||||||
|
|
||||||
|
final TestRestTemplate superadminTemplate = this.restTemplate.withBasicAuth("admin@wisemapping.org", "test");
|
||||||
|
superadminTemplate.delete("/admin/users/" + secondUser.getId());
|
||||||
|
|
||||||
|
// Validate that the two maps are there ...
|
||||||
|
final RestMindmapList body = fetchMaps(requestHeaders, firstUser);
|
||||||
|
final List<RestMindmapInfo> mindmaps = body.getMindmapsInfo();
|
||||||
|
|
||||||
|
final Optional<RestMindmapInfo> any = mindmaps.stream().filter(m -> m.getTitle().equals(title1)).findAny();
|
||||||
|
assertTrue(any.isPresent(), "Map could not be found");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateMap() throws IOException, WiseMappingException {
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final String title = "Update sample ";
|
||||||
|
final URI resourceUri = addNewMap(restTemplate, title);
|
||||||
|
|
||||||
|
// Build map to update ...
|
||||||
|
final RestMindmap mapToUpdate = new RestMindmap();
|
||||||
|
mapToUpdate.setXml("<map>this is not valid</map>");
|
||||||
|
mapToUpdate.setProperties("{zoom:x}");
|
||||||
|
|
||||||
|
// Create lock ...
|
||||||
|
final HttpHeaders lockHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
lockHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||||
|
|
||||||
|
// Update map ...
|
||||||
|
final String resourceUrl = resourceUri.toString() + "/document";
|
||||||
|
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
|
||||||
|
final HttpEntity<RestMindmap> updateEntity = new HttpEntity<>(mapToUpdate, requestHeaders);
|
||||||
|
restTemplate.put(resourceUrl, updateEntity);
|
||||||
|
|
||||||
|
// Check that the map has been updated ...
|
||||||
|
HttpEntity<RestUser> findMapEntity = new HttpEntity<>(requestHeaders);
|
||||||
|
final ResponseEntity<RestMindmap> response = restTemplate.exchange(resourceUri, HttpMethod.GET, findMapEntity, RestMindmap.class);
|
||||||
|
assertEquals(response.getBody().getXml(), mapToUpdate.getXml());
|
||||||
|
assertEquals(response.getBody().getProperties(), mapToUpdate.getProperties());
|
||||||
|
|
||||||
|
// Unlock ...
|
||||||
|
HttpEntity<String> lockEntity = new HttpEntity<>("false", lockHeaders);
|
||||||
|
restTemplate.exchange(resourceUri + "/lock", HttpMethod.PUT, lockEntity, RestLockInfo.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void addCollabs() {
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final URI resourceUri = addNewMap(restTemplate, "Map for addCollabs - ");
|
||||||
|
|
||||||
|
String newCollab = addNewCollaboration(requestHeaders, restTemplate, resourceUri);
|
||||||
|
|
||||||
|
// Has been added ?
|
||||||
|
RestCollaborationList responseCollbs = fetchAndGetCollabs(requestHeaders, restTemplate, resourceUri);
|
||||||
|
|
||||||
|
// Has been added ?
|
||||||
|
assertEquals(responseCollbs.getCount(), 2);
|
||||||
|
|
||||||
|
final Optional<RestCollaboration> addedCollab = responseCollbs.getCollaborations().stream().filter(c -> c.getEmail().equals(newCollab)).findAny();
|
||||||
|
assertTrue(addedCollab.isPresent());
|
||||||
|
assertEquals(addedCollab.get().getRole(), "editor");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void updateCollabType() {
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final URI resourceUri = addNewMap(restTemplate, "Map for updateCollabType");
|
||||||
|
|
||||||
|
// Add a new collaboration ...
|
||||||
|
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
final RestCollaborationList collabs = new RestCollaborationList();
|
||||||
|
collabs.setMessage("Adding new permission");
|
||||||
|
|
||||||
|
final String newCollab = "new-collab@example.com";
|
||||||
|
String role = "editor";
|
||||||
|
|
||||||
|
final RestCollaboration collab = addCollabToList(newCollab, role, collabs);
|
||||||
|
|
||||||
|
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||||
|
restTemplate.put(resourceUri + "/collabs/", updateEntity);
|
||||||
|
|
||||||
|
// Has been added ?
|
||||||
|
RestCollaborationList responseCollbs = fetchAndGetCollabs(requestHeaders, restTemplate, resourceUri);
|
||||||
|
assertEquals(responseCollbs.getCount(), 2);
|
||||||
|
|
||||||
|
// Update the collaboration type ...
|
||||||
|
collab.setRole("viewer");
|
||||||
|
restTemplate.put(resourceUri + "/collabs/", updateEntity);
|
||||||
|
|
||||||
|
// Has been added ?
|
||||||
|
final ResponseEntity<RestCollaborationList> afterResponse = fetchCollabs(requestHeaders, restTemplate, resourceUri);
|
||||||
|
final Optional<RestCollaboration> updatedCollab = afterResponse.getBody().getCollaborations().stream().filter(c -> c.getEmail().equals(newCollab)).findAny();
|
||||||
|
assertTrue(updatedCollab.isPresent());
|
||||||
|
assertEquals(updatedCollab.get().getRole(), "viewer");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void deleteCollabs() {
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final URI resourceUri = addNewMap(restTemplate, "Map for deleteCollabs - ");
|
||||||
|
|
||||||
|
String newCollab = addNewCollaboration(requestHeaders, restTemplate, resourceUri);
|
||||||
|
|
||||||
|
// Has been added ?
|
||||||
|
RestCollaborationList responseCollbs = fetchAndGetCollabs(requestHeaders, restTemplate, resourceUri);
|
||||||
|
|
||||||
|
// Has been added ?
|
||||||
|
assertEquals(responseCollbs.getCount(), 2);
|
||||||
|
|
||||||
|
// Now, remove it ...
|
||||||
|
restTemplate.delete(resourceUri + "/collabs?email=" + newCollab);
|
||||||
|
|
||||||
|
// Check that it has been removed ...
|
||||||
|
final ResponseEntity<RestCollaborationList> afterDeleteResponse = fetchCollabs(requestHeaders, restTemplate, resourceUri);
|
||||||
|
assertEquals(afterDeleteResponse.getBody().getCollaborations().size(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String addNewCollaboration(final HttpHeaders requestHeaders, final TestRestTemplate template, final URI resourceUri) throws RestClientException {
|
||||||
|
// Add a new collaboration ...
|
||||||
|
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
final RestCollaborationList collabs = new RestCollaborationList();
|
||||||
|
collabs.setMessage("Adding new permission");
|
||||||
|
final String newCollab = "new-collab@example.com";
|
||||||
|
String role = "editor";
|
||||||
|
addCollabToList(newCollab, role, collabs);
|
||||||
|
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||||
|
template.put(resourceUri + "/collabs/", updateEntity);
|
||||||
|
return newCollab;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void deleteCollabsWithInvalidEmail() {
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
|
||||||
|
// Create a sample map ...
|
||||||
|
final URI resourceUri = addNewMap(restTemplate, "deleteCollabsWithInvalidEmail");
|
||||||
|
|
||||||
|
// Remove with invalid email ...
|
||||||
|
try {
|
||||||
|
restTemplate.delete(resourceUri + "/collabs?email=invalidEmail");
|
||||||
|
} catch (HttpClientErrorException e) {
|
||||||
|
assertEquals(e.getRawStatusCode(), 400);
|
||||||
|
assertTrue(e.getMessage().contains("Invalid email exception:"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that it has been removed ...
|
||||||
|
final ResponseEntity<RestCollaborationList> afterDeleteResponse = fetchCollabs(requestHeaders, restTemplate, resourceUri);
|
||||||
|
assertEquals(Objects.requireNonNull(afterDeleteResponse.getBody()).getCollaborations().size(), 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Test
|
||||||
|
// public void deleteCollabsWithoutOwnerPermission() {
|
||||||
|
// final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_JSON);
|
||||||
|
// final TestRestTemplate restTemplate = this.restTemplate.withBasicAuth(user.getEmail(), user.getPassword());
|
||||||
|
//
|
||||||
|
// // Create a sample map ...
|
||||||
|
// final URI resourceUri = addNewMap(restTemplate, "deleteWithoutOwnerPermission");
|
||||||
|
//
|
||||||
|
// final String newCollab = restAdminITCase.createNewUser(MediaType.APPLICATION_JSON);
|
||||||
|
// template = createTemplate(newCollab + ":admin");
|
||||||
|
//
|
||||||
|
// // Remove with invalid email ...
|
||||||
|
// try {
|
||||||
|
//
|
||||||
|
// template.delete(HOST_PORT + resourceUri + "/collabs?email=" + newCollab);
|
||||||
|
// } catch (HttpClientErrorException e) {
|
||||||
|
// assertEquals(e.getRawStatusCode(), 400);
|
||||||
|
// assertTrue(e.getMessage().contains("No enough permissions"));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
|
// public void deleteOwnerCollab(final @NotNull MediaType mediaType) {
|
||||||
|
// final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
// final RestTemplate template = createTemplate(userEmail);
|
||||||
|
//
|
||||||
|
// // Create a sample map ...
|
||||||
|
// final URI resourceUri = addNewMap(template, "Map for deleteOwnerCollab");
|
||||||
|
//
|
||||||
|
// // Now, remove owner collab ...
|
||||||
|
// try {
|
||||||
|
// template.delete(HOST_PORT + resourceUri + "/collabs?email=" + userEmail.replace(":admin", ""));
|
||||||
|
// } catch (HttpClientErrorException e) {
|
||||||
|
// assertEquals(e.getRawStatusCode(), 400);
|
||||||
|
// assertTrue(e.getMessage().contains("Can not remove owner collab"));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private ResponseEntity<RestCollaborationList> fetchCollabs(HttpHeaders requestHeaders, TestRestTemplate template, URI resourceUri) {
|
||||||
|
final HttpEntity<RestCollaborationList> findCollabs = new HttpEntity(requestHeaders);
|
||||||
|
return template.exchange(resourceUri + "/collabs", HttpMethod.GET, findCollabs, RestCollaborationList.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// @Test(dataProviderClass = RestHelper.class, expectedExceptions = {HttpClientErrorException.class}, dataProvider = "ContentType-Provider-Function")
|
||||||
|
// public void addCollabsInvalidOwner(final @NotNull MediaType mediaType) {
|
||||||
|
//
|
||||||
|
// final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
// final RestTemplate template = createTemplate(userEmail);
|
||||||
|
//
|
||||||
|
// // Create a sample map ...fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
||||||
|
// final URI resourceUri = addNewMap(template, "Map for Collaboration - " + mediaType);
|
||||||
|
//
|
||||||
|
// // Add a new collaboration ...
|
||||||
|
// requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
// final RestCollaborationList collabs = new RestCollaborationList();
|
||||||
|
// collabs.setMessage("Adding new permission");
|
||||||
|
//
|
||||||
|
// // Validate that owner can not be added.
|
||||||
|
// addCollabToList("newCollab@example", "owner", collabs);
|
||||||
|
//
|
||||||
|
// final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||||
|
// template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
|
// public void removeLabelFromMindmap(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 = "removeLabelFromMindmap";
|
||||||
|
// final URI labelUri = RestLabelITCase.addNewLabel(requestHeaders, template, titleLabel, COLOR);
|
||||||
|
//
|
||||||
|
// // Create a sample map ...
|
||||||
|
// final String mapTitle = "removeLabelFromMindmap";
|
||||||
|
// final URI mindmapUri = addNewMap(template, mapTitle);
|
||||||
|
// final String mapId = mindmapUri.getPath().replace("/api/restfull/maps/", "");
|
||||||
|
//
|
||||||
|
// // Assign label to map ...
|
||||||
|
// String labelId = labelUri.getPath().replace("/api/restfull/labels/", "");
|
||||||
|
// HttpEntity<String> labelEntity = new HttpEntity<>(labelId, requestHeaders);
|
||||||
|
// template.postForLocation(BASE_REST_URL + "/maps/" + mapId + "/labels", labelEntity);
|
||||||
|
//
|
||||||
|
// // Remove label from map
|
||||||
|
// 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 ...
|
||||||
|
// final List<RestMindmapInfo> mindmapsInfo = fetchMaps(requestHeaders, template).getMindmapsInfo();
|
||||||
|
// Optional<RestMindmapInfo> mindmapInfo = mindmapsInfo
|
||||||
|
// .stream()
|
||||||
|
// .filter(m -> m.getId() == Integer.parseInt(mapId))
|
||||||
|
// .findAny();
|
||||||
|
// return mindmapInfo;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
|
// public void deleteMapAndCheckLabels(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||||
|
// throw new SkipException("missing test: delete map should not affects others labels");
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @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;
|
||||||
|
// final URI labelUri = RestLabelITCase.addNewLabel(requestHeaders, template, titleLabel, COLOR);
|
||||||
|
//
|
||||||
|
// // Create a sample map ...
|
||||||
|
// final String mapTitle = "Maps 1 - " + mediaType;
|
||||||
|
// final URI mindmapUri = addNewMap(template, mapTitle);
|
||||||
|
// final String mapId = mindmapUri.getPath().replace("/api/restfull/maps/", "");
|
||||||
|
//
|
||||||
|
// // Assign label to map ...
|
||||||
|
// String labelId = labelUri.getPath().replace("/api/restfull/labels/", "");
|
||||||
|
// HttpEntity<String> labelEntity = new HttpEntity<>(labelId, requestHeaders);
|
||||||
|
// template.postForLocation(BASE_REST_URL + "/maps/" + mapId + "/labels", labelEntity);
|
||||||
|
//
|
||||||
|
// // Check that the label has been assigned ...
|
||||||
|
// Optional<RestMindmapInfo> mindmapInfo = fetchMap(requestHeaders, template, mapId);
|
||||||
|
//
|
||||||
|
// assertTrue(mindmapInfo.get().getLabels().size() == 1);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
|
// public void updateCollabs(final @NotNull MediaType mediaType) {
|
||||||
|
//
|
||||||
|
// // Create a sample map ...
|
||||||
|
// final RestTemplate template = createTemplate(userEmail);
|
||||||
|
// final URI resourceUri = addNewMap(template, "Map for updateCollabs - " + mediaType);
|
||||||
|
//
|
||||||
|
// final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
// // Add a new collaboration ...
|
||||||
|
// requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
// RestCollaborationList collabs = new RestCollaborationList();
|
||||||
|
// collabs.setMessage("Adding new permission");
|
||||||
|
//
|
||||||
|
// String newCollab = "new-collab@example.com";
|
||||||
|
// String role = "editor";
|
||||||
|
//
|
||||||
|
// addCollabToList(newCollab, role, collabs);
|
||||||
|
//
|
||||||
|
// HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||||
|
// template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||||
|
//
|
||||||
|
// collabs = fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
||||||
|
//
|
||||||
|
// //delete one collab
|
||||||
|
// collabs.setCollaborations(collabs.getCollaborations().stream().filter(c -> c.getRole().equals("owner")).collect(Collectors.toList()));
|
||||||
|
//
|
||||||
|
// //Add another collaborationMediaType
|
||||||
|
// newCollab = "another-collab@example.com";
|
||||||
|
// addCollabToList(newCollab, role, collabs);
|
||||||
|
//
|
||||||
|
// //add owner to list
|
||||||
|
// addCollabToList(userEmail.replace(":admin", ""), "owner", collabs);
|
||||||
|
//
|
||||||
|
// updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||||
|
// template.postForLocation(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// RestCollaborationList responseCollbs = fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
||||||
|
//
|
||||||
|
// // Has been another-collaboration list updated ?
|
||||||
|
// assertTrue(responseCollbs.getCollaborations().stream().anyMatch(x -> x.getEmail().equals("another-collab@example.com")));
|
||||||
|
// assertEquals(responseCollbs.getCount(), 2);
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
|
// public void updateProperties(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||||
|
// final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
// final RestTemplate template = createTemplate(userEmail);
|
||||||
|
//
|
||||||
|
// // Create a sample map ...
|
||||||
|
// final String title = "updateProperties map";
|
||||||
|
// final URI resourceUri = addNewMap(template, title);
|
||||||
|
//
|
||||||
|
// // Build map to update ...
|
||||||
|
// final RestMindmap mapToUpdate = new RestMindmap();
|
||||||
|
// mapToUpdate.setXml("<map>this is not valid</map>");
|
||||||
|
// mapToUpdate.setProperties("{zoom:x}");
|
||||||
|
// mapToUpdate.setTitle("new title for map");
|
||||||
|
// mapToUpdate.setDescription("updated map description");
|
||||||
|
//
|
||||||
|
// // Update map ...
|
||||||
|
// final String resourceUrl = HOST_PORT + resourceUri.toString();
|
||||||
|
// final HttpEntity<RestMindmap> updateEntity = new HttpEntity<>(mapToUpdate, requestHeaders);
|
||||||
|
// template.put(resourceUrl, updateEntity);
|
||||||
|
//
|
||||||
|
// // Check that the map has been updated ...
|
||||||
|
// HttpEntity<RestUser> findMapEntity = new HttpEntity<>(requestHeaders);
|
||||||
|
// final ResponseEntity<RestMindmap> response = template.exchange(HOST_PORT + resourceUri, HttpMethod.GET, findMapEntity, RestMindmap.class);
|
||||||
|
// assertEquals(response.getBody().getTitle(), mapToUpdate.getTitle());
|
||||||
|
// assertEquals(response.getBody().getDescription(), mapToUpdate.getDescription());
|
||||||
|
// assertEquals(response.getBody().getXml(), mapToUpdate.getXml());
|
||||||
|
// assertEquals(response.getBody().getProperties(), mapToUpdate.getProperties());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
|
// public void batchDelete(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||||
|
// final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
// final RestTemplate template = createTemplate(userEmail);
|
||||||
|
//
|
||||||
|
// // Create a sample map ...
|
||||||
|
// final String title1 = "Batch delete map 1";
|
||||||
|
// addNewMap(template, title1);
|
||||||
|
//
|
||||||
|
// final String title2 = "Batch delete map 2";
|
||||||
|
// addNewMap(template, title2);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// String maps;
|
||||||
|
// maps = fetchMaps(requestHeaders, template).getMindmapsInfo().stream().map(map -> {
|
||||||
|
// return String.valueOf(map.getId());
|
||||||
|
// }).collect(Collectors.joining(","));
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// template.delete(BASE_REST_URL + "/maps/batch?ids=" + maps);
|
||||||
|
//
|
||||||
|
// // Validate that the two maps are there ...
|
||||||
|
// final RestMindmapList body = fetchMaps(requestHeaders, template);
|
||||||
|
// assertEquals(body.getMindmapsInfo().size(), 0);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
|
// public void updatePublishState(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
||||||
|
// final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
// final RestTemplate template = createTemplate(userEmail);
|
||||||
|
//
|
||||||
|
// // Create a sample map ...
|
||||||
|
// final String mapTitle = "updatePublishState";
|
||||||
|
// final URI mindmapUri = addNewMap(template, mapTitle);
|
||||||
|
// final String mapId = mindmapUri.getPath().replace("/api/restfull/maps/", "");
|
||||||
|
//
|
||||||
|
// // Change map status ...
|
||||||
|
// requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||||
|
// //final String newPublicState = "true";
|
||||||
|
// final HttpEntity<String> updateEntity = new HttpEntity<>(Boolean.TRUE.toString(), requestHeaders);
|
||||||
|
// template.put(HOST_PORT + mindmapUri + "/publish", updateEntity);
|
||||||
|
//
|
||||||
|
//// //fetch public view
|
||||||
|
//// final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
||||||
|
//// ResponseEntity<String> publicView = template.exchange(HOST_PORT + mapId + "/public", HttpMethod.GET, findMapEntity, String.class);
|
||||||
|
//// assertNotNull(publicView.getBody());
|
||||||
|
//// assertEquals(publicView.getStatusCodeValue(), 200);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
|
// public void fetchMapHistory(final @NotNull MediaType mediaType) { // Configure media types ...
|
||||||
|
// final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
// final RestTemplate template = createTemplate(userEmail);
|
||||||
|
//
|
||||||
|
// // Create a sample map ...
|
||||||
|
// final URI resourceUri = addNewMap(template, "Map to change title - " + mediaType);
|
||||||
|
//
|
||||||
|
// updateMapDocument(requestHeaders, template, HOST_PORT + resourceUri.toString());
|
||||||
|
//
|
||||||
|
// //fetch map history
|
||||||
|
// final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
||||||
|
// final ResponseEntity<RestMindmapHistoryList> maps = template.exchange(HOST_PORT + resourceUri + "/history/", HttpMethod.GET, findMapEntity, RestMindmapHistoryList.class);
|
||||||
|
// assertEquals(maps.getBody().getCount(), 1);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
|
// public void updateRevertMindmap(final @NotNull MediaType mediaType) throws IOException { // Configure media types ...
|
||||||
|
// final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
// final RestTemplate template = createTemplate(userEmail);
|
||||||
|
//
|
||||||
|
// // Create a sample map ...
|
||||||
|
// final URI resourceUri = addNewMap(template, "map to test revert changes");
|
||||||
|
// updateMapDocument(requestHeaders, template, HOST_PORT + resourceUri.toString(), "<map><node text='this is an xml to test revert changes service'></map>");
|
||||||
|
//
|
||||||
|
// updateMapDocument(requestHeaders, template, HOST_PORT + resourceUri.toString(), "<map><node text='this is an xml with modification to be reverted'></map>");
|
||||||
|
//
|
||||||
|
// //fetch map history
|
||||||
|
// final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
||||||
|
// final ResponseEntity<RestMindmapHistoryList> mapHistories = template.exchange(HOST_PORT + resourceUri + "/history/", HttpMethod.GET, findMapEntity, RestMindmapHistoryList.class);
|
||||||
|
//
|
||||||
|
// //aply revert
|
||||||
|
// final HttpEntity<String> cloneEntity = new HttpEntity<>(requestHeaders);
|
||||||
|
// template.postForLocation(HOST_PORT + resourceUri + "/history/latest", cloneEntity);
|
||||||
|
// final RestMindmap latestStoredMap = findMap(requestHeaders, template, resourceUri);
|
||||||
|
// template.postForLocation(HOST_PORT + resourceUri + "/history/" + mapHistories.getBody().getChanges().get(1).getId(), cloneEntity);
|
||||||
|
// final RestMindmap firstVersionMap = findMap(requestHeaders, template, resourceUri);
|
||||||
|
//
|
||||||
|
// //verify revert
|
||||||
|
// assertEquals(firstVersionMap.getXml(), "<map><node text='this is an xml to test revert changes service'></map>");
|
||||||
|
// assertEquals(latestStoredMap.getXml(), "<map><node text='this is an xml with modification to be reverted'></map>");
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
|
// public void addCollabWhitoutOwnerPermission(final @NotNull MediaType mediaType) {
|
||||||
|
// final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
// RestTemplate template = createTemplate(userEmail);
|
||||||
|
//
|
||||||
|
// // Create a sample map ...
|
||||||
|
// final URI resourceUri = addNewMap(template, "MaddCollabWhitoutOwnerPermission");
|
||||||
|
//
|
||||||
|
// // Add a new collaboration ...
|
||||||
|
// requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
// final RestCollaborationList collabs = new RestCollaborationList();
|
||||||
|
// collabs.setMessage("Adding new permission");
|
||||||
|
//
|
||||||
|
// final String newCollab = restAdminITCase.createNewUser(MediaType.APPLICATION_JSON);
|
||||||
|
// String role = "editor";
|
||||||
|
//
|
||||||
|
// addCollabToList(newCollab, role, collabs);
|
||||||
|
//
|
||||||
|
// final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||||
|
// template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||||
|
//
|
||||||
|
// template = createTemplate(newCollab + ":admin");
|
||||||
|
// //add collab again with the new user expecting the Exception
|
||||||
|
// try {
|
||||||
|
// template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||||
|
// } catch (HttpClientErrorException e) {
|
||||||
|
// assertEquals(e.getRawStatusCode(), 400);
|
||||||
|
// assertTrue(e.getMessage().contains("User must be owner to share mindmap"));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
||||||
|
// public void addCollabWhitOwnerRole(final @NotNull MediaType mediaType) {
|
||||||
|
// final HttpHeaders requestHeaders = createHeaders(mediaType);
|
||||||
|
// RestTemplate template = createTemplate(userEmail);
|
||||||
|
//
|
||||||
|
// // Create a sample map ...
|
||||||
|
// final URI resourceUri = addNewMap(template, "addCollabWhitOwnerRole");
|
||||||
|
//
|
||||||
|
// // Add a new collaboration ...
|
||||||
|
// requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
// final RestCollaborationList collabs = new RestCollaborationList();
|
||||||
|
// collabs.setMessage("Adding new permission");
|
||||||
|
//
|
||||||
|
// final String newCollab = "new-collaborator@mail.com";
|
||||||
|
// String role = "owner";
|
||||||
|
//
|
||||||
|
// addCollabToList(newCollab, role, collabs);
|
||||||
|
//
|
||||||
|
// final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
||||||
|
// try {
|
||||||
|
// template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
||||||
|
// } catch (HttpClientErrorException e) {
|
||||||
|
// assertEquals(e.getRawStatusCode(), 400);
|
||||||
|
// assertTrue(e.getMessage().contains("Collab email can not be change"));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
private String changeMapTitle(final HttpHeaders requestHeaders, final MediaType mediaType, final TestRestTemplate template, final URI resourceUri) throws RestClientException {
|
||||||
|
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
||||||
|
final String result = "New map to change title - " + mediaType;
|
||||||
|
final HttpEntity<String> updateEntity = new HttpEntity<>(result, requestHeaders);
|
||||||
|
template.put(resourceUri + "/title", updateEntity);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private RestMindmapList fetchMaps(final HttpHeaders requestHeaders, final TestRestTemplate template) throws RestClientException {
|
||||||
|
final HttpEntity<RestMindmapList> findMapEntity = new HttpEntity<>(requestHeaders);
|
||||||
|
final ResponseEntity<RestMindmapList> response = template.exchange("/api/restfull/maps/", HttpMethod.GET, findMapEntity, RestMindmapList.class);
|
||||||
|
assertTrue(response.getStatusCode().is2xxSuccessful(), response.toString());
|
||||||
|
|
||||||
|
return Objects.requireNonNull(response.getBody());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private RestCollaborationList fetchAndGetCollabs(final HttpHeaders requestHeaders, final TestRestTemplate template, final URI resourceUri) {
|
||||||
|
final ResponseEntity<RestCollaborationList> response = fetchCollabs(requestHeaders, template, resourceUri);
|
||||||
|
RestCollaborationList responseCollbs = response.getBody();
|
||||||
|
return responseCollbs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private RestCollaboration addCollabToList(String newCollab, String role, RestCollaborationList collabs) {
|
||||||
|
RestCollaboration collab = new RestCollaboration();
|
||||||
|
collab.setEmail(newCollab);
|
||||||
|
collab.setRole(role);
|
||||||
|
collabs.addCollaboration(collab);
|
||||||
|
return collab;
|
||||||
|
}
|
||||||
|
|
||||||
|
private RestMindmap findMap(@NotNull HttpHeaders requestHeaders, @NotNull TestRestTemplate template, URI resourceUri) {
|
||||||
|
final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
||||||
|
final ResponseEntity<RestMindmap> response = template.exchange("http://localhost:8081/" + resourceUri.toString(), HttpMethod.GET, findMapEntity, RestMindmap.class);
|
||||||
|
|
||||||
|
if (!response.getStatusCode().is2xxSuccessful()) {
|
||||||
|
throw new IllegalArgumentException(response.toString());
|
||||||
|
}
|
||||||
|
return response.getBody();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
private URI addNewMap(@NotNull TestRestTemplate template, @NotNull String title, @Nullable String xml) {
|
||||||
|
// Create a new map ...
|
||||||
|
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_XML);
|
||||||
|
HttpEntity<String> createUserEntity = new HttpEntity<>(xml, requestHeaders);
|
||||||
|
return template.postForLocation("/api/restfull/maps?title=" + title, createUserEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private URI addNewMap(@NotNull TestRestTemplate template, @NotNull String title) {
|
||||||
|
return addNewMap(template, title, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,830 +0,0 @@
|
|||||||
package com.wisemapping.test.rest;
|
|
||||||
|
|
||||||
|
|
||||||
import com.wisemapping.exceptions.WiseMappingException;
|
|
||||||
import com.wisemapping.rest.model.*;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.springframework.http.*;
|
|
||||||
import org.springframework.web.client.HttpClientErrorException;
|
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
import org.testng.SkipException;
|
|
||||||
import org.testng.annotations.BeforeClass;
|
|
||||||
import org.testng.annotations.Test;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import static com.wisemapping.test.rest.RestHelper.*;
|
|
||||||
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
import org.springframework.web.client.RestClientException;
|
|
||||||
|
|
||||||
import static com.wisemapping.test.rest.RestHelper.createHeaders;
|
|
||||||
import static org.testng.Assert.*;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public class RestMindmapITCase {
|
|
||||||
|
|
||||||
private String userEmail = "admin@wisemapping.com";
|
|
||||||
final RestAdminITCase restAdminITCase = new RestAdminITCase();
|
|
||||||
|
|
||||||
@BeforeClass
|
|
||||||
void createUser() {
|
|
||||||
|
|
||||||
userEmail = restAdminITCase.createNewUser(MediaType.APPLICATION_JSON);
|
|
||||||
userEmail += ":" + "admin";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void listMaps(final @NotNull MediaType mediaType) { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final String title1 = "List Maps 1 - " + mediaType;
|
|
||||||
addNewMap(template, title1);
|
|
||||||
|
|
||||||
final String title2 = "List Maps 2 - " + mediaType;
|
|
||||||
addNewMap(template, title2);
|
|
||||||
|
|
||||||
// Validate that the two maps are there ...
|
|
||||||
final RestMindmapList body = fetchMaps(requestHeaders, template);
|
|
||||||
final List<RestMindmapInfo> mindmaps = body.getMindmapsInfo();
|
|
||||||
|
|
||||||
boolean found1 = false;
|
|
||||||
boolean found2 = false;
|
|
||||||
for (RestMindmapInfo mindmap : mindmaps) {
|
|
||||||
if (mindmap.getTitle().equals(title1)) {
|
|
||||||
found1 = true;
|
|
||||||
}
|
|
||||||
if (mindmap.getTitle().equals(title2)) {
|
|
||||||
found2 = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertTrue(found1 && found2, "Map could not be found");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void deleteMap(final @NotNull MediaType mediaType) { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final String title1 = "Map to delete - " + mediaType;
|
|
||||||
final URI resourceUri = addNewMap(template, title1);
|
|
||||||
|
|
||||||
// Now remove it ...
|
|
||||||
template.delete(HOST_PORT + resourceUri.toString());
|
|
||||||
|
|
||||||
// Check that has been removed ...
|
|
||||||
try {
|
|
||||||
findMap(requestHeaders, template, resourceUri);
|
|
||||||
fail("Map could not be removed:" + resourceUri);
|
|
||||||
} catch (Exception e) {
|
|
||||||
// Ignore
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void changeMapTitle(final @NotNull MediaType mediaType) { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final URI resourceUri = addNewMap(template, "Map to change title - " + mediaType);
|
|
||||||
|
|
||||||
String newTitle = changeMapTitle(requestHeaders, mediaType, template, resourceUri);
|
|
||||||
|
|
||||||
// Load map again ..
|
|
||||||
final RestMindmap map = findMap(requestHeaders, template, resourceUri);
|
|
||||||
assertEquals(newTitle, map.getTitle());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void validateMapsCreation(final @NotNull MediaType mediaType) { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
requestHeaders.set(HttpHeaders.ACCEPT_LANGUAGE, "en");
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final String title = "Map to Validate Creation - " + mediaType;
|
|
||||||
addNewMap(template, title);
|
|
||||||
|
|
||||||
// Add map with same name ...
|
|
||||||
try {
|
|
||||||
HttpEntity<RestMindmap> createUserEntity = new HttpEntity<>(requestHeaders);
|
|
||||||
template.postForLocation(BASE_REST_URL + "/maps?title=" + title, createUserEntity);
|
|
||||||
} catch (HttpClientErrorException cause) {
|
|
||||||
final String responseBodyAsString = cause.getResponseBodyAsString();
|
|
||||||
assert (responseBodyAsString.contains("You have already a map"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
fail("Wrong response");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void changeMapDescription(final @NotNull MediaType mediaType) { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final URI resourceUri = addNewMap(template, "Map to change Description - " + mediaType);
|
|
||||||
|
|
||||||
// Change map title ...
|
|
||||||
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
|
||||||
final String newDescription = "New map to change description - " + mediaType;
|
|
||||||
final HttpEntity<String> updateEntity = new HttpEntity<>(newDescription, requestHeaders);
|
|
||||||
template.put(HOST_PORT + resourceUri + "/description", updateEntity);
|
|
||||||
|
|
||||||
// Load map again ..
|
|
||||||
final RestMindmap map = findMap(requestHeaders, template, resourceUri);
|
|
||||||
assertEquals(newDescription, map.getDescription());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void updateMapXml(final @NotNull MediaType mediaType) throws IOException { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final String title = "Update XML sample " + mediaType;
|
|
||||||
final URI resourceUri = addNewMap(template, title);
|
|
||||||
|
|
||||||
// Update map xml content ...
|
|
||||||
final String resourceUrl = HOST_PORT + resourceUri.toString();
|
|
||||||
String newXmlContent = updateMapDocument(requestHeaders, template, resourceUrl);
|
|
||||||
|
|
||||||
// Check that the map has been updated ...
|
|
||||||
final RestMindmap response = findMap(requestHeaders, template, resourceUri);
|
|
||||||
assertEquals(response.getXml(), newXmlContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String updateMapDocument(final HttpHeaders requestHeaders, final RestTemplate template, final String resourceUrl, String content) throws RestClientException {
|
|
||||||
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
|
||||||
final String newXmlContent = content != null ? content : "<map>this is not valid</map>";
|
|
||||||
HttpEntity<String> updateEntity = new HttpEntity<>(newXmlContent, requestHeaders);
|
|
||||||
template.put(resourceUrl + "/document/xml", updateEntity);
|
|
||||||
return newXmlContent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String updateMapDocument(final HttpHeaders requestHeaders, final RestTemplate template, final String resourceUrl) throws RestClientException {
|
|
||||||
return updateMapDocument(requestHeaders, template, resourceUrl, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void cloneMap(final @NotNull MediaType mediaType) throws IOException { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final String title = "Map to clone sample " + mediaType;
|
|
||||||
final String xml = "<map><node text='this is a cloned map'></map>";
|
|
||||||
final URI newMapUri = addNewMap(template, title, xml);
|
|
||||||
|
|
||||||
// Clone map ...
|
|
||||||
final RestMindmapInfo restMindmap = new RestMindmapInfo();
|
|
||||||
restMindmap.setTitle("Cloned map but with previous content." + mediaType);
|
|
||||||
restMindmap.setDescription("Cloned map desc");
|
|
||||||
|
|
||||||
// Create a new map ...
|
|
||||||
final HttpEntity<RestMindmapInfo> cloneEntity = new HttpEntity<>(restMindmap, requestHeaders);
|
|
||||||
final URI clonedMapUri = template.postForLocation(HOST_PORT + newMapUri, cloneEntity);
|
|
||||||
|
|
||||||
// Check that the map has been updated ...
|
|
||||||
final RestMindmap response = findMap(requestHeaders, template, clonedMapUri);
|
|
||||||
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 HttpEntity findLabelEntity = new HttpEntity(createHeaders(MediaType.TEXT_PLAIN));
|
|
||||||
final ResponseEntity<String> response = template.exchange(resourceUrl, HttpMethod.GET, findLabelEntity, String.class);
|
|
||||||
|
|
||||||
assertTrue(Boolean.parseBoolean(response.getBody()), "Starred has been updated");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void verifyMapOwnership(final @NotNull MediaType mediaType) { // Configure media types ...
|
|
||||||
final RestAdminITCase restAdminITCase = new RestAdminITCase();
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final String title1 = "verifyMapOwnership Map user 1";
|
|
||||||
addNewMap(template, title1);
|
|
||||||
|
|
||||||
//create another user
|
|
||||||
RestUser secondUser = restAdminITCase.createNewUserAndGetUser(MediaType.APPLICATION_JSON);
|
|
||||||
final RestTemplate secondTemplate = createTemplate(secondUser.getEmail() + ":admin");
|
|
||||||
|
|
||||||
final String title2 = "verifyMapOwnership Map user 2";
|
|
||||||
addNewMap(secondTemplate, title2);
|
|
||||||
|
|
||||||
// Delete user ...
|
|
||||||
String authorisation = "admin@wisemapping.org" + ":" + "test";
|
|
||||||
RestTemplate superadminTemplate = createTemplate(authorisation);
|
|
||||||
|
|
||||||
superadminTemplate.delete(BASE_REST_URL + "/admin/users/" + secondUser.getId());
|
|
||||||
|
|
||||||
// Validate that the two maps are there ...
|
|
||||||
final RestMindmapList body = fetchMaps(requestHeaders, template);
|
|
||||||
final List<RestMindmapInfo> mindmaps = body.getMindmapsInfo();
|
|
||||||
|
|
||||||
boolean found1 = false;
|
|
||||||
for (RestMindmapInfo mindmap : mindmaps) {
|
|
||||||
if (mindmap.getTitle().equals(title1)) {
|
|
||||||
found1 = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
assertTrue(found1, "Map could not be found");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void updateMap(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final String title = "Update sample " + mediaType;
|
|
||||||
final URI resourceUri = addNewMap(template, title);
|
|
||||||
|
|
||||||
// Build map to update ...
|
|
||||||
final RestMindmap mapToUpdate = new RestMindmap();
|
|
||||||
mapToUpdate.setXml("<map>this is not valid</map>");
|
|
||||||
mapToUpdate.setProperties("{zoom:x}");
|
|
||||||
|
|
||||||
// Create lock ...
|
|
||||||
final HttpHeaders lockHeaders = createHeaders(mediaType);
|
|
||||||
lockHeaders.setContentType(MediaType.TEXT_PLAIN);
|
|
||||||
|
|
||||||
// Update map ...
|
|
||||||
final String resourceUrl = HOST_PORT + resourceUri.toString() + "/document";
|
|
||||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
final HttpEntity<RestMindmap> updateEntity = new HttpEntity<>(mapToUpdate, requestHeaders);
|
|
||||||
template.put(resourceUrl, updateEntity);
|
|
||||||
|
|
||||||
// Check that the map has been updated ...
|
|
||||||
HttpEntity<RestUser> findMapEntity = new HttpEntity<>(requestHeaders);
|
|
||||||
final ResponseEntity<RestMindmap> response = template.exchange(HOST_PORT + resourceUri, HttpMethod.GET, findMapEntity, RestMindmap.class);
|
|
||||||
assertEquals(response.getBody().getXml(), mapToUpdate.getXml());
|
|
||||||
assertEquals(response.getBody().getProperties(), mapToUpdate.getProperties());
|
|
||||||
|
|
||||||
// Unlock ...
|
|
||||||
HttpEntity<String> lockEntity = new HttpEntity<>("false", lockHeaders);
|
|
||||||
template.exchange(HOST_PORT + resourceUri + "/lock", HttpMethod.PUT, lockEntity, RestLockInfo.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void addCollabs(final @NotNull MediaType mediaType) {
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final URI resourceUri = addNewMap(template, "Map for addCollabs - " + mediaType);
|
|
||||||
|
|
||||||
String newCollab = addNewCollaboration(requestHeaders, template, resourceUri);
|
|
||||||
|
|
||||||
// Has been added ?
|
|
||||||
RestCollaborationList responseCollbs = fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
|
||||||
|
|
||||||
// Has been added ?
|
|
||||||
assertEquals(responseCollbs.getCount(), 2);
|
|
||||||
|
|
||||||
final Optional<RestCollaboration> addedCollab = responseCollbs.getCollaborations().stream().filter(c -> c.getEmail().equals(newCollab)).findAny();
|
|
||||||
assertTrue(addedCollab.isPresent());
|
|
||||||
assertEquals(addedCollab.get().getRole(), "editor");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void updateCollabType(final @NotNull MediaType mediaType) {
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final URI resourceUri = addNewMap(template, "Map for updateCollabType - " + mediaType);
|
|
||||||
|
|
||||||
// Add a new collaboration ...
|
|
||||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
final RestCollaborationList collabs = new RestCollaborationList();
|
|
||||||
collabs.setMessage("Adding new permission");
|
|
||||||
|
|
||||||
final String newCollab = "new-collab@example.com";
|
|
||||||
String role = "editor";
|
|
||||||
|
|
||||||
final RestCollaboration collab = addCollabToList(newCollab, role, collabs);
|
|
||||||
|
|
||||||
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
|
||||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
|
||||||
|
|
||||||
// Has been added ?
|
|
||||||
RestCollaborationList responseCollbs = fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
|
||||||
assertEquals(responseCollbs.getCount(), 2);
|
|
||||||
|
|
||||||
// Update the collaboration type ...
|
|
||||||
collab.setRole("viewer");
|
|
||||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
|
||||||
|
|
||||||
// Has been added ?
|
|
||||||
final ResponseEntity<RestCollaborationList> afterResponse = fetchCollabs(requestHeaders, template, resourceUri);
|
|
||||||
final Optional<RestCollaboration> updatedCollab = afterResponse.getBody().getCollaborations().stream().filter(c -> c.getEmail().equals(newCollab)).findAny();
|
|
||||||
assertTrue(updatedCollab.isPresent());
|
|
||||||
assertEquals(updatedCollab.get().getRole(), "viewer");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void deleteCollabs(final @NotNull MediaType mediaType) {
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final URI resourceUri = addNewMap(template, "Map for deleteCollabs - " + mediaType);
|
|
||||||
|
|
||||||
String newCollab = addNewCollaboration(requestHeaders, template, resourceUri);
|
|
||||||
|
|
||||||
// Has been added ?
|
|
||||||
RestCollaborationList responseCollbs = fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
|
||||||
|
|
||||||
// Has been added ?
|
|
||||||
assertEquals(responseCollbs.getCount(), 2);
|
|
||||||
|
|
||||||
// Now, remove it ...
|
|
||||||
template.delete(HOST_PORT + resourceUri + "/collabs?email=" + newCollab);
|
|
||||||
|
|
||||||
// Check that it has been removed ...
|
|
||||||
final ResponseEntity<RestCollaborationList> afterDeleteResponse = fetchCollabs(requestHeaders, template, resourceUri);
|
|
||||||
assertEquals(afterDeleteResponse.getBody().getCollaborations().size(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private String addNewCollaboration(final HttpHeaders requestHeaders, final RestTemplate template, final URI resourceUri) throws RestClientException {
|
|
||||||
// Add a new collaboration ...
|
|
||||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
final RestCollaborationList collabs = new RestCollaborationList();
|
|
||||||
collabs.setMessage("Adding new permission");
|
|
||||||
final String newCollab = "new-collab@example.com";
|
|
||||||
String role = "editor";
|
|
||||||
addCollabToList(newCollab, role, collabs);
|
|
||||||
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
|
||||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
|
||||||
return newCollab;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void deleteCollabsWithInvalidEmail(final @NotNull MediaType mediaType) {
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final URI resourceUri = addNewMap(template, "deleteCollabsWithInvalidEmail");
|
|
||||||
|
|
||||||
// Remove with invalid email ...
|
|
||||||
try {
|
|
||||||
|
|
||||||
template.delete(HOST_PORT + resourceUri + "/collabs?email=invalidEmail");
|
|
||||||
} catch (HttpClientErrorException e) {
|
|
||||||
assertEquals(e.getRawStatusCode(), 400);
|
|
||||||
assertTrue(e.getMessage().contains("Invalid email exception:"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that it has been removed ...
|
|
||||||
final ResponseEntity<RestCollaborationList> afterDeleteResponse = fetchCollabs(requestHeaders, template, resourceUri);
|
|
||||||
assertEquals(afterDeleteResponse.getBody().getCollaborations().size(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void deleteCollabsWithoutOwnerPermission(final @NotNull MediaType mediaType) {
|
|
||||||
|
|
||||||
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final URI resourceUri = addNewMap(template, "deleteWithoutOwnerPermission");
|
|
||||||
|
|
||||||
final String newCollab = restAdminITCase.createNewUser(MediaType.APPLICATION_JSON);
|
|
||||||
template = createTemplate(newCollab + ":admin");
|
|
||||||
|
|
||||||
// Remove with invalid email ...
|
|
||||||
try {
|
|
||||||
|
|
||||||
template.delete(HOST_PORT + resourceUri + "/collabs?email=" + newCollab);
|
|
||||||
} catch (HttpClientErrorException e) {
|
|
||||||
assertEquals(e.getRawStatusCode(), 400);
|
|
||||||
assertTrue(e.getMessage().contains("No enough permissions"));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void deleteOwnerCollab(final @NotNull MediaType mediaType) {
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final URI resourceUri = addNewMap(template, "Map for deleteOwnerCollab");
|
|
||||||
|
|
||||||
// Now, remove owner collab ...
|
|
||||||
try {
|
|
||||||
template.delete(HOST_PORT + resourceUri + "/collabs?email=" + userEmail.replace(":admin", ""));
|
|
||||||
} catch (HttpClientErrorException e) {
|
|
||||||
assertEquals(e.getRawStatusCode(), 400);
|
|
||||||
assertTrue(e.getMessage().contains("Can not remove owner collab"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
private ResponseEntity<RestCollaborationList> fetchCollabs(HttpHeaders requestHeaders, RestTemplate template, URI resourceUri) {
|
|
||||||
final HttpEntity findCollabs = new HttpEntity(requestHeaders);
|
|
||||||
return template.exchange(HOST_PORT + resourceUri + "/collabs", HttpMethod.GET, findCollabs, RestCollaborationList.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, expectedExceptions = {HttpClientErrorException.class}, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void addCollabsInvalidOwner(final @NotNull MediaType mediaType) {
|
|
||||||
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
|
||||||
final URI resourceUri = addNewMap(template, "Map for Collaboration - " + mediaType);
|
|
||||||
|
|
||||||
// Add a new collaboration ...
|
|
||||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
final RestCollaborationList collabs = new RestCollaborationList();
|
|
||||||
collabs.setMessage("Adding new permission");
|
|
||||||
|
|
||||||
// Validate that owner can not be added.
|
|
||||||
addCollabToList("newCollab@example", "owner", collabs);
|
|
||||||
|
|
||||||
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
|
||||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void removeLabelFromMindmap(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 = "removeLabelFromMindmap";
|
|
||||||
final URI labelUri = RestLabelITCase.addNewLabel(requestHeaders, template, titleLabel, COLOR);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final String mapTitle = "removeLabelFromMindmap";
|
|
||||||
final URI mindmapUri = addNewMap(template, mapTitle);
|
|
||||||
final String mapId = mindmapUri.getPath().replace("/api/restfull/maps/", "");
|
|
||||||
|
|
||||||
// Assign label to map ...
|
|
||||||
String labelId = labelUri.getPath().replace("/api/restfull/labels/", "");
|
|
||||||
HttpEntity<String> labelEntity = new HttpEntity<>(labelId, requestHeaders);
|
|
||||||
template.postForLocation(BASE_REST_URL + "/maps/" + mapId + "/labels", labelEntity);
|
|
||||||
|
|
||||||
// Remove label from map
|
|
||||||
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 ...
|
|
||||||
final List<RestMindmapInfo> mindmapsInfo = fetchMaps(requestHeaders, template).getMindmapsInfo();
|
|
||||||
Optional<RestMindmapInfo> mindmapInfo = mindmapsInfo
|
|
||||||
.stream()
|
|
||||||
.filter(m -> m.getId() == Integer.parseInt(mapId))
|
|
||||||
.findAny();
|
|
||||||
return mindmapInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void deleteMapAndCheckLabels(final @NotNull MediaType mediaType) { // Configure media types ...
|
|
||||||
throw new SkipException("missing test: delete map should not affects others labels");
|
|
||||||
}
|
|
||||||
|
|
||||||
@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;
|
|
||||||
final URI labelUri = RestLabelITCase.addNewLabel(requestHeaders, template, titleLabel, COLOR);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final String mapTitle = "Maps 1 - " + mediaType;
|
|
||||||
final URI mindmapUri = addNewMap(template, mapTitle);
|
|
||||||
final String mapId = mindmapUri.getPath().replace("/api/restfull/maps/", "");
|
|
||||||
|
|
||||||
// Assign label to map ...
|
|
||||||
String labelId = labelUri.getPath().replace("/api/restfull/labels/", "");
|
|
||||||
HttpEntity<String> labelEntity = new HttpEntity<>(labelId, requestHeaders);
|
|
||||||
template.postForLocation(BASE_REST_URL + "/maps/" + mapId + "/labels", labelEntity);
|
|
||||||
|
|
||||||
// Check that the label has been assigned ...
|
|
||||||
Optional<RestMindmapInfo> mindmapInfo = fetchMap(requestHeaders, template, mapId);
|
|
||||||
|
|
||||||
assertTrue(mindmapInfo.get().getLabels().size() == 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void updateCollabs(final @NotNull MediaType mediaType) {
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
final URI resourceUri = addNewMap(template, "Map for updateCollabs - " + mediaType);
|
|
||||||
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
// Add a new collaboration ...
|
|
||||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
RestCollaborationList collabs = new RestCollaborationList();
|
|
||||||
collabs.setMessage("Adding new permission");
|
|
||||||
|
|
||||||
String newCollab = "new-collab@example.com";
|
|
||||||
String role = "editor";
|
|
||||||
|
|
||||||
addCollabToList(newCollab, role, collabs);
|
|
||||||
|
|
||||||
HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
|
||||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
|
||||||
|
|
||||||
collabs = fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
|
||||||
|
|
||||||
//delete one collab
|
|
||||||
collabs.setCollaborations(collabs.getCollaborations().stream().filter(c -> c.getRole().equals("owner")).collect(Collectors.toList()));
|
|
||||||
|
|
||||||
//Add another collaborationMediaType
|
|
||||||
newCollab = "another-collab@example.com";
|
|
||||||
addCollabToList(newCollab, role, collabs);
|
|
||||||
|
|
||||||
//add owner to list
|
|
||||||
addCollabToList(userEmail.replace(":admin", ""), "owner", collabs);
|
|
||||||
|
|
||||||
updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
|
||||||
template.postForLocation(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
|
||||||
|
|
||||||
|
|
||||||
RestCollaborationList responseCollbs = fetchAndGetCollabs(requestHeaders, template, resourceUri);
|
|
||||||
|
|
||||||
// Has been another-collaboration list updated ?
|
|
||||||
assertTrue(responseCollbs.getCollaborations().stream().anyMatch(x -> x.getEmail().equals("another-collab@example.com")));
|
|
||||||
assertEquals(responseCollbs.getCount(), 2);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void updateProperties(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final String title = "updateProperties map";
|
|
||||||
final URI resourceUri = addNewMap(template, title);
|
|
||||||
|
|
||||||
// Build map to update ...
|
|
||||||
final RestMindmap mapToUpdate = new RestMindmap();
|
|
||||||
mapToUpdate.setXml("<map>this is not valid</map>");
|
|
||||||
mapToUpdate.setProperties("{zoom:x}");
|
|
||||||
mapToUpdate.setTitle("new title for map");
|
|
||||||
mapToUpdate.setDescription("updated map description");
|
|
||||||
|
|
||||||
// Update map ...
|
|
||||||
final String resourceUrl = HOST_PORT + resourceUri.toString();
|
|
||||||
final HttpEntity<RestMindmap> updateEntity = new HttpEntity<>(mapToUpdate, requestHeaders);
|
|
||||||
template.put(resourceUrl, updateEntity);
|
|
||||||
|
|
||||||
// Check that the map has been updated ...
|
|
||||||
HttpEntity<RestUser> findMapEntity = new HttpEntity<>(requestHeaders);
|
|
||||||
final ResponseEntity<RestMindmap> response = template.exchange(HOST_PORT + resourceUri, HttpMethod.GET, findMapEntity, RestMindmap.class);
|
|
||||||
assertEquals(response.getBody().getTitle(), mapToUpdate.getTitle());
|
|
||||||
assertEquals(response.getBody().getDescription(), mapToUpdate.getDescription());
|
|
||||||
assertEquals(response.getBody().getXml(), mapToUpdate.getXml());
|
|
||||||
assertEquals(response.getBody().getProperties(), mapToUpdate.getProperties());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void batchDelete(final @NotNull MediaType mediaType) { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final String title1 = "Batch delete map 1";
|
|
||||||
addNewMap(template, title1);
|
|
||||||
|
|
||||||
final String title2 = "Batch delete map 2";
|
|
||||||
addNewMap(template, title2);
|
|
||||||
|
|
||||||
|
|
||||||
String maps;
|
|
||||||
maps = fetchMaps(requestHeaders, template).getMindmapsInfo().stream().map(map -> {
|
|
||||||
return String.valueOf(map.getId());
|
|
||||||
}).collect(Collectors.joining(","));
|
|
||||||
|
|
||||||
|
|
||||||
template.delete(BASE_REST_URL + "/maps/batch?ids=" + maps);
|
|
||||||
|
|
||||||
// Validate that the two maps are there ...
|
|
||||||
final RestMindmapList body = fetchMaps(requestHeaders, template);
|
|
||||||
assertEquals(body.getMindmapsInfo().size(), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void updatePublishState(final @NotNull MediaType mediaType) throws IOException, WiseMappingException { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final String mapTitle = "updatePublishState";
|
|
||||||
final URI mindmapUri = addNewMap(template, mapTitle);
|
|
||||||
final String mapId = mindmapUri.getPath().replace("/api/restfull/maps/", "");
|
|
||||||
|
|
||||||
// Change map status ...
|
|
||||||
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
|
||||||
//final String newPublicState = "true";
|
|
||||||
final HttpEntity<String> updateEntity = new HttpEntity<>(Boolean.TRUE.toString(), requestHeaders);
|
|
||||||
template.put(HOST_PORT + mindmapUri + "/publish", updateEntity);
|
|
||||||
|
|
||||||
// //fetch public view
|
|
||||||
// final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
|
||||||
// ResponseEntity<String> publicView = template.exchange(HOST_PORT + mapId + "/public", HttpMethod.GET, findMapEntity, String.class);
|
|
||||||
// assertNotNull(publicView.getBody());
|
|
||||||
// assertEquals(publicView.getStatusCodeValue(), 200);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void fetchMapHistory(final @NotNull MediaType mediaType) { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final URI resourceUri = addNewMap(template, "Map to change title - " + mediaType);
|
|
||||||
|
|
||||||
updateMapDocument(requestHeaders, template, HOST_PORT + resourceUri.toString());
|
|
||||||
|
|
||||||
//fetch map history
|
|
||||||
final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
|
||||||
final ResponseEntity<RestMindmapHistoryList> maps = template.exchange(HOST_PORT + resourceUri + "/history/", HttpMethod.GET, findMapEntity, RestMindmapHistoryList.class);
|
|
||||||
assertEquals(maps.getBody().getCount(), 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void updateRevertMindmap(final @NotNull MediaType mediaType) throws IOException { // Configure media types ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
final RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final URI resourceUri = addNewMap(template, "map to test revert changes");
|
|
||||||
updateMapDocument(requestHeaders, template, HOST_PORT + resourceUri.toString(), "<map><node text='this is an xml to test revert changes service'></map>");
|
|
||||||
|
|
||||||
updateMapDocument(requestHeaders, template, HOST_PORT + resourceUri.toString(), "<map><node text='this is an xml with modification to be reverted'></map>");
|
|
||||||
|
|
||||||
//fetch map history
|
|
||||||
final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
|
||||||
final ResponseEntity<RestMindmapHistoryList> mapHistories = template.exchange(HOST_PORT + resourceUri + "/history/", HttpMethod.GET, findMapEntity, RestMindmapHistoryList.class);
|
|
||||||
|
|
||||||
//aply revert
|
|
||||||
final HttpEntity<String> cloneEntity = new HttpEntity<>(requestHeaders);
|
|
||||||
template.postForLocation(HOST_PORT + resourceUri + "/history/latest", cloneEntity);
|
|
||||||
final RestMindmap latestStoredMap = findMap(requestHeaders, template, resourceUri);
|
|
||||||
template.postForLocation(HOST_PORT + resourceUri + "/history/" + mapHistories.getBody().getChanges().get(1).getId(), cloneEntity);
|
|
||||||
final RestMindmap firstVersionMap = findMap(requestHeaders, template, resourceUri);
|
|
||||||
|
|
||||||
//verify revert
|
|
||||||
assertEquals(firstVersionMap.getXml(), "<map><node text='this is an xml to test revert changes service'></map>");
|
|
||||||
assertEquals(latestStoredMap.getXml(), "<map><node text='this is an xml with modification to be reverted'></map>");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void addCollabWhitoutOwnerPermission(final @NotNull MediaType mediaType) {
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final URI resourceUri = addNewMap(template, "MaddCollabWhitoutOwnerPermission");
|
|
||||||
|
|
||||||
// Add a new collaboration ...
|
|
||||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
final RestCollaborationList collabs = new RestCollaborationList();
|
|
||||||
collabs.setMessage("Adding new permission");
|
|
||||||
|
|
||||||
final String newCollab = restAdminITCase.createNewUser(MediaType.APPLICATION_JSON);
|
|
||||||
String role = "editor";
|
|
||||||
|
|
||||||
addCollabToList(newCollab, role, collabs);
|
|
||||||
|
|
||||||
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
|
||||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
|
||||||
|
|
||||||
template = createTemplate(newCollab + ":admin");
|
|
||||||
//add collab again with the new user expecting the Exception
|
|
||||||
try {
|
|
||||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
|
||||||
} catch (HttpClientErrorException e) {
|
|
||||||
assertEquals(e.getRawStatusCode(), 400);
|
|
||||||
assertTrue(e.getMessage().contains("User must be owner to share mindmap"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test(dataProviderClass = RestHelper.class, dataProvider = "ContentType-Provider-Function")
|
|
||||||
public void addCollabWhitOwnerRole(final @NotNull MediaType mediaType) {
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(mediaType);
|
|
||||||
RestTemplate template = createTemplate(userEmail);
|
|
||||||
|
|
||||||
// Create a sample map ...
|
|
||||||
final URI resourceUri = addNewMap(template, "addCollabWhitOwnerRole");
|
|
||||||
|
|
||||||
// Add a new collaboration ...
|
|
||||||
requestHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
||||||
final RestCollaborationList collabs = new RestCollaborationList();
|
|
||||||
collabs.setMessage("Adding new permission");
|
|
||||||
|
|
||||||
final String newCollab = "new-collaborator@mail.com";
|
|
||||||
String role = "owner";
|
|
||||||
|
|
||||||
addCollabToList(newCollab, role, collabs);
|
|
||||||
|
|
||||||
final HttpEntity<RestCollaborationList> updateEntity = new HttpEntity<>(collabs, requestHeaders);
|
|
||||||
try {
|
|
||||||
template.put(HOST_PORT + resourceUri + "/collabs/", updateEntity);
|
|
||||||
} catch (HttpClientErrorException e) {
|
|
||||||
assertEquals(e.getRawStatusCode(), 400);
|
|
||||||
assertTrue(e.getMessage().contains("Collab email can not be change"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String changeMapTitle(final HttpHeaders requestHeaders, final MediaType mediaType, final RestTemplate template, final URI resourceUri) throws RestClientException {
|
|
||||||
// Change map title ...
|
|
||||||
requestHeaders.setContentType(MediaType.TEXT_PLAIN);
|
|
||||||
final String newTitle = "New map to change title - " + mediaType;
|
|
||||||
final HttpEntity<String> updateEntity = new HttpEntity<>(newTitle, requestHeaders);
|
|
||||||
template.put(HOST_PORT + resourceUri + "/title", updateEntity);
|
|
||||||
return newTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
private RestMindmapList fetchMaps(final HttpHeaders requestHeaders, final RestTemplate template) throws RestClientException {
|
|
||||||
final HttpEntity findMapEntity = new HttpEntity(requestHeaders);
|
|
||||||
final ResponseEntity<RestMindmapList> maps = template.exchange(BASE_REST_URL + "/maps/", HttpMethod.GET, findMapEntity, RestMindmapList.class);
|
|
||||||
return maps.getBody();
|
|
||||||
}
|
|
||||||
|
|
||||||
private RestCollaborationList fetchAndGetCollabs(final HttpHeaders requestHeaders, final RestTemplate template, final URI resourceUri) {
|
|
||||||
final ResponseEntity<RestCollaborationList> response = fetchCollabs(requestHeaders, template, resourceUri);
|
|
||||||
RestCollaborationList responseCollbs = response.getBody();
|
|
||||||
return responseCollbs;
|
|
||||||
}
|
|
||||||
|
|
||||||
private RestCollaboration addCollabToList(String newCollab, String role, RestCollaborationList collabs) {
|
|
||||||
RestCollaboration collab = new RestCollaboration();
|
|
||||||
collab.setEmail(newCollab);
|
|
||||||
collab.setRole(role);
|
|
||||||
collabs.addCollaboration(collab);
|
|
||||||
return collab;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
return response.getBody();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private URI addNewMap(@NotNull RestTemplate template, @NotNull String title, @Nullable String xml) {
|
|
||||||
// Create a new map ...
|
|
||||||
final HttpHeaders requestHeaders = createHeaders(MediaType.APPLICATION_XML);
|
|
||||||
HttpEntity<String> createUserEntity = new HttpEntity<>(xml, requestHeaders);
|
|
||||||
return template.postForLocation(BASE_REST_URL + "/maps?title=" + title, createUserEntity);
|
|
||||||
}
|
|
||||||
|
|
||||||
private URI addNewMap(@NotNull RestTemplate template, @NotNull String title) {
|
|
||||||
return addNewMap(template, title, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,26 +0,0 @@
|
|||||||
package com.wisemapping.test.rest;
|
|
||||||
|
|
||||||
|
|
||||||
import com.wisemapping.config.Application;
|
|
||||||
import com.wisemapping.rest.MindmapController;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.extension.ExtendWith;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
|
||||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|
||||||
|
|
||||||
|
|
||||||
@SpringBootTest(classes = Application.class)
|
|
||||||
@ExtendWith(SpringExtension.class)
|
|
||||||
|
|
||||||
class SmokeTest {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private MindmapController controller;
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void contextLoads() throws Exception {
|
|
||||||
if(controller==null) throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user