-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
9872f96
commit 8f54279
Showing
3 changed files
with
118 additions
and
11 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
54 changes: 54 additions & 0 deletions
54
backend/src/test/java/com/festago/fcm/domain/MemberFCMTest.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,54 @@ | ||
package com.festago.fcm.domain; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
import com.festago.common.exception.ValidException; | ||
import org.junit.jupiter.api.DisplayNameGeneration; | ||
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.params.ParameterizedTest; | ||
import org.junit.jupiter.params.provider.NullSource; | ||
import org.junit.jupiter.params.provider.ValueSource; | ||
|
||
@DisplayNameGeneration(ReplaceUnderscores.class) | ||
@SuppressWarnings("NonAsciiCharacters") | ||
class MemberFCMTest { | ||
|
||
@Test | ||
void MemberFCM_생성_성공() { | ||
// given | ||
MemberFCM memberFCM = new MemberFCM(1L, "token"); | ||
|
||
// when & then | ||
assertThat(memberFCM.getMemberId()).isEqualTo(1L); | ||
assertThat(memberFCM.getFcmToken()).isEqualTo("token"); | ||
} | ||
|
||
@ParameterizedTest | ||
@NullSource | ||
void memberId가_null이면_예외(Long memberId) { | ||
// when & then | ||
assertThatThrownBy(() -> new MemberFCM(memberId, "token")) | ||
.isInstanceOf(ValidException.class); | ||
} | ||
|
||
@ParameterizedTest | ||
@NullSource | ||
@ValueSource(strings = {"", " ", "\t", "\n"}) | ||
void token이_null_또는_공백이면_예외(String token) { | ||
// when & then | ||
assertThatThrownBy(() -> new MemberFCM(1L, token)) | ||
.isInstanceOf(ValidException.class); | ||
} | ||
|
||
@Test | ||
void token의_길이가_255자를_초과하면_예외() { | ||
// given | ||
String token = "1".repeat(256); | ||
|
||
// when & then | ||
assertThatThrownBy(() -> new MemberFCM(1L, token)) | ||
.isInstanceOf(ValidException.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