From c82e8889e3b6a532dd82975d7c7c63690a58d0c6 Mon Sep 17 00:00:00 2001 From: Kim yeonsu Date: Thu, 28 Nov 2024 09:42:24 +0900 Subject: [PATCH] =?UTF-8?q?test:=20=EB=9D=BC=EB=B2=A8=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20isOwnedCountValid=20=EB=A9=94=EC=84=9C=EB=93=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bottler/label/domain/LabelTest.java | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/test/java/postman/bottler/label/domain/LabelTest.java b/src/test/java/postman/bottler/label/domain/LabelTest.java index 9a131437..3aefc077 100644 --- a/src/test/java/postman/bottler/label/domain/LabelTest.java +++ b/src/test/java/postman/bottler/label/domain/LabelTest.java @@ -6,7 +6,6 @@ import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; import postman.bottler.label.dto.response.LabelResponseDTO; -import postman.bottler.label.exception.FirstComeFirstServedLabelException; import postman.bottler.label.exception.InvalidLabelException; @SpringBootTest @@ -61,31 +60,32 @@ void createLabelWithAllParameters() { } @Test - @DisplayName("ownedCount가 limitCount를 초과하지 않는 경우 라벨 생성이 성공한다.") - void createLabelSuccessfullyWhenOwnedCountIsValid() { + @DisplayName("ownedCount가 limitCount를 초과하지 않는 경우 isOwnedCountValid 메서드는 true를 반환한다.") + void isOwnedCountValidReturnsTrue() { // given - Long labelId = 1L; - String imageUrl = "http://example.com/image3.png"; - int limitCount = 10; - int ownedCount = 5; + Label label = Label.createLabel("http://example.com/image3.png", 10); + label.increaseOwnedCount(); - // when, then - assertDoesNotThrow(() -> Label.createLabel(labelId, imageUrl, limitCount, ownedCount)); + // when + boolean result = label.isOwnedCountValid(); + + // then + assertTrue(result, "소유 인원수가 제한 인원수를 초과하지 않았을 때 true를 반환해야 함"); } @Test - @DisplayName("ownedCount가 limitCount를 초과하는 경우 예외가 발생한다.") - void createLabelThrowsExceptionWhenOwnedCountExceedsLimit() { + @DisplayName("ownedCount가 limitCount를 초과한 경우 isOwnedCountValid 메서드는 false를 반환한다.") + void isOwnedCountValidReturnsFalse() { // given - Long labelId = 1L; - String imageUrl = "http://example.com/image3.png"; - int limitCount = 5; - int ownedCount = 6; + Label label = Label.createLabel("http://example.com/image4.png", 1); + label.increaseOwnedCount(); + label.increaseOwnedCount(); - // when, then - assertThrows(FirstComeFirstServedLabelException.class, - () -> Label.createLabel(labelId, imageUrl, limitCount, ownedCount), - "소유 인원수가 제한 인원수를 초과했을 때 예외가 발생해야 함"); + // when + boolean result = label.isOwnedCountValid(); + + // then + assertFalse(result, "소유 인원수가 제한 인원수에 도달했을 때 false를 반환해야 함"); } @Test @@ -114,4 +114,4 @@ void createLabelWithNegativeLimitCountThrowsException() { Label.createLabel(imageUrl, invalidLimitCount); }, "limitCount가 음수일 경우 예외가 발생해야 함"); } -} +} \ No newline at end of file