Skip to content

Commit

Permalink
refactor: 쿠폰 대기열 크기 조회 기능 삭제
Browse files Browse the repository at this point in the history
  • Loading branch information
hongdosan committed Nov 28, 2023
1 parent 112498c commit 1a581e4
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ public Set<Long> range(String couponName, long start, long end) {
.collect(Collectors.toSet());
}

public Long queueSize(String couponName) {
return zSetRedisRepository.size(requireNonNull(couponName));
}

public void deleteQueue(String couponName) {
valueRedisRepository.delete(requireNonNull(couponName));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,4 @@ public Set<Object> range(String key, long start, long end) {
.opsForZSet()
.range(key, start, end);
}

public Long size(String key) {
return redisTemplate.opsForZSet().size(key);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void init_success() {
assertThatNoException().isThrownBy(() -> couponManageService.init());
}

@DisplayName("10명ㅗ두 쿠폰 발행이 성공적으로 된다.")
@DisplayName("10명의 사용자가 쿠폰 발행을 성공적으로 .")
@MethodSource("com.moabam.support.fixture.CouponFixture#provideValues_Long")
@ParameterizedTest
void issue_all_success(Set<Long> values) {
Expand All @@ -76,7 +76,6 @@ void issue_all_success(Set<Long> values) {
couponManageService.issue();

// Then
verify(couponManageRepository).queueSize(any(String.class));
verify(couponWalletRepository, times(10)).save(any(CouponWallet.class));
verify(notificationService, times(10))
.sendCouponIssueResult(any(Long.class), any(String.class), any(String.class));
Expand All @@ -95,7 +94,6 @@ void issue_notStartAt() {
// Then
verify(couponManageRepository, times(0)).increaseIssuedStock(any(String.class));
verify(couponWalletRepository, times(0)).save(any(CouponWallet.class));
verify(couponManageRepository, times(0)).queueSize(any(String.class));
verify(couponManageRepository, times(0))
.range(any(String.class), any(long.class), any(long.class));
verify(notificationService, times(0))
Expand All @@ -118,7 +116,6 @@ void issue_stockEnd(Set<Long> values) {
couponManageService.issue();

// Then
verify(couponManageRepository).queueSize(any(String.class));
verify(couponManageRepository, times(10)).increaseIssuedStock(any(String.class));
verify(couponWalletRepository, times(0)).save(any(CouponWallet.class));
verify(notificationService, times(10))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,27 +78,6 @@ void range_NullPointerException() {
.isInstanceOf(NullPointerException.class);
}

@DisplayName("대기열의 사이즈를 성공적으로 반환한다. - Long")
@Test
void queueSize_success() {
// Given
given(zSetRedisRepository.size(any(String.class))).willReturn(2L);

// When
Long actual = couponManageRepository.queueSize("CouponName");

// Then
assertThat(actual).isEqualTo(2L);
}

@DisplayName("쿠폰명이 Null인 대기열의 사이즈를 반환한다. - NullPointerException")
@Test
void queueSize_NullPointerException() {
// When & Then
assertThatThrownBy(() -> couponManageRepository.queueSize(null))
.isInstanceOf(NullPointerException.class);
}

@DisplayName("쿠폰 대기열을 성공적으로 삭제한다. - Void")
@Test
void deleteQueue_success() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,4 @@ void range_less_success() {
// Then
assertThat(actual).hasSize(3);
}

@DisplayName("저장된 데이터 갯수를 조회한다. - Long")
@Test
void size_success() {
// Given
zSetRedisRepository.addIfAbsent(key, value + 1, 1, expireDays);
zSetRedisRepository.addIfAbsent(key, value + 2, 2, expireDays);

// When
Long actual = zSetRedisRepository.size(key);

// Then
assertThat(actual).isEqualTo(2);
}
}

0 comments on commit 1a581e4

Please sign in to comment.