refactoring
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
package io.spring.api;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
public abstract class ApiTestBase {
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
}
|
||||
@@ -89,7 +89,6 @@ public class ArticleApiTest extends TestWithCurrentUser {
|
||||
|
||||
Article article = new Article(title, description, body, new String[]{"java", "spring", "jpg"}, user.getId());
|
||||
|
||||
DateTime time = new DateTime();
|
||||
ArticleData articleData = TestHelper.getArticleDataFromArticleAndUser(article, user);
|
||||
|
||||
when(articleRepository.findBySlug(eq(article.getSlug()))).thenReturn(Optional.of(article));
|
||||
@@ -168,7 +167,6 @@ public class ArticleApiTest extends TestWithCurrentUser {
|
||||
String title = "new-title";
|
||||
String body = "new body";
|
||||
String description = "new description";
|
||||
Map<String, Object> updateParam = prepareUpdateParam(title, body, description);
|
||||
|
||||
User anotherUser = new User("test@test.com", "test", "123123", "", "");
|
||||
|
||||
|
||||
@@ -46,13 +46,12 @@ public class ArticleFavoriteApiTest extends TestWithCurrentUser {
|
||||
private ArticleQueryService articleQueryService;
|
||||
|
||||
private Article article;
|
||||
private User anotherUser;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
RestAssuredMockMvc.mockMvc(mvc);
|
||||
anotherUser = new User("other@test.com", "other", "123", "", "");
|
||||
User anotherUser = new User("other@test.com", "other", "123", "", "");
|
||||
article = new Article("title", "desc", "body", new String[]{"java"}, anotherUser.getId());
|
||||
when(articleRepository.findBySlug(eq(article.getSlug()))).thenReturn(Optional.of(article));
|
||||
ArticleData articleData = new ArticleData(
|
||||
|
||||
@@ -5,7 +5,6 @@ import io.spring.JacksonCustomizations;
|
||||
import io.spring.api.security.WebSecurityConfig;
|
||||
import io.spring.application.ProfileQueryService;
|
||||
import io.spring.application.data.ProfileData;
|
||||
import io.spring.core.article.Article;
|
||||
import io.spring.core.user.FollowRelation;
|
||||
import io.spring.core.user.User;
|
||||
import org.junit.Before;
|
||||
@@ -27,7 +26,6 @@ import static org.mockito.Mockito.when;
|
||||
@WebMvcTest(ProfileApi.class)
|
||||
@Import({WebSecurityConfig.class, JacksonCustomizations.class})
|
||||
public class ProfileApiTest extends TestWithCurrentUser {
|
||||
private Article article;
|
||||
private User anotherUser;
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -13,7 +13,7 @@ import java.util.Optional;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
abstract class TestWithCurrentUser extends ApiTestBase {
|
||||
abstract class TestWithCurrentUser {
|
||||
@MockBean
|
||||
protected UserRepository userRepository;
|
||||
|
||||
@@ -46,10 +46,8 @@ abstract class TestWithCurrentUser extends ApiTestBase {
|
||||
when(jwtService.getSubFromToken(eq(token))).thenReturn(Optional.of(user.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
userFixture();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ import static org.mockito.Mockito.when;
|
||||
|
||||
@WebMvcTest(UsersApi.class)
|
||||
@Import({WebSecurityConfig.class, UserQueryService.class, NaiveEncryptService.class, JacksonCustomizations.class})
|
||||
public class UsersApiTest extends ApiTestBase {
|
||||
public class UsersApiTest {
|
||||
@Autowired
|
||||
private MockMvc mvc;
|
||||
|
||||
|
||||
@@ -31,13 +31,12 @@ public class MyBatisArticleRepositoryTest {
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
private User user;
|
||||
private Article article;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
user = new User("aisensiy@gmail.com", "aisensiy", "123", "bio", "default");
|
||||
User user = new User("aisensiy@gmail.com", "aisensiy", "123", "bio", "default");
|
||||
userRepository.save(user);
|
||||
article = new Article("test", "desc", "body", new String[]{"java", "spring"}, user.getId());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user