Skip to content

Commit

Permalink
test(BaseballTeam): 구단 생성 테스트 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
EunjiShin committed Jul 14, 2024
1 parent a91a4a8 commit 266e42e
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
import org.depromeet.spot.usecase.port.out.team.BaseballTeamRepository;
import org.springframework.stereotype.Service;

import lombok.Builder;
import lombok.RequiredArgsConstructor;

@Service
@Builder
@RequiredArgsConstructor
public class CreateBaseballTeamService implements CreateBaseballTeamUsecase {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package org.depromeet.spot.usecase.service.team;

import static org.assertj.core.api.Assertions.assertThatThrownBy;

import java.util.List;

import org.depromeet.spot.common.exception.team.TeamException.DuplicateTeamNameException;
import org.depromeet.spot.domain.common.RgbCode;
import org.depromeet.spot.domain.team.BaseballTeam;
import org.depromeet.spot.usecase.service.fake.FakeBaseballTeamRepository;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class CreateBaseballTeamServiceTest {

private CreateBaseballTeamService createBaseballTeamService;

@BeforeEach
void init() {
FakeBaseballTeamRepository fakeBaseballTeamRepository = new FakeBaseballTeamRepository();
this.createBaseballTeamService =
CreateBaseballTeamService.builder()
.baseballTeamRepository(fakeBaseballTeamRepository)
.build();

BaseballTeam team =
BaseballTeam.builder()
.id(1L)
.name("두산 베어스")
.alias("두산")
.logo("logo1.png")
.labelRgbCode(new RgbCode(0, 0, 0))
.build();
fakeBaseballTeamRepository.save(team);
}

@Test
void 이미_존재하는_이름의_구단을_중복_저장할__없다() {
// given
BaseballTeam team =
BaseballTeam.builder()
.id(1L)
.name("두산 베어스")
.alias("두산")
.logo("logo1.png")
.labelRgbCode(new RgbCode(0, 0, 0))
.build();
List<BaseballTeam> teams = List.of(team);

// when
// then
assertThatThrownBy(() -> createBaseballTeamService.saveAll(teams))
.isInstanceOf(DuplicateTeamNameException.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class BaseballTeamReadServiceTest {
class ReadBaseballTeamServiceTest {

private ReadBaseballTeamService baseballTeamReadService;

Expand Down

0 comments on commit 266e42e

Please sign in to comment.