Skip to content

Commit

Permalink
[TEST] 응원톡 조회 시 order 필드 삭제 #119
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin409 committed Mar 2, 2024
1 parent 57a12b9 commit 206a637
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 44 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.sports.server.query.acceptance;

import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
import com.sports.server.command.cheertalk.application.CheerTalkService;
import com.sports.server.command.cheertalk.dto.CheerTalkRequest;
import com.sports.server.query.dto.response.CheerTalkResponse;
import com.sports.server.support.AcceptanceTest;
import java.lang.reflect.Type;
import java.util.concurrent.CompletableFuture;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -19,12 +24,6 @@
import org.springframework.web.socket.client.standard.StandardWebSocketClient;
import org.springframework.web.socket.messaging.WebSocketStompClient;

import java.lang.reflect.Type;
import java.util.concurrent.CompletableFuture;

import static java.util.concurrent.TimeUnit.SECONDS;
import static org.assertj.core.api.Assertions.assertThat;

@Sql(scripts = "/cheer-talk-fixture.sql")
class CheerTalkEventHandlerTest extends AcceptanceTest {

Expand Down Expand Up @@ -62,28 +61,6 @@ public void setup() {
assertThat(actual.content()).isEqualTo("응원톡입니다.");
}

@Test
void 응원톡의_응답_형태에_알맞은_order를_포함하고_있는지_확인한다() throws Exception {
//given
WebSocketStompClient stompClient = new WebSocketStompClient(new StandardWebSocketClient());
MappingJackson2MessageConverter messageConverter = new MappingJackson2MessageConverter();
ObjectMapper objectMapper = messageConverter.getObjectMapper();
objectMapper.registerModules(new JavaTimeModule(), new ParameterNamesModule());
stompClient.setMessageConverter(messageConverter);
StompSession stompSession = stompClient.connectAsync(URL, new StompSessionHandlerAdapter() {
})
.get(1, SECONDS);

stompSession.subscribe("/topic/games/1", new CommentStompFrameHandler());

//when
cheerTalkService.register(new CheerTalkRequest("응원톡입니다.", 2L));

//then
CheerTalkResponse actual = completableFuture.get(10, SECONDS);
assertThat(actual.order()).isEqualTo(2);
}

private class CommentStompFrameHandler implements StompFrameHandler {
@Override
public Type getPayloadType(StompHeaders stompHeaders) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
package com.sports.server.query.acceptance;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;

import com.sports.server.query.dto.response.CheerTalkResponse;
import com.sports.server.support.AcceptanceTest;
import io.restassured.RestAssured;
import io.restassured.response.ExtractableResponse;
import io.restassured.response.Response;
import java.time.LocalDateTime;
import java.util.List;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.springframework.http.MediaType;
import org.springframework.test.context.jdbc.Sql;

import java.time.LocalDateTime;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertAll;

@Sql(scripts = "/cheer-talk-fixture.sql")
class CheerTalkQueryAcceptanceTest extends AcceptanceTest {

Expand Down Expand Up @@ -47,7 +46,7 @@ class GetCommentsTest {
"응원톡5",
1L,
LocalDateTime.of(2023, 1, 2, 14, 55, 0),
false, 1
false
)),
() -> assertThat(actual)
.map(CheerTalkResponse::cheerTalkId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
package com.sports.server.query.application;

import com.sports.server.query.dto.response.CheerTalkResponse;
import com.sports.server.common.dto.PageRequestDto;
import com.sports.server.query.dto.response.CheerTalkResponse;
import com.sports.server.support.ServiceTest;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.jdbc.Sql;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Disabled;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.jdbc.Sql;

@Sql(scripts = "/cheer-talk-fixture.sql")
class CheerTalkQueryServiceTest extends ServiceTest {

@Autowired
private CheerTalkQueryService cheerTalkQueryService;

@Test
@Disabled
void 댓글_조회시_경기에_참여하는_팀의_아이디_순서대로_정수가_반환된다() {
//given
Long gameId = 1L;
Expand All @@ -34,7 +31,7 @@ class CheerTalkQueryServiceTest extends ServiceTest {
orderOfGameTeams.put(2L, 2);

for (CheerTalkResponse cheerTalkResponse : commentsByGameId) {
assertEquals((int) orderOfGameTeams.get(cheerTalkResponse.gameTeamId()), cheerTalkResponse.order());
// assertEquals((int) orderOfGameTeams.get(cheerTalkResponse.gameTeamId()), cheerTalkResponse.order());
}
}
}

0 comments on commit 206a637

Please sign in to comment.