-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
[Fix]: 챌린지 그룹 업데이트 코드 엔티티 책임으로 수정
- Loading branch information
Showing
5 changed files
with
117 additions
and
53 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
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
90 changes: 90 additions & 0 deletions
90
...erver/app/src/test/java/org/haedal/zzansuni/challengegroup/domain/ChallengeGroupTest.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,90 @@ | ||
package org.haedal.zzansuni.challengegroup.domain; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.time.LocalDate; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class ChallengeGroupTest { | ||
|
||
@Test | ||
@DisplayName("챌린지 그룹 업데이트가 정상적으로 동작한다.") | ||
void update() { | ||
// given | ||
// 챌린지 그룹1, 챌린지1,2,3 생성 | ||
List<Challenge> challenges = new ArrayList<>(); | ||
ChallengeGroup challengeGroup = ChallengeGroup.builder() | ||
.id(1L) | ||
.challenges(challenges) | ||
.build(); | ||
|
||
Challenge challenge1 = Challenge.builder() | ||
.id(1L) | ||
.challengeGroup(challengeGroup) | ||
.build(); | ||
|
||
Challenge challenge2 = Challenge.builder() | ||
.id(2L) | ||
.challengeGroup(challengeGroup) | ||
.build(); | ||
Challenge challenge3 = Challenge.builder() | ||
.id(3L) | ||
.challengeGroup(challengeGroup) | ||
.build(); | ||
|
||
challenges.add(challenge1); | ||
challenges.add(challenge2); | ||
challenges.add(challenge3); | ||
|
||
|
||
// 챌린지 update 1,2,3 생성 | ||
ChallengeGroupCommand.UpdateChallenge updateChallenge1 = ChallengeGroupCommand.UpdateChallenge.builder() | ||
.id(1L) | ||
.requiredCount(1) | ||
.onceExp(1) | ||
.successExp(1) | ||
.difficulty(1) | ||
.activePeriod(1) | ||
.build(); | ||
|
||
ChallengeGroupCommand.UpdateChallenge updateChallenge2 = ChallengeGroupCommand.UpdateChallenge.builder() | ||
.id(2L) | ||
.requiredCount(2) | ||
.onceExp(2) | ||
.successExp(2) | ||
.difficulty(2) | ||
.activePeriod(2) | ||
.build(); | ||
|
||
ChallengeGroupCommand.UpdateChallenge updateChallenge3 = ChallengeGroupCommand.UpdateChallenge.builder() | ||
.id(3L) | ||
.requiredCount(3) | ||
.onceExp(3) | ||
.successExp(3) | ||
.difficulty(3) | ||
.activePeriod(3) | ||
.build(); | ||
|
||
ChallengeGroupCommand.Update command = ChallengeGroupCommand.Update.builder() | ||
.id(1L) | ||
.title("title") | ||
.content("content") | ||
.guide("guide") | ||
.joinStartDate(LocalDate.now()) | ||
.joinEndDate(LocalDate.now().plusDays(1)) | ||
.category(ChallengeCategory.ETC) | ||
.createChallenges(List.of()) | ||
.updateChallenges(List.of(updateChallenge1, updateChallenge2, updateChallenge3)) | ||
.build(); | ||
|
||
// when | ||
challengeGroup.update(command); | ||
|
||
// then | ||
assertEquals(3, challengeGroup.getChallenges().size()); | ||
} | ||
} |