-
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.
- Loading branch information
Showing
3 changed files
with
58 additions
and
1 deletion.
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
55 changes: 55 additions & 0 deletions
55
.../src/test/java/org/depromeet/spot/usecase/service/team/CreateBaseballTeamServiceTest.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,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); | ||
} | ||
} |
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