summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-06-24 23:28:22 +0300
committerHenri Sara <hesara@vaadin.com>2015-07-04 13:22:49 +0300
commita827e893579a646f518bfd0abd93bbb771d73b2e (patch)
treeceff5d8621055a4177b1674781b17c431de37f80 /server
parentf68f1d058d600f2802d60a72227514c66f2b2a51 (diff)
downloadvaadin-framework-a827e893579a646f518bfd0abd93bbb771d73b2e.tar.gz
vaadin-framework-a827e893579a646f518bfd0abd93bbb771d73b2e.zip
Pass critical notification details to the client (#18342)
Change-Id: I50fbbd0f3e6589d144b733c5f08f5a625acfc1e6
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/VaadinService.java15
-rw-r--r--server/tests/src/com/vaadin/server/VaadinServiceTest.java45
2 files changed, 25 insertions, 35 deletions
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java
index 74f0051e30..bff71fedee 100644
--- a/server/src/com/vaadin/server/VaadinService.java
+++ b/server/src/com/vaadin/server/VaadinService.java
@@ -1574,8 +1574,8 @@ public abstract class VaadinService implements Serializable {
JsonObject appError = Json.createObject();
putValueOrJsonNull(appError, "caption", caption);
putValueOrJsonNull(appError, "url", url);
- putValueOrJsonNull(appError, "message",
- createCriticalNotificationMessage(message, details));
+ putValueOrJsonNull(appError, "message", message);
+ putValueOrJsonNull(appError, "details", details);
JsonObject meta = Json.createObject();
meta.put("appError", appError);
@@ -1595,17 +1595,6 @@ public abstract class VaadinService implements Serializable {
return "for(;;);[" + returnString + "]";
}
- private static String createCriticalNotificationMessage(String message,
- String details) {
- if (message == null) {
- return details;
- } else if (details != null) {
- return message + "<br/><br/>" + details;
- }
-
- return message;
- }
-
private static void putValueOrJsonNull(JsonObject json, String key,
String value) {
if (value == null) {
diff --git a/server/tests/src/com/vaadin/server/VaadinServiceTest.java b/server/tests/src/com/vaadin/server/VaadinServiceTest.java
index 4b655e7855..bd3da6277a 100644
--- a/server/tests/src/com/vaadin/server/VaadinServiceTest.java
+++ b/server/tests/src/com/vaadin/server/VaadinServiceTest.java
@@ -42,9 +42,10 @@ public class VaadinServiceTest {
}
}
- private String createCriticalNotification(String caption, String message, String details, String url) {
- return VaadinService
- .createCriticalNotificationJSON(caption, message, details, url);
+ private String createCriticalNotification(String caption, String message,
+ String details, String url) {
+ return VaadinService.createCriticalNotificationJSON(caption, message,
+ details, url);
}
@Test
@@ -77,64 +78,64 @@ public class VaadinServiceTest {
@Test
public void captionIsSetToACriticalNotification() {
- String notification =
- createCriticalNotification("foobar", "message", "details", "url");
+ String notification = createCriticalNotification("foobar", "message",
+ "details", "url");
assertThat(notification, containsString("\"caption\":\"foobar\""));
}
@Test
public void nullCaptionIsSetToACriticalNotification() {
- String notification =
- createCriticalNotification(null, "message", "details", "url");
+ String notification = createCriticalNotification(null, "message",
+ "details", "url");
assertThat(notification, containsString("\"caption\":null"));
}
@Test
public void messageWithDetailsIsSetToACriticalNotification() {
- String notification =
- createCriticalNotification("caption", "foo", "bar", "url");
+ String notification = createCriticalNotification("caption", "foo",
+ "bar", "url");
- assertThat(notification, containsString("\"message\":\"foo<br/><br/>bar\""));
+ assertThat(notification, containsString("\"details\":\"bar\""));
}
@Test
- public void nullMessageIsReplacedByDetailsInACriticalNotification() {
- String notification =
- createCriticalNotification("caption", null, "foobar", "url");
+ public void nullMessageSentAsNullInACriticalNotification() {
+ String notification = createCriticalNotification("caption", null,
+ "foobar", "url");
- assertThat(notification, containsString("\"message\":\"foobar\""));
+ assertThat(notification, containsString("\"message\":null"));
}
@Test
public void nullMessageIsSetToACriticalNotification() {
- String notification =
- createCriticalNotification("caption", null, null, "url");
+ String notification = createCriticalNotification("caption", null, null,
+ "url");
assertThat(notification, containsString("\"message\":null"));
}
@Test
public void messageSetToACriticalNotification() {
- String notification =
- createCriticalNotification("caption", "foobar", null, "url");
+ String notification = createCriticalNotification("caption", "foobar",
+ null, "url");
assertThat(notification, containsString("\"message\":\"foobar\""));
}
@Test
public void urlIsSetToACriticalNotification() {
- String notification =
- createCriticalNotification("caption", "message", "details", "foobar");
+ String notification = createCriticalNotification("caption", "message",
+ "details", "foobar");
assertThat(notification, containsString("\"url\":\"foobar\""));
}
@Test
public void nullUrlIsSetToACriticalNotification() {
- String notification =
- createCriticalNotification("caption", "message", "details", null);
+ String notification = createCriticalNotification("caption", "message",
+ "details", null);
assertThat(notification, containsString("\"url\":null"));
}