-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: User도메인에 친구 필드와 친구 추가 메소드를 구현한다 * fix: ddl에 빠진 필드를 추가하고, UserFixture에 friends 를 기본삽입한다 * feat: 친구 맺기 API를 개발한다 * refactor: 유저 수정 API에서 LoginContext를 사용하도록 수정한다 * test: 도메인별로 흩어져있는 통합테스트를 하나로 합친다
- Loading branch information
Showing
22 changed files
with
324 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package net.teumteum.core.context; | ||
|
||
public interface LoginContext { | ||
|
||
void setUserId(Long userId); | ||
|
||
Long getUserId(); | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/net/teumteum/core/context/LoginContextImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package net.teumteum.core.context; | ||
|
||
import org.springframework.context.annotation.Profile; | ||
import org.springframework.context.annotation.ScopedProxyMode; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.context.annotation.RequestScope; | ||
|
||
@Component | ||
@Profile("prod") | ||
@RequestScope(proxyMode = ScopedProxyMode.INTERFACES) | ||
public class LoginContextImpl implements LoginContext { | ||
|
||
private Long userId; | ||
|
||
@Override | ||
public void setUserId(Long userId) { | ||
this.userId = userId; | ||
} | ||
|
||
@Override | ||
public Long getUserId() { | ||
return userId; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
spring.profiles.active=prod | ||
|
||
### SERVER CONFIG ### | ||
server.port=8080 | ||
server.name=teum-teum-server | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
create table if not exists users_friends( | ||
users_id bigint not null, | ||
friends bigint not null, | ||
foreign key (users_id) references users(id) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package net.teumteum.integration; | ||
|
||
import net.teumteum.meeting.config.PageableHandlerMethodArgumentResolver; | ||
import net.teumteum.meeting.domain.Topic; | ||
import net.teumteum.user.domain.request.UserUpdateRequest; | ||
import org.springframework.boot.test.context.TestComponent; | ||
import org.springframework.context.ApplicationContext; | ||
import org.springframework.data.domain.Pageable; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.test.web.reactive.server.WebTestClient; | ||
import org.springframework.test.web.reactive.server.WebTestClient.ResponseSpec; | ||
|
||
@TestComponent | ||
class Api { | ||
|
||
private final WebTestClient webTestClient; | ||
|
||
public Api(ApplicationContext applicationContext) { | ||
var controllers = applicationContext.getBeansWithAnnotation(Controller.class).values(); | ||
webTestClient = WebTestClient.bindToController(controllers.toArray()) | ||
.argumentResolvers(resolvers -> resolvers.addCustomResolver(new PageableHandlerMethodArgumentResolver())) | ||
.build(); | ||
} | ||
|
||
ResponseSpec getUser(String token, Long userId) { | ||
return webTestClient.get() | ||
.uri("/users/" + userId) | ||
.header(HttpHeaders.AUTHORIZATION, token) | ||
.exchange(); | ||
} | ||
|
||
ResponseSpec getUsersById(String token, String userIds) { | ||
return webTestClient.get() | ||
.uri("/users?id=" + userIds) | ||
.header(HttpHeaders.AUTHORIZATION, token) | ||
.exchange(); | ||
} | ||
|
||
ResponseSpec updateUser(String token, UserUpdateRequest userUpdateRequest) { | ||
return webTestClient.put() | ||
.uri("/users") | ||
.header(HttpHeaders.AUTHORIZATION, token) | ||
.bodyValue(userUpdateRequest) | ||
.exchange(); | ||
} | ||
|
||
ResponseSpec addFriends(String token, Long friendId) { | ||
return webTestClient.post() | ||
.uri("/users/" + friendId + "/friends") | ||
.header(HttpHeaders.AUTHORIZATION, token) | ||
.exchange(); | ||
} | ||
|
||
ResponseSpec getOpenMeetings(String token, Long cursorId, int size) { | ||
return webTestClient.get() | ||
.uri("/meetings" + | ||
"?cursorId=" + cursorId + | ||
"&size=" + size) | ||
.header(HttpHeaders.AUTHORIZATION, token) | ||
.exchange(); | ||
} | ||
|
||
ResponseSpec getMeetingById(String token, Long meetingId) { | ||
return webTestClient.get() | ||
.uri("/meetings/" + meetingId) | ||
.header(HttpHeaders.AUTHORIZATION, token) | ||
.exchange(); | ||
} | ||
|
||
ResponseSpec getMeetingsByTopic(String token, Pageable pageable, boolean isOpen, Topic topic) { | ||
String sort = pageable.getSort().toString().replace(": ", ","); | ||
String uri = "/meetings?sort=" + sort + | ||
"&page=" + pageable.getOffset() + | ||
"&size=" + pageable.getPageSize() + | ||
"&isOpen=" + isOpen + | ||
"&topic=" + topic; | ||
|
||
return webTestClient.get() | ||
.uri(uri) | ||
.header(HttpHeaders.AUTHORIZATION, token) | ||
.exchange(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.