Skip to content

Commit

Permalink
[BE] FIX: user blackhole same 로직 null 경우 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
enaenen committed Aug 10, 2024
1 parent 0593339 commit 6541292
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
11 changes: 11 additions & 0 deletions backend/src/main/java/org/ftclub/cabinet/user/domain/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,21 @@ public boolean isBlackholed() {
return blackholedAt != null && blackholedAt.isBefore(LocalDateTime.now());
}

/**
* this.blackholedAt과 전달인자 blackholedAt 중 어느 하나가 null인 경우 false를 반환
*
* @param blackholedAt
* @return
*/
public boolean isSameBlackholedAt(LocalDateTime blackholedAt) {
if (this.blackholedAt == null || blackholedAt == null) {
return this.blackholedAt == null && blackholedAt == null;
}

return this.blackholedAt.isEqual(blackholedAt);
}


public void addCoin(Long reward) {
this.coin += reward;
}
Expand Down
25 changes: 25 additions & 0 deletions backend/src/test/java/org/ftclub/cabinet/user/domain/UserTest.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
package org.ftclub.cabinet.user.domain;

import java.time.LocalDateTime;
import lombok.RequiredArgsConstructor;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

@RequiredArgsConstructor
public class UserTest {

@Test
void isSameBlackholedAt_test_both_null() {
User test = User.of("test", "[email protected]", null);
boolean sameBlackholedAt = test.isSameBlackholedAt(null);
Assertions.assertTrue(sameBlackholedAt);
}

@Test
void isSameBlackholedAt_test_one_null() {
User test = User.of("test", "[email protected]", null);
boolean sameBlackholedAt = test.isSameBlackholedAt(LocalDateTime.now());
Assertions.assertFalse(sameBlackholedAt);
}

@Test
void isSameBlackholedAt_test_same() {
LocalDateTime now = LocalDateTime.now();
User test = User.of("test", "[email protected]", now);
boolean sameBlackholedAt = test.isSameBlackholedAt(now);
Assertions.assertTrue(sameBlackholedAt);
}

// @Test
// @DisplayName("유저 생성 성공 - 일반적인 이메일 형식")
// void of_성공_일반적인_이메일_형식() {
Expand Down

0 comments on commit 6541292

Please sign in to comment.