aboutsummaryrefslogtreecommitdiff
path: root/juick-api/src/test/java/com/juick/api
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2017-11-01 12:55:21 +0300
committerGravatar Vitaly Takmazov2017-11-01 12:55:21 +0300
commite2c2cf416db9637ebd41c489cf5a533824d17d4c (patch)
tree6f421d432b54a1a694af946438a5e6e4c1c53af5 /juick-api/src/test/java/com/juick/api
parent0dcabe039a51a3a1aebd9a656a8dde2895b5e03a (diff)
notifications: fix tokens deletion
Diffstat (limited to 'juick-api/src/test/java/com/juick/api')
-rw-r--r--juick-api/src/test/java/com/juick/api/tests/MessagesTests.java23
1 files changed, 17 insertions, 6 deletions
diff --git a/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java b/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java
index 63fac6a1..13d399ca 100644
--- a/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java
+++ b/juick-api/src/test/java/com/juick/api/tests/MessagesTests.java
@@ -81,8 +81,8 @@ public class MessagesTests extends AbstractJUnit4SpringContextTests {
@Inject
private ImagesService imagesService;
- private static User ugnich, freefd;
- static String ugnichName, ugnichPassword, freefdName, freefdPassword;
+ private static User ugnich, freefd, juick;
+ static String ugnichName, ugnichPassword, freefdName, freefdPassword, juickName, juickPassword;
static Message msg;
private static boolean isSetUp = false;
@@ -99,11 +99,15 @@ public class MessagesTests extends AbstractJUnit4SpringContextTests {
ugnichPassword = "MyPassw0rd!";
freefdName = "freefd";
freefdPassword = "MyPassw0rd!";
-
+ juickName = "juick";
+ juickPassword = "demo";
int ugnichId = userService.createUser(ugnichName, ugnichPassword);
ugnich = userService.getUserByUID(ugnichId).orElseThrow(IllegalStateException::new);
int freefdId = userService.createUser(freefdName, freefdPassword);
freefd = userService.getUserByUID(freefdId).orElseThrow(IllegalStateException::new);
+ int juickId = userService.createUser(juickName, juickPassword);
+ juick = userService.getUserByUID(juickId).orElseThrow(IllegalStateException::new);
+
String msgText = "Привет, я - Угнич";
int mid = messagesService.createMessage(ugnich.getUid(), msgText, "png", null);
@@ -245,9 +249,6 @@ public class MessagesTests extends AbstractJUnit4SpringContextTests {
}
@Test
public void registerForNotificationsTests() throws Exception {
- String juickName = "juick";
- String juickPassword = "demo";
- int juickId = userService.createUser(juickName, juickPassword);
String token = "123456";
ExternalToken registration = new ExternalToken(null, "apns", token, null);
mockMvc.perform(put("/notifications").with(httpBasic(ugnichName, ugnichPassword))
@@ -270,4 +271,14 @@ public class MessagesTests extends AbstractJUnit4SpringContextTests {
assertThat(uriComponents.getPath().substring(1), is("123456"));
assertThat(uriComponents.getFragment(), is("23"));
}
+ @Test
+ public void notificationsTokensTest() throws Exception {
+ List<ExternalToken> tokens = Collections.singletonList(new ExternalToken(null, "gcm", "123456", null));
+ mockMvc.perform(delete("/notifications").with(httpBasic(ugnichName, ugnichPassword))
+ .contentType(MediaType.APPLICATION_JSON_UTF8)
+ .content(jsonMapper.writeValueAsBytes(tokens))).andExpect(status().isForbidden());
+ mockMvc.perform(delete("/notifications").with(httpBasic(juickName, juickPassword))
+ .contentType(MediaType.APPLICATION_JSON_UTF8)
+ .content(jsonMapper.writeValueAsBytes(tokens))).andExpect(status().isOk());
+ }
}