aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/test/java/com/juick/server/tests/RSSTests.java
diff options
context:
space:
mode:
Diffstat (limited to 'juick-server/src/test/java/com/juick/server/tests/RSSTests.java')
-rw-r--r--juick-server/src/test/java/com/juick/server/tests/RSSTests.java143
1 files changed, 0 insertions, 143 deletions
diff --git a/juick-server/src/test/java/com/juick/server/tests/RSSTests.java b/juick-server/src/test/java/com/juick/server/tests/RSSTests.java
deleted file mode 100644
index 6a19123b..00000000
--- a/juick-server/src/test/java/com/juick/server/tests/RSSTests.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2008-2017, Juick
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-package com.juick.server.tests;
-
-import com.juick.Message;
-import com.juick.Tag;
-import com.juick.User;
-import com.juick.configuration.RepositoryConfiguration;
-import com.juick.server.configuration.ApiAppConfiguration;
-import com.juick.server.configuration.ApiSecurityConfig;
-import com.juick.service.*;
-import org.apache.commons.text.RandomStringGenerator;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mockito;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Import;
-import org.springframework.context.annotation.Primary;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-import org.springframework.test.context.web.WebAppConfiguration;
-import org.springframework.test.web.servlet.MockMvc;
-import org.springframework.test.web.servlet.setup.MockMvcBuilders;
-import org.springframework.web.context.WebApplicationContext;
-
-import javax.inject.Inject;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import static org.mockito.Mockito.when;
-import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
-import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
-
-/**
- * Created by vitalyster on 13.12.2016.
- */
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {ApiAppConfiguration.class, ApiSecurityConfig.class, RepositoryConfiguration.class})
-@WebAppConfiguration
-public class RSSTests {
-
- private MockMvc mockMvc;
- @Inject
- private WebApplicationContext webApplicationContext;
-
- @Inject
- private MessagesService messagesService;
- @Inject
- private UserService userService;
- @Inject
- private TagService tagService;
-
- private User ugnich, freefd;
- String ugnichName, ugnichPassword, freefdName, freefdPassword;
-
- final static RandomStringGenerator generator = new RandomStringGenerator.Builder().withinRange('a', 'z').build();
-
- private static Message getMessage(final User user, final String messageText) {
- Message msg = new Message();
-
- msg.setMid(1);
- msg.setUser(user);
- msg.setText(messageText == null ? generator.generate(24) : messageText);
- msg.setTags(Collections.singletonList(new Tag(generator.generate(4))));
-
- return msg;
- }
-
- private static User getUser(final int uid, final String name, final String password) {
- User user = new User();
-
- user.setName(name);
- user.setUid(uid);
- user.setCredentials(password);
- user.setBanned(false);
-
- return user;
- }
-
- @Before
- public void setUp() {
- mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
- .dispatchOptions(true)
- .build();
- ugnichName = "ugnich";
- ugnichPassword = "MyPassw0rd!";
- freefdName = "freefd";
- freefdPassword = "MyPassw0rd!";
-
- ugnich = getUser(1, ugnichName, ugnichPassword);
- freefd = getUser(2, freefdName, freefdPassword);
-
- List<String> users = new ArrayList<>(2);
- users.add(ugnichName);
- users.add(freefdName);
-
- when(userService.getUsersByName(users))
- .thenReturn(Arrays.asList(ugnich, freefd));
- when(userService.getUserByName(ugnichName))
- .thenReturn(ugnich);
- when(userService.getFullyUserByName(ugnichName))
- .thenReturn(ugnich);
- when(userService.getUserByName(null))
- .thenReturn(new User());
- }
-
- @Test
- public void lastMessagesTest() throws Exception {
- String msgText = "Привет, я - Угнич";
-
- Message msg = getMessage(ugnich, msgText);
-
- when(messagesService.getMyFeed(1, 0, false))
- .thenReturn(Collections.singletonList(1));
- when(messagesService.getMessages(Collections.singletonList(1)))
- .thenReturn(Collections.singletonList(msg));
-
- mockMvc.perform(
- get("/rss/"))
- .andExpect(status().isOk())
- .andExpect(content().contentType("application/rss+xml"))
- .andExpect(xpath("/rss/channel/description").string("The latest messages at Juick"));
- }
-}