- Add REST Integration tests.

This commit is contained in:
Paulo Gustavo Veiga 2012-03-12 10:48:54 -03:00
parent 2d38b5d990
commit 1aebcf48e3
7 changed files with 396 additions and 280 deletions

View File

@ -267,7 +267,6 @@
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
@ -418,9 +417,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<parallel>true</parallel>
</configuration>
</plugin>
<plugin>
@ -432,7 +428,7 @@
<stopPort>9999</stopPort>
<war>${project.build.directory}/wisemapping.war</war>
<reload>automatic</reload>
<scanIntervalSeconds>10</scanIntervalSeconds>
<!--<scanIntervalSeconds>10</scanIntervalSeconds>-->
</configuration>
<executions>
<execution>

View File

@ -1,255 +1,255 @@
/*
* Copyright [2011] [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.model;
import org.jetbrains.annotations.NotNull;
import java.lang.IllegalStateException;
import java.lang.reflect.Field;
import java.util.*;
@SuppressWarnings({"UnusedDeclaration"})
public class MindmapIcons {
private static Map<IconFamily, List<MindmapIcon>> iconsByFamily;
public static final MindmapIcon FACE_PLAIN = new MindmapIcon(IconFamily.FACE, "plain");
public static final MindmapIcon FACE_SAD = new MindmapIcon(IconFamily.FACE, "sad");
public static final MindmapIcon FACE_CRYING = new MindmapIcon(IconFamily.FACE, "crying");
public static final MindmapIcon FACE_SMILE = new MindmapIcon(IconFamily.FACE, "smile");
public static final MindmapIcon FACE_SURPRISE = new MindmapIcon(IconFamily.FACE, "surprise");
public static final MindmapIcon FACE_WINK = new MindmapIcon(IconFamily.FACE, "wink");
public static final MindmapIcon THUMB__UP = new MindmapIcon(IconFamily.THUMB, "thumb_up");
public static final MindmapIcon THUMB_DOWN = new MindmapIcon(IconFamily.THUMB, "thumb_down");
public static final MindmapIcon ARROW_UP = new MindmapIcon(IconFamily.ARROW, "up");
public static final MindmapIcon ARROW_DOWN = new MindmapIcon(IconFamily.ARROW, "down");
public static final MindmapIcon ARROW_LEFT = new MindmapIcon(IconFamily.ARROW, "left");
public static final MindmapIcon ARROW_RIGHT = new MindmapIcon(IconFamily.ARROW, "right");
// public static final MindmapIcon TASK_ONE = new MindmapIcon(IconFamily.TASK, "one");
// public static final MindmapIcon TASK_TWO = new MindmapIcon(IconFamily.TASK, "two");
// public static final MindmapIcon TASK_THREE = new MindmapIcon(IconFamily.TASK, "three");
// public static final MindmapIcon TASK_FOUR = new MindmapIcon(IconFamily.TASK, "four");
// public static final MindmapIcon TASK_FIVE = new MindmapIcon(IconFamily.TASK, "five");
// public static final MindmapIcon ARROWC_UNDO = new MindmapIcon(IconFamily.ARROWC, "undo");
public static final MindmapIcon ARROWC_ANTICLOCK_WISE = new MindmapIcon(IconFamily.ARROWC, "rotate_anticlockwise");
public static final MindmapIcon ARROWC_CLOCK_WISE = new MindmapIcon(IconFamily.ARROWC, "rotate_clockwise");
public static final MindmapIcon ARROWC_LEFT = new MindmapIcon(IconFamily.ARROWC, "turn_left");
public static final MindmapIcon ARROWC_RIGHT = new MindmapIcon(IconFamily.ARROWC, "turn_right");
public static final MindmapIcon BULB_LIGHT_ON = new MindmapIcon(IconFamily.BULB, "light_on");
public static final MindmapIcon BULB_LIGHT__OFF = new MindmapIcon(IconFamily.BULB, "light_off");
public static final MindmapIcon TICK_TICK = new MindmapIcon(IconFamily.TICK, "tick");
public static final MindmapIcon TICK_CROSS = new MindmapIcon(IconFamily.TICK, "cross");
public static final MindmapIcon CHART_BAR = new MindmapIcon(IconFamily.CHART, "bar");
public static final MindmapIcon CHART_LINE = new MindmapIcon(IconFamily.CHART, "line");
public static final MindmapIcon CHART_CURVE = new MindmapIcon(IconFamily.CHART, "curve");
public static final MindmapIcon CHART_PIE = new MindmapIcon(IconFamily.CHART, "pie");
public static final MindmapIcon CHART_ORGANISATION = new MindmapIcon(IconFamily.CHART, "organisation");
public static final MindmapIcon ONOFF_CLOCK = new MindmapIcon(IconFamily.ONOFF, "clock");
public static final MindmapIcon ONOFF_CLOCK__RED = new MindmapIcon(IconFamily.ONOFF, "clock_red");
public static final MindmapIcon ONOFF_ADD = new MindmapIcon(IconFamily.ONOFF, "add");
public static final MindmapIcon ONOFF_DELETE = new MindmapIcon(IconFamily.ONOFF, "delete");
public static final MindmapIcon ONOFF_STATUS_OFFLINE = new MindmapIcon(IconFamily.ONOFF, "status_offline");
public static final MindmapIcon ONOFF_STATUS_ONLINE = new MindmapIcon(IconFamily.ONOFF, "status_online");
public static final MindmapIcon TAG_BLUE = new MindmapIcon(IconFamily.TAG, "blue");
public static final MindmapIcon TAG_GREEN = new MindmapIcon(IconFamily.TAG, "green");
public static final MindmapIcon TAG_ORANGE = new MindmapIcon(IconFamily.TAG, "orange");
public static final MindmapIcon TAG_RED = new MindmapIcon(IconFamily.TAG, "red");
public static final MindmapIcon TAG_PINK = new MindmapIcon(IconFamily.TAG, "pink");
public static final MindmapIcon TAG_YELLOW = new MindmapIcon(IconFamily.TAG, "yellow");
// public static final MindmapIcon NUMBER_ONE = new MindmapIcon(IconFamily.NUMBER, "one");
// public static final MindmapIcon NUMBER_TWO = new MindmapIcon(IconFamily.NUMBER, "two");
// public static final MindmapIcon NUMBER_THREE = new MindmapIcon(IconFamily.NUMBER, "three");
// public static final MindmapIcon NUMBER_FOUR = new MindmapIcon(IconFamily.NUMBER, "four");
// public static final MindmapIcon NUMBER_FIVE = new MindmapIcon(IconFamily.NUMBER, "five");
// public static final MindmapIcon NUMBER_SIX = new MindmapIcon(IconFamily.NUMBER, "six");
// public static final MindmapIcon NUMBER_SEVEN = new MindmapIcon(IconFamily.NUMBER, "seven");
// public static final MindmapIcon NUMBER_EIGHT = new MindmapIcon(IconFamily.NUMBER, "eight");
// public static final MindmapIcon NUMBER_NINE = new MindmapIcon(IconFamily.NUMBER, "nine");
public static final MindmapIcon FUNNY_ANGEL = new MindmapIcon(IconFamily.FUNY, "angel");
public static final MindmapIcon FUNNY_DEVILISH = new MindmapIcon(IconFamily.FUNY, "devilish");
public static final MindmapIcon FUNNY_GLASSES = new MindmapIcon(IconFamily.FUNY, "glasses");
public static final MindmapIcon FUNNY_GRIN = new MindmapIcon(IconFamily.FUNY, "grin");
public static final MindmapIcon FUNNY_KISS = new MindmapIcon(IconFamily.FUNY, "kiss");
public static final MindmapIcon FUNNY_MONKEY = new MindmapIcon(IconFamily.FUNY, "monkey");
public static final MindmapIcon FLAG_BLUE = new MindmapIcon(IconFamily.FLAG, "blue");
public static final MindmapIcon FLAG_GREEN = new MindmapIcon(IconFamily.FLAG, "green");
public static final MindmapIcon FLAG_ORANGE = new MindmapIcon(IconFamily.FLAG, "orange");
public static final MindmapIcon FLAG_PINK = new MindmapIcon(IconFamily.FLAG, "pink");
public static final MindmapIcon FLAG_PURPLE = new MindmapIcon(IconFamily.FLAG, "purple");
public static final MindmapIcon FLAG_YELLOW = new MindmapIcon(IconFamily.FLAG, "yellow");
public static final MindmapIcon BULLET_BLACK = new MindmapIcon(IconFamily.BULLET, "black");
public static final MindmapIcon BULLET_BLUE = new MindmapIcon(IconFamily.BULLET, "blue");
public static final MindmapIcon BULLET_BLUEGREEN = new MindmapIcon(IconFamily.BULLET, "green");
public static final MindmapIcon BULLET_BLUEORANGE = new MindmapIcon(IconFamily.BULLET, "orange");
public static final MindmapIcon BULLET_BLUERED = new MindmapIcon(IconFamily.BULLET, "red");
public static final MindmapIcon BULLET_BLUEPINK = new MindmapIcon(IconFamily.BULLET, "pink");
public static final MindmapIcon BULLET_BLUEPURPLE = new MindmapIcon(IconFamily.BULLET, "purple");
public static final MindmapIcon MONEY_GENERIC = new MindmapIcon(IconFamily.MONEY, "money");
public static final MindmapIcon MONEY_DOLLAR = new MindmapIcon(IconFamily.MONEY, "dollar");
public static final MindmapIcon MONEY_EURO = new MindmapIcon(IconFamily.MONEY, "euro");
public static final MindmapIcon MONEY_POUND = new MindmapIcon(IconFamily.MONEY, "pound");
public static final MindmapIcon MONEY_YEN = new MindmapIcon(IconFamily.MONEY, "yen");
public static final MindmapIcon MONEY_COINS = new MindmapIcon(IconFamily.MONEY, "coins");
public static final MindmapIcon MONEY_RUBY = new MindmapIcon(IconFamily.MONEY, "ruby");
public static final MindmapIcon MONEY_CONNECT = new MindmapIcon(IconFamily.CONN, "connect");
public static final MindmapIcon MONEY_DISCONNECT = new MindmapIcon(IconFamily.CONN, "disconnect");
public static final MindmapIcon SPORT_BASKETBALL = new MindmapIcon(IconFamily.SPORT, "basketball");
public static final MindmapIcon SPORT_FOOTBALL = new MindmapIcon(IconFamily.SPORT, "football");
public static final MindmapIcon SPORT_GOLF = new MindmapIcon(IconFamily.SPORT, "golf");
public static final MindmapIcon SPORT_RAQUET = new MindmapIcon(IconFamily.SPORT, "raquet");
public static final MindmapIcon SPORT_SHUTTLECLOCK = new MindmapIcon(IconFamily.SPORT, "shuttlecock");
public static final MindmapIcon SPORT_SOURCE = new MindmapIcon(IconFamily.SPORT, "soccer");
public static final MindmapIcon SPORT_TENNIS = new MindmapIcon(IconFamily.SPORT, "tennis");
public static final MindmapIcon TIME_CALENDAR = new MindmapIcon(IconFamily.TIME, "calendar");
public static final MindmapIcon TIME_CLOCK = new MindmapIcon(IconFamily.TIME, "clock");
public static final MindmapIcon TIME_HOURGLASS = new MindmapIcon(IconFamily.TIME, "hourglass");
public static final MindmapIcon OBJECT_BELL = new MindmapIcon(IconFamily.OBJECT, "bell");
public static final MindmapIcon OBJECT_BOMB = new MindmapIcon(IconFamily.OBJECT, "clanbomber");
public static final MindmapIcon OBJECT_KEY = new MindmapIcon(IconFamily.OBJECT, "key");
public static final MindmapIcon OBJECT_PENCIL = new MindmapIcon(IconFamily.OBJECT, "pencil");
public static final MindmapIcon OBJECT_PHONE = new MindmapIcon(IconFamily.OBJECT, "phone");
public static final MindmapIcon OBJECT_MAGNIFIER = new MindmapIcon(IconFamily.OBJECT, "magnifier");
public static final MindmapIcon OBJECT_CLIP = new MindmapIcon(IconFamily.OBJECT, "clip");
public static final MindmapIcon OBJECT_MUSIC = new MindmapIcon(IconFamily.OBJECT, "music");
public static final MindmapIcon OBJECT_STAR = new MindmapIcon(IconFamily.OBJECT, "star");
public static final MindmapIcon OBJECT_WIZARD = new MindmapIcon(IconFamily.OBJECT, "wizard");
public static final MindmapIcon OBJECT_HOUSE = new MindmapIcon(IconFamily.OBJECT, "house");
public static final MindmapIcon OBJECT_CAKE = new MindmapIcon(IconFamily.OBJECT, "cake");
public static final MindmapIcon OBJECT_CAMERA = new MindmapIcon(IconFamily.OBJECT, "camera");
public static final MindmapIcon OBJECT_PALETTE = new MindmapIcon(IconFamily.OBJECT, "palette");
public static final MindmapIcon OBJECT_RAINBOW = new MindmapIcon(IconFamily.OBJECT, "rainbow");
public static final MindmapIcon WEATHER_CLEAR_NIGHT = new MindmapIcon(IconFamily.WEATHER, "clear-night");
public static final MindmapIcon WEATHER_CLEAR = new MindmapIcon(IconFamily.WEATHER, "clear");
public static final MindmapIcon WEATHER_FEW_CLOUDS_NIGHT = new MindmapIcon(IconFamily.WEATHER, "few-clouds-night");
public static final MindmapIcon WEATHER_FEW_CLOUDS = new MindmapIcon(IconFamily.WEATHER, "few-clouds");
public static final MindmapIcon WEATHER_OVERCAST = new MindmapIcon(IconFamily.WEATHER, "overcast");
public static final MindmapIcon WEATHER_SEVERE_ALERT = new MindmapIcon(IconFamily.WEATHER, "severe-alert");
public static final MindmapIcon WEATHER_SHOWERS_SCATTERED = new MindmapIcon(IconFamily.WEATHER, "showers-scattered");
public static final MindmapIcon WEATHER_SHOWERS = new MindmapIcon(IconFamily.WEATHER, "showers");
public static final MindmapIcon WEATHER_SNOW = new MindmapIcon(IconFamily.WEATHER, "snow");
public static final MindmapIcon WEATHER_STORM = new MindmapIcon(IconFamily.WEATHER, "storm");
public static final MindmapIcon MAIL_ENVELOP = new MindmapIcon(IconFamily.MAIL, "envelop");
public static final MindmapIcon MAIL_MAILBOX = new MindmapIcon(IconFamily.MAIL, "mailbox");
public static final MindmapIcon MAIL_EDIT = new MindmapIcon(IconFamily.MAIL, "edit");
public static final MindmapIcon MAIL_LIST = new MindmapIcon(IconFamily.MAIL, "list");
public static final MindmapIcon SIGN_WARNING = new MindmapIcon(IconFamily.SIGN, "warning");
public static final MindmapIcon SIGN_INFO = new MindmapIcon(IconFamily.SIGN, "info");
public static final MindmapIcon SIGN_STOP = new MindmapIcon(IconFamily.SIGN, "stop");
public static final MindmapIcon SIGN_HELP = new MindmapIcon(IconFamily.SIGN, "help");
public static final MindmapIcon SIGN_CANCEL = new MindmapIcon(IconFamily.SIGN, "cancel");
public static final MindmapIcon HARD_CD = new MindmapIcon(IconFamily.HARD, "cd");
public static final MindmapIcon HARD_COMPUTER = new MindmapIcon(IconFamily.HARD, "computer");
public static final MindmapIcon HARD_CONTROLLER = new MindmapIcon(IconFamily.HARD, "controller");
public static final MindmapIcon HARD_DRIVER_DISK = new MindmapIcon(IconFamily.HARD, "driver_disk");
public static final MindmapIcon HARD_IPOD = new MindmapIcon(IconFamily.HARD, "ipod");
public static final MindmapIcon HARD_KEYBOARD = new MindmapIcon(IconFamily.HARD, "keyboard");
public static final MindmapIcon HARD_MOUSE = new MindmapIcon(IconFamily.HARD, "mouse");
public static final MindmapIcon HARD_PRINTER = new MindmapIcon(IconFamily.HARD, "printer");
public static final MindmapIcon SOFT_BUG = new MindmapIcon(IconFamily.SOFT, "bug");
public static final MindmapIcon SOFT_CURSOR = new MindmapIcon(IconFamily.SOFT, "cursor");
public static final MindmapIcon SOFT_DATABASE_TABLE = new MindmapIcon(IconFamily.SOFT, "database_table");
public static final MindmapIcon SOFT_DATABASE = new MindmapIcon(IconFamily.SOFT, "database");
public static final MindmapIcon SOFT_FEED = new MindmapIcon(IconFamily.SOFT, "feed");
public static final MindmapIcon SOFT_FOLDER_EXPORE = new MindmapIcon(IconFamily.SOFT, "folder_explore");
public static final MindmapIcon SOFT_RSS = new MindmapIcon(IconFamily.SOFT, "rss");
public static final MindmapIcon SOFT_PENGUIN = new MindmapIcon(IconFamily.SOFT, "penguin");
public static final MindmapIcon PEOPLE_GROUP = new MindmapIcon(IconFamily.PEOPLE, "group");
public static final MindmapIcon PEOPLE_MALE = new MindmapIcon(IconFamily.PEOPLE, "male1");
public static final MindmapIcon PEOPLE_MALE2 = new MindmapIcon(IconFamily.PEOPLE, "male2");
public static final MindmapIcon PEOPLE_FEMALE = new MindmapIcon(IconFamily.PEOPLE, "female1");
public static final MindmapIcon PEOPLE_FEMALE2 = new MindmapIcon(IconFamily.PEOPLE, "female2");
@NotNull
public static List<MindmapIcon> getIconByFamily(@NotNull IconFamily family) {
load();
return iconsByFamily.get(family);
}
private static void load() {
try {
if (iconsByFamily == null) {
iconsByFamily = new TreeMap<IconFamily, List<MindmapIcon>>();
Field[] fields = MindmapIcons.class.getDeclaredFields();
for (Field field : fields) {
final Object object = field.get(null);
if (object instanceof MindmapIcon) {
final MindmapIcon icon = (MindmapIcon) object;
final IconFamily iconFamily = icon.getFamily();
List<MindmapIcon> mindmapIcons = iconsByFamily.get(iconFamily);
if (mindmapIcons == null) {
mindmapIcons = new ArrayList<MindmapIcon>();
iconsByFamily.put(iconFamily, mindmapIcons);
}
mindmapIcons.add(icon);
}
}
}
} catch (IllegalAccessException e) {
throw new IllegalStateException(e);
}
}
public static MindmapIcon findById(final @NotNull String id) {
for (IconFamily imageFamily : iconsByFamily.keySet()) {
final List<MindmapIcon> mindmapIcons = iconsByFamily.get(imageFamily);
for (MindmapIcon mindmapIcon : mindmapIcons) {
if (mindmapIcon.getId().equals(id)) {
return mindmapIcon;
}
}
}
throw new IllegalArgumentException("Image could not be found. Id:" + id);
}
}
/*
* Copyright [2011] [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.model;
import org.jetbrains.annotations.NotNull;
import java.lang.IllegalStateException;
import java.lang.reflect.Field;
import java.util.*;
@SuppressWarnings({"UnusedDeclaration"})
public class MindmapIcons {
private static Map<IconFamily, List<MindmapIcon>> iconsByFamily;
public static final MindmapIcon FACE_PLAIN = new MindmapIcon(IconFamily.FACE, "plain");
public static final MindmapIcon FACE_SAD = new MindmapIcon(IconFamily.FACE, "sad");
public static final MindmapIcon FACE_CRYING = new MindmapIcon(IconFamily.FACE, "crying");
public static final MindmapIcon FACE_SMILE = new MindmapIcon(IconFamily.FACE, "smile");
public static final MindmapIcon FACE_SURPRISE = new MindmapIcon(IconFamily.FACE, "surprise");
public static final MindmapIcon FACE_WINK = new MindmapIcon(IconFamily.FACE, "wink");
public static final MindmapIcon THUMB__UP = new MindmapIcon(IconFamily.THUMB, "thumb_up");
public static final MindmapIcon THUMB_DOWN = new MindmapIcon(IconFamily.THUMB, "thumb_down");
public static final MindmapIcon ARROW_UP = new MindmapIcon(IconFamily.ARROW, "up");
public static final MindmapIcon ARROW_DOWN = new MindmapIcon(IconFamily.ARROW, "down");
public static final MindmapIcon ARROW_LEFT = new MindmapIcon(IconFamily.ARROW, "left");
public static final MindmapIcon ARROW_RIGHT = new MindmapIcon(IconFamily.ARROW, "right");
// public static final MindmapIcon TASK_ONE = new MindmapIcon(IconFamily.TASK, "one");
// public static final MindmapIcon TASK_TWO = new MindmapIcon(IconFamily.TASK, "two");
// public static final MindmapIcon TASK_THREE = new MindmapIcon(IconFamily.TASK, "three");
// public static final MindmapIcon TASK_FOUR = new MindmapIcon(IconFamily.TASK, "four");
// public static final MindmapIcon TASK_FIVE = new MindmapIcon(IconFamily.TASK, "five");
// public static final MindmapIcon ARROWC_UNDO = new MindmapIcon(IconFamily.ARROWC, "undo");
public static final MindmapIcon ARROWC_ANTICLOCK_WISE = new MindmapIcon(IconFamily.ARROWC, "rotate_anticlockwise");
public static final MindmapIcon ARROWC_CLOCK_WISE = new MindmapIcon(IconFamily.ARROWC, "rotate_clockwise");
public static final MindmapIcon ARROWC_LEFT = new MindmapIcon(IconFamily.ARROWC, "turn_left");
public static final MindmapIcon ARROWC_RIGHT = new MindmapIcon(IconFamily.ARROWC, "turn_right");
public static final MindmapIcon BULB_LIGHT_ON = new MindmapIcon(IconFamily.BULB, "light_on");
public static final MindmapIcon BULB_LIGHT__OFF = new MindmapIcon(IconFamily.BULB, "light_off");
public static final MindmapIcon TICK_TICK = new MindmapIcon(IconFamily.TICK, "tick");
public static final MindmapIcon TICK_CROSS = new MindmapIcon(IconFamily.TICK, "cross");
public static final MindmapIcon CHART_BAR = new MindmapIcon(IconFamily.CHART, "bar");
public static final MindmapIcon CHART_LINE = new MindmapIcon(IconFamily.CHART, "line");
public static final MindmapIcon CHART_CURVE = new MindmapIcon(IconFamily.CHART, "curve");
public static final MindmapIcon CHART_PIE = new MindmapIcon(IconFamily.CHART, "pie");
public static final MindmapIcon CHART_ORGANISATION = new MindmapIcon(IconFamily.CHART, "organisation");
public static final MindmapIcon ONOFF_CLOCK = new MindmapIcon(IconFamily.ONOFF, "clock");
public static final MindmapIcon ONOFF_CLOCK__RED = new MindmapIcon(IconFamily.ONOFF, "clock_red");
public static final MindmapIcon ONOFF_ADD = new MindmapIcon(IconFamily.ONOFF, "add");
public static final MindmapIcon ONOFF_DELETE = new MindmapIcon(IconFamily.ONOFF, "delete");
public static final MindmapIcon ONOFF_STATUS_OFFLINE = new MindmapIcon(IconFamily.ONOFF, "status_offline");
public static final MindmapIcon ONOFF_STATUS_ONLINE = new MindmapIcon(IconFamily.ONOFF, "status_online");
public static final MindmapIcon TAG_BLUE = new MindmapIcon(IconFamily.TAG, "blue");
public static final MindmapIcon TAG_GREEN = new MindmapIcon(IconFamily.TAG, "green");
public static final MindmapIcon TAG_ORANGE = new MindmapIcon(IconFamily.TAG, "orange");
public static final MindmapIcon TAG_RED = new MindmapIcon(IconFamily.TAG, "red");
public static final MindmapIcon TAG_PINK = new MindmapIcon(IconFamily.TAG, "pink");
public static final MindmapIcon TAG_YELLOW = new MindmapIcon(IconFamily.TAG, "yellow");
// public static final MindmapIcon NUMBER_ONE = new MindmapIcon(IconFamily.NUMBER, "one");
// public static final MindmapIcon NUMBER_TWO = new MindmapIcon(IconFamily.NUMBER, "two");
// public static final MindmapIcon NUMBER_THREE = new MindmapIcon(IconFamily.NUMBER, "three");
// public static final MindmapIcon NUMBER_FOUR = new MindmapIcon(IconFamily.NUMBER, "four");
// public static final MindmapIcon NUMBER_FIVE = new MindmapIcon(IconFamily.NUMBER, "five");
// public static final MindmapIcon NUMBER_SIX = new MindmapIcon(IconFamily.NUMBER, "six");
// public static final MindmapIcon NUMBER_SEVEN = new MindmapIcon(IconFamily.NUMBER, "seven");
// public static final MindmapIcon NUMBER_EIGHT = new MindmapIcon(IconFamily.NUMBER, "eight");
// public static final MindmapIcon NUMBER_NINE = new MindmapIcon(IconFamily.NUMBER, "nine");
public static final MindmapIcon FUNNY_ANGEL = new MindmapIcon(IconFamily.FUNY, "angel");
public static final MindmapIcon FUNNY_DEVILISH = new MindmapIcon(IconFamily.FUNY, "devilish");
public static final MindmapIcon FUNNY_GLASSES = new MindmapIcon(IconFamily.FUNY, "glasses");
public static final MindmapIcon FUNNY_GRIN = new MindmapIcon(IconFamily.FUNY, "grin");
public static final MindmapIcon FUNNY_KISS = new MindmapIcon(IconFamily.FUNY, "kiss");
public static final MindmapIcon FUNNY_MONKEY = new MindmapIcon(IconFamily.FUNY, "monkey");
public static final MindmapIcon FLAG_BLUE = new MindmapIcon(IconFamily.FLAG, "blue");
public static final MindmapIcon FLAG_GREEN = new MindmapIcon(IconFamily.FLAG, "green");
public static final MindmapIcon FLAG_ORANGE = new MindmapIcon(IconFamily.FLAG, "orange");
public static final MindmapIcon FLAG_PINK = new MindmapIcon(IconFamily.FLAG, "pink");
public static final MindmapIcon FLAG_PURPLE = new MindmapIcon(IconFamily.FLAG, "purple");
public static final MindmapIcon FLAG_YELLOW = new MindmapIcon(IconFamily.FLAG, "yellow");
public static final MindmapIcon BULLET_BLACK = new MindmapIcon(IconFamily.BULLET, "black");
public static final MindmapIcon BULLET_BLUE = new MindmapIcon(IconFamily.BULLET, "blue");
public static final MindmapIcon BULLET_BLUEGREEN = new MindmapIcon(IconFamily.BULLET, "green");
public static final MindmapIcon BULLET_BLUEORANGE = new MindmapIcon(IconFamily.BULLET, "orange");
public static final MindmapIcon BULLET_BLUERED = new MindmapIcon(IconFamily.BULLET, "red");
public static final MindmapIcon BULLET_BLUEPINK = new MindmapIcon(IconFamily.BULLET, "pink");
public static final MindmapIcon BULLET_BLUEPURPLE = new MindmapIcon(IconFamily.BULLET, "purple");
public static final MindmapIcon MONEY_GENERIC = new MindmapIcon(IconFamily.MONEY, "money");
public static final MindmapIcon MONEY_DOLLAR = new MindmapIcon(IconFamily.MONEY, "dollar");
public static final MindmapIcon MONEY_EURO = new MindmapIcon(IconFamily.MONEY, "euro");
public static final MindmapIcon MONEY_POUND = new MindmapIcon(IconFamily.MONEY, "pound");
public static final MindmapIcon MONEY_YEN = new MindmapIcon(IconFamily.MONEY, "yen");
public static final MindmapIcon MONEY_COINS = new MindmapIcon(IconFamily.MONEY, "coins");
public static final MindmapIcon MONEY_RUBY = new MindmapIcon(IconFamily.MONEY, "ruby");
public static final MindmapIcon MONEY_CONNECT = new MindmapIcon(IconFamily.CONN, "connect");
public static final MindmapIcon MONEY_DISCONNECT = new MindmapIcon(IconFamily.CONN, "disconnect");
public static final MindmapIcon SPORT_BASKETBALL = new MindmapIcon(IconFamily.SPORT, "basketball");
public static final MindmapIcon SPORT_FOOTBALL = new MindmapIcon(IconFamily.SPORT, "football");
public static final MindmapIcon SPORT_GOLF = new MindmapIcon(IconFamily.SPORT, "golf");
public static final MindmapIcon SPORT_RAQUET = new MindmapIcon(IconFamily.SPORT, "raquet");
public static final MindmapIcon SPORT_SHUTTLECLOCK = new MindmapIcon(IconFamily.SPORT, "shuttlecock");
public static final MindmapIcon SPORT_SOURCE = new MindmapIcon(IconFamily.SPORT, "soccer");
public static final MindmapIcon SPORT_TENNIS = new MindmapIcon(IconFamily.SPORT, "tennis");
public static final MindmapIcon TIME_CALENDAR = new MindmapIcon(IconFamily.TIME, "calendar");
public static final MindmapIcon TIME_CLOCK = new MindmapIcon(IconFamily.TIME, "clock");
public static final MindmapIcon TIME_HOURGLASS = new MindmapIcon(IconFamily.TIME, "hourglass");
public static final MindmapIcon OBJECT_BELL = new MindmapIcon(IconFamily.OBJECT, "bell");
public static final MindmapIcon OBJECT_BOMB = new MindmapIcon(IconFamily.OBJECT, "clanbomber");
public static final MindmapIcon OBJECT_KEY = new MindmapIcon(IconFamily.OBJECT, "key");
public static final MindmapIcon OBJECT_PENCIL = new MindmapIcon(IconFamily.OBJECT, "pencil");
public static final MindmapIcon OBJECT_PHONE = new MindmapIcon(IconFamily.OBJECT, "phone");
public static final MindmapIcon OBJECT_MAGNIFIER = new MindmapIcon(IconFamily.OBJECT, "magnifier");
public static final MindmapIcon OBJECT_CLIP = new MindmapIcon(IconFamily.OBJECT, "clip");
public static final MindmapIcon OBJECT_MUSIC = new MindmapIcon(IconFamily.OBJECT, "music");
public static final MindmapIcon OBJECT_STAR = new MindmapIcon(IconFamily.OBJECT, "star");
public static final MindmapIcon OBJECT_WIZARD = new MindmapIcon(IconFamily.OBJECT, "wizard");
public static final MindmapIcon OBJECT_HOUSE = new MindmapIcon(IconFamily.OBJECT, "house");
public static final MindmapIcon OBJECT_CAKE = new MindmapIcon(IconFamily.OBJECT, "cake");
public static final MindmapIcon OBJECT_CAMERA = new MindmapIcon(IconFamily.OBJECT, "camera");
public static final MindmapIcon OBJECT_PALETTE = new MindmapIcon(IconFamily.OBJECT, "palette");
public static final MindmapIcon OBJECT_RAINBOW = new MindmapIcon(IconFamily.OBJECT, "rainbow");
public static final MindmapIcon WEATHER_CLEAR_NIGHT = new MindmapIcon(IconFamily.WEATHER, "clear-night");
public static final MindmapIcon WEATHER_CLEAR = new MindmapIcon(IconFamily.WEATHER, "clear");
public static final MindmapIcon WEATHER_FEW_CLOUDS_NIGHT = new MindmapIcon(IconFamily.WEATHER, "few-clouds-night");
public static final MindmapIcon WEATHER_FEW_CLOUDS = new MindmapIcon(IconFamily.WEATHER, "few-clouds");
public static final MindmapIcon WEATHER_OVERCAST = new MindmapIcon(IconFamily.WEATHER, "overcast");
public static final MindmapIcon WEATHER_SEVERE_ALERT = new MindmapIcon(IconFamily.WEATHER, "severe-alert");
public static final MindmapIcon WEATHER_SHOWERS_SCATTERED = new MindmapIcon(IconFamily.WEATHER, "showers-scattered");
public static final MindmapIcon WEATHER_SHOWERS = new MindmapIcon(IconFamily.WEATHER, "showers");
public static final MindmapIcon WEATHER_SNOW = new MindmapIcon(IconFamily.WEATHER, "snow");
public static final MindmapIcon WEATHER_STORM = new MindmapIcon(IconFamily.WEATHER, "storm");
public static final MindmapIcon MAIL_ENVELOP = new MindmapIcon(IconFamily.MAIL, "envelop");
public static final MindmapIcon MAIL_MAILBOX = new MindmapIcon(IconFamily.MAIL, "mailbox");
public static final MindmapIcon MAIL_EDIT = new MindmapIcon(IconFamily.MAIL, "edit");
public static final MindmapIcon MAIL_LIST = new MindmapIcon(IconFamily.MAIL, "list");
public static final MindmapIcon SIGN_WARNING = new MindmapIcon(IconFamily.SIGN, "warning");
public static final MindmapIcon SIGN_INFO = new MindmapIcon(IconFamily.SIGN, "info");
public static final MindmapIcon SIGN_STOP = new MindmapIcon(IconFamily.SIGN, "stop");
public static final MindmapIcon SIGN_HELP = new MindmapIcon(IconFamily.SIGN, "help");
public static final MindmapIcon SIGN_CANCEL = new MindmapIcon(IconFamily.SIGN, "cancel");
public static final MindmapIcon HARD_CD = new MindmapIcon(IconFamily.HARD, "cd");
public static final MindmapIcon HARD_COMPUTER = new MindmapIcon(IconFamily.HARD, "computer");
public static final MindmapIcon HARD_CONTROLLER = new MindmapIcon(IconFamily.HARD, "controller");
public static final MindmapIcon HARD_DRIVER_DISK = new MindmapIcon(IconFamily.HARD, "driver_disk");
public static final MindmapIcon HARD_IPOD = new MindmapIcon(IconFamily.HARD, "ipod");
public static final MindmapIcon HARD_KEYBOARD = new MindmapIcon(IconFamily.HARD, "keyboard");
public static final MindmapIcon HARD_MOUSE = new MindmapIcon(IconFamily.HARD, "mouse");
public static final MindmapIcon HARD_PRINTER = new MindmapIcon(IconFamily.HARD, "printer");
public static final MindmapIcon SOFT_BUG = new MindmapIcon(IconFamily.SOFT, "bug");
public static final MindmapIcon SOFT_CURSOR = new MindmapIcon(IconFamily.SOFT, "cursor");
public static final MindmapIcon SOFT_DATABASE_TABLE = new MindmapIcon(IconFamily.SOFT, "database_table");
public static final MindmapIcon SOFT_DATABASE = new MindmapIcon(IconFamily.SOFT, "database");
public static final MindmapIcon SOFT_FEED = new MindmapIcon(IconFamily.SOFT, "feed");
public static final MindmapIcon SOFT_FOLDER_EXPORE = new MindmapIcon(IconFamily.SOFT, "folder_explore");
public static final MindmapIcon SOFT_RSS = new MindmapIcon(IconFamily.SOFT, "rss");
public static final MindmapIcon SOFT_PENGUIN = new MindmapIcon(IconFamily.SOFT, "penguin");
public static final MindmapIcon PEOPLE_GROUP = new MindmapIcon(IconFamily.PEOPLE, "group");
public static final MindmapIcon PEOPLE_MALE = new MindmapIcon(IconFamily.PEOPLE, "male1");
public static final MindmapIcon PEOPLE_MALE2 = new MindmapIcon(IconFamily.PEOPLE, "male2");
public static final MindmapIcon PEOPLE_FEMALE = new MindmapIcon(IconFamily.PEOPLE, "female1");
public static final MindmapIcon PEOPLE_FEMALE2 = new MindmapIcon(IconFamily.PEOPLE, "female2");
public static List<MindmapIcon> getIconByFamily(@NotNull IconFamily family) {
load();
return iconsByFamily.get(family);
}
private static void load() {
try {
if (iconsByFamily == null) {
iconsByFamily = new TreeMap<IconFamily, List<MindmapIcon>>();
Field[] fields = MindmapIcons.class.getDeclaredFields();
for (Field field : fields) {
final Object object = field.get(null);
if (object instanceof MindmapIcon) {
final MindmapIcon icon = (MindmapIcon) object;
final IconFamily iconFamily = icon.getFamily();
List<MindmapIcon> mindmapIcons = iconsByFamily.get(iconFamily);
if (mindmapIcons == null) {
mindmapIcons = new ArrayList<MindmapIcon>();
iconsByFamily.put(iconFamily, mindmapIcons);
}
mindmapIcons.add(icon);
}
}
}
} catch (IllegalAccessException e) {
throw new IllegalStateException(e);
}
}
public static MindmapIcon findById(final @NotNull String id) {
for (IconFamily imageFamily : iconsByFamily.keySet()) {
final List<MindmapIcon> mindmapIcons = iconsByFamily.get(imageFamily);
for (MindmapIcon mindmapIcon : mindmapIcons) {
if (mindmapIcon.getId().equals(id)) {
return mindmapIcon;
}
}
}
throw new IllegalArgumentException("Image could not be found. Id:" + id);
}
}

View File

@ -110,7 +110,7 @@ public class User
if (!getEmail().equals(user.getEmail())) return false;
if (firstname != null ? !firstname.equals(user.firstname) : user.firstname != null) return false;
if (lastname != null ? !lastname.equals(user.lastname) : user.lastname != null) return false;
if (password != null ? !password.equals(user.password) : user.password != null) return false;
if (username != null ? !username.equals(user.username) : user.username != null) return false;
return true;
}

View File

@ -11,11 +11,11 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@Controller
public class AdminController extends BaseController {
private static final String RESPONSE_VIEW = "responseView";
@Autowired
private UserService userService;
@ -26,7 +26,7 @@ public class AdminController extends BaseController {
if (userBy == null) {
throw new IllegalArgumentException("User could not be found");
}
return new ModelAndView("userView", "user", new RestUser(userBy));
return new ModelAndView("userView", "user", new RestUser(userBy));
}
@RequestMapping(method = RequestMethod.GET, value = "admin/users/email/{email}", produces = {"application/json", "text/html", "application/xml"})
@ -40,7 +40,8 @@ public class AdminController extends BaseController {
}
@RequestMapping(method = RequestMethod.POST, value = "admin/users", consumes = {"application/xml", "application/json"}, produces = {"application/json", "text/html", "application/xml"})
public ModelAndView getUserByEmail(@RequestBody RestUser user) throws IOException, WiseMappingException {
@ResponseStatus(value = HttpStatus.CREATED)
public void getUserByEmail(@RequestBody RestUser user, HttpServletResponse response) throws IOException, WiseMappingException {
if (user == null) {
throw new IllegalArgumentException("User could not be found");
}
@ -51,8 +52,24 @@ public class AdminController extends BaseController {
throw new IllegalArgumentException("User already exists with this email.");
}
userService.createUser(user.getDelegated(), false);
return new ModelAndView(RESPONSE_VIEW, "message", "User '" + user.getId() + "' created successfully");
final User delegated = user.getDelegated();
final String lastname = delegated.getLastname();
if (lastname == null || lastname.isEmpty()) {
throw new IllegalArgumentException("lastname can not be null");
}
final String firstName = delegated.getFirstname();
if (firstName == null || firstName.isEmpty()) {
throw new IllegalArgumentException("firstname can not be null");
}
final String username = delegated.getUsername();
if (username == null || username.isEmpty()) {
throw new IllegalArgumentException("username can not be null");
}
userService.createUser(delegated, false);
response.setHeader("Location","/service/admin/users/" + user.getId());
}
@RequestMapping(method = RequestMethod.PUT, value = "admin/users/{id}/password", consumes = {"text/plain"}, produces = {"application/json", "text/html", "application/xml"})

View File

@ -1,7 +1,6 @@
package com.wisemapping.rest.model;
import com.wisemapping.model.MindMap;
import com.wisemapping.model.User;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore;
@ -10,9 +9,7 @@ import org.jetbrains.annotations.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import java.util.Set;
@XmlRootElement(name = "user")
@ -22,6 +19,7 @@ import java.util.Set;
public class RestUser {
private User user;
private String password;
public RestUser() {
this(new User());
@ -59,9 +57,9 @@ public class RestUser {
user.setLastname(lastname);
}
public boolean isActive() {
return user.isActive();
}
// public boolean isActive() {
// return user.isActive();
// }
public String getUsername() {
return user.getUsername();
@ -91,12 +89,34 @@ public class RestUser {
// user.setCreationDate(creationDate);
}
public void setPassword(@NotNull final String password){
public void setPassword(final String password) {
this.user.setPassword(password);
this.password = password;
}
public String getPassword() {
return this.password;
}
@JsonIgnore
public User getDelegated(){
public User getDelegated() {
return this.user;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof RestUser)) {
return false;
}
RestUser restUser = (RestUser) o;
return this.getDelegated().equals(restUser.getDelegated());
}
@Override
public int hashCode() {
return this.getDelegated().hashCode();
}
}

View File

@ -54,7 +54,9 @@
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView"/>
<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView">
<property name="extractValueFromSingleKeyModel" value="true"/>
</bean>
<bean class="org.springframework.web.servlet.view.xml.MarshallingView">
<constructor-arg ref="jaxbMarshaller"/>
</bean>

View File

@ -1,17 +1,98 @@
package com.wisemapping.test.rest;
import com.wisemapping.rest.model.RestUser;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.springframework.http.*;
import org.springframework.http.client.SimpleClientHttpRequestFactory;
import org.springframework.security.crypto.codec.Base64;
import org.springframework.web.client.RestTemplate;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
@Test
public class RestAdminITCase {
@Test
public void createNewUser() {
String uri = "http://localhost:9000/service/admin/user";
@NonNls
private static final String HOST_PORT = "http://localhost:8080/";
private static final String BASE_REST_URL = HOST_PORT + "service";
// RestTemplate template = new RestTemplate();
// location = template.postForLocation(uri);
@Test(dataProvider = "ContentType-Provider-Function")
public void findUser(final @NotNull MediaType mediaType) { // Configure media types ...
final HttpHeaders requestHeaders = createHeaders(mediaType);
final RestTemplate templateRest = createTemplate();
HttpEntity<RestUser> findUserEntity = new HttpEntity<RestUser>(requestHeaders);
final ResponseEntity<RestUser> result = templateRest.exchange(BASE_REST_URL + "/admin/users/2", HttpMethod.GET, findUserEntity, RestUser.class);
}
@Test(dataProvider = "ContentType-Provider-Function")
public void createNewUser(final @NotNull MediaType mediaType) {
// Configure media types ...
final HttpHeaders requestHeaders = createHeaders(mediaType);
// Configure media ...
final RestTemplate templateRest = createTemplate();
// Fill user data ...
final RestUser restUser = new RestUser();
restUser.setEmail("foo" + System.nanoTime() + "@example.org");
restUser.setUsername("foo");
restUser.setFirstname("foo first name");
restUser.setLastname("foo last name");
restUser.setPassword("foo password");
// Post request ...
HttpEntity<RestUser> createUserEntity = new HttpEntity<RestUser>(restUser, requestHeaders);
URI location = templateRest.postForLocation(BASE_REST_URL + "/admin/users", createUserEntity);
System.out.println("location:" + location);
// Check that the user has been created ...
HttpEntity<RestUser> findUserEntity = new HttpEntity<RestUser>(requestHeaders);
final String url = "http://localhost:8080" + location;
final ResponseEntity<RestUser> result = templateRest.exchange(url, HttpMethod.GET, findUserEntity, RestUser.class);
assertEquals(result.getBody(), restUser, "Returned object object seems not be the same.");
}
private HttpHeaders createHeaders(MediaType mediaType) {
List<MediaType> acceptableMediaTypes = new ArrayList<MediaType>();
acceptableMediaTypes.add(mediaType);
final HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.setAccept(acceptableMediaTypes);
requestHeaders.setContentType(mediaType);
return requestHeaders;
}
private RestTemplate createTemplate() {
SimpleClientHttpRequestFactory s = new SimpleClientHttpRequestFactory() {
@Override
protected void prepareConnection(HttpURLConnection connection, String httpMethod) throws IOException {
super.prepareConnection(connection, httpMethod);
//Basic Authentication for Police API
String authorisation = "admin@wisemapping.org" + ":" + "admin";
byte[] encodedAuthorisation = Base64.encode(authorisation.getBytes());
connection.setRequestProperty("Authorization", "Basic " + new String(encodedAuthorisation));
}
};
return new RestTemplate(s);
}
@DataProvider(name = "ContentType-Provider-Function")
public Object[][] contentTypes() {
return new Object[][]{{MediaType.APPLICATION_XML}, {MediaType.APPLICATION_JSON}};
}
}