From 40b392f1d63f6aaa8794beaff4c0432dd29f1858 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 12 Jan 2018 11:34:43 +0300 Subject: refactoring and tests fixes --- .../src/test/java/com/juick/api/tests/MessagesTests.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'juick-api/src/test/java/com/juick/api/tests') 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 a270a120..fff7e02c 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 @@ -23,6 +23,7 @@ import com.juick.ExternalToken; import com.juick.Message; import com.juick.Tag; import com.juick.User; +import com.juick.api.EmailManager; import com.juick.api.configuration.ApiAppConfiguration; import com.juick.api.configuration.ApiSecurityConfig; import com.juick.configuration.RepositoryConfiguration; @@ -299,22 +300,17 @@ public class MessagesTests extends AbstractJUnit4SpringContextTests { IntStream.rangeClosed(6, 12).forEach(i -> { messagesService.createReply(topmid, 0, i, "yo", null); }); - mockMvc.perform(get("/messages/top_candidates").with(httpBasic(juickName, juickPassword)) - .contentType(MediaType.APPLICATION_JSON_UTF8)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$[0]", is(topmid))); + + assertThat(messagesService.getPopularCandidates().get(0), is(topmid)); Tag juickTag = tagService.getTag(juickTagId); assertThat(juickTag.TID, is(2)); tagService.updateTags(topmid, Collections.singletonList(juickTag)); - mockMvc.perform(get("/messages/top_candidates").with(httpBasic(juickName, juickPassword)) - .contentType(MediaType.APPLICATION_JSON_UTF8)) - .andExpect(status().isOk()) - .andExpect(jsonPath("$", hasSize(0))); + assertThat(messagesService.getPopularCandidates().isEmpty(), is(true)); } @Test public void inReplyToScannerTest() { String header = "<123456.56@juick.com>"; - Scanner headerScanner = new Scanner(header).useDelimiter("\\.|@|<"); + Scanner headerScanner = new Scanner(header).useDelimiter(EmailManager.MSGID_PATTERN); int mid = Integer.parseInt(headerScanner.next()); int rid = Integer.parseInt(headerScanner.next()); assertThat(mid, equalTo(123456)); -- cgit v1.2.3