-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Api-v0.2.3-5
- Loading branch information
Showing
20 changed files
with
214 additions
and
22 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
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
14 changes: 14 additions & 0 deletions
14
...a/band/gosrock/domain/domains/order/exception/CanNotApproveDeletedUserOrderException.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,14 @@ | ||
package band.gosrock.domain.domains.order.exception; | ||
|
||
|
||
import band.gosrock.common.exception.DuDoongCodeException; | ||
|
||
public class CanNotApproveDeletedUserOrderException extends DuDoongCodeException { | ||
|
||
public static final DuDoongCodeException EXCEPTION = | ||
new CanNotApproveDeletedUserOrderException(); | ||
|
||
private CanNotApproveDeletedUserOrderException() { | ||
super(OrderErrorCode.CAN_NOT_DELETED_USER_APPROVE); | ||
} | ||
} |
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
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
13 changes: 13 additions & 0 deletions
13
...n/java/band/gosrock/domain/domains/ticket_item/exception/InvalidOptionPriceException.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,13 @@ | ||
package band.gosrock.domain.domains.ticket_item.exception; | ||
|
||
|
||
import band.gosrock.common.exception.DuDoongCodeException; | ||
|
||
public class InvalidOptionPriceException extends DuDoongCodeException { | ||
|
||
public static final DuDoongCodeException EXCEPTION = new InvalidOptionPriceException(); | ||
|
||
private InvalidOptionPriceException() { | ||
super(TicketItemErrorCode.INVALID_OPTION_PRICE); | ||
} | ||
} |
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
59 changes: 59 additions & 0 deletions
59
...test/java/band/gosrock/domain/domains/host/service/HostServiceConcurrencyFailureTest.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,59 @@ | ||
package band.gosrock.domain.domains.host.service; | ||
|
||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.BDDMockito.given; | ||
|
||
import band.gosrock.domain.CunCurrencyExecutorService; | ||
import band.gosrock.domain.DisableDomainEvent; | ||
import band.gosrock.domain.DisableRedissonLock; | ||
import band.gosrock.domain.DomainIntegrateSpringBootTest; | ||
import band.gosrock.domain.domains.host.domain.Host; | ||
import band.gosrock.domain.domains.host.domain.HostUser; | ||
import band.gosrock.domain.domains.host.repository.HostRepository; | ||
import java.util.concurrent.atomic.AtomicLong; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mock; | ||
import org.redisson.api.RedissonClient; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
import org.springframework.test.util.ReflectionTestUtils; | ||
|
||
@DomainIntegrateSpringBootTest | ||
@DisableDomainEvent | ||
@DisableRedissonLock | ||
@Slf4j | ||
public class HostServiceConcurrencyFailureTest { | ||
@Autowired HostService hostService; | ||
|
||
@Autowired RedissonClient redissonClient; | ||
|
||
Host host; | ||
|
||
@Mock HostUser hostUser; | ||
@MockBean HostRepository hostRepository; | ||
|
||
@BeforeEach | ||
void setup() { | ||
host = Host.builder().build(); | ||
ReflectionTestUtils.setField(host, "id", 1L); | ||
given(hostUser.getUserId()).willReturn(9L); | ||
given(hostRepository.save(any(Host.class))).willReturn(host); | ||
} | ||
|
||
@Test | ||
@DisplayName("락 적용을 안하면 여러개의 초대가 승인될 수도 있다.") | ||
public void 호스트유저_초대요청_동시성_실패() throws InterruptedException { | ||
// given | ||
// when | ||
AtomicLong successCount = new AtomicLong(); | ||
CunCurrencyExecutorService.execute( | ||
() -> hostService.inviteHostUser(host, hostUser), successCount); | ||
// then | ||
log.info(String.valueOf(successCount.get())); | ||
assertThat(successCount.get()).isGreaterThanOrEqualTo(1L); | ||
} | ||
} |
Oops, something went wrong.