From 41e0cddba4828216297e764c630037534f610e41 Mon Sep 17 00:00:00 2001 From: whereami2048 Date: Thu, 23 May 2024 15:12:19 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=EA=B2=BD=ED=97=98=20=EB=93=B1?= =?UTF-8?q?=EB=A1=9D=20=EC=8B=9C=20=EB=82=A0=EC=A7=9C=20=EC=9E=85=EB=A0=A5?= =?UTF-8?q?=20=EC=98=88=EC=99=B8=20=EC=B2=98=EB=A6=AC(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domainmodule/domain/experience/aggregate/Experience.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/Experience.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/Experience.kt index 641a0c16..3453877b 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/Experience.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/Experience.kt @@ -44,6 +44,7 @@ data class Experience( init { require(title.length < 50) { "제목의 글자 수는 50자 제한입니다." } + require(startedAt.isBefore(endedAt)) { "활동 시작일은 종료일보다 빨라야 합니다."} } companion object { fun create( From d93e03424040965fb7c081735104da40c83eced2 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Thu, 23 May 2024 15:20:40 +0900 Subject: [PATCH 2/6] =?UTF-8?q?test:=20=EA=B2=BD=ED=97=98=20=EB=82=A0?= =?UTF-8?q?=EC=A7=9C=20=EC=98=88=EC=99=B8=20=EC=B2=98=EB=A6=AC=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20=EB=A1=9C=EC=A7=81=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/experience/aggregate/Experience.kt | 1 + .../experience/aggregate/ExperienceTest.kt | 33 ++++++++++++++++--- .../aggregate/JobDescriptionTest.kt | 8 ++--- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/Experience.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/Experience.kt index 3453877b..14421766 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/Experience.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/Experience.kt @@ -46,6 +46,7 @@ data class Experience( require(title.length < 50) { "제목의 글자 수는 50자 제한입니다." } require(startedAt.isBefore(endedAt)) { "활동 시작일은 종료일보다 빨라야 합니다."} } + companion object { fun create( title: String, diff --git a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/ExperienceTest.kt b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/ExperienceTest.kt index 39111492..fd3f956b 100644 --- a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/ExperienceTest.kt +++ b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/ExperienceTest.kt @@ -1,6 +1,5 @@ package com.bamyanggang.domainmodule.domain.experience.aggregate -import com.bamyanggang.commonmodule.fixture.generateBasicTypeFixture import com.bamyanggang.commonmodule.fixture.generateFixture import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.style.FunSpec @@ -9,10 +8,11 @@ import java.time.LocalDateTime import java.util.* class ExperienceTest : FunSpec({ + test("Experience 정상 생성 테스트"){ - val title: String = generateBasicTypeFixture(15) - val parentTagId: UUID = generateFixture() - val childTagId: UUID = generateFixture() + val title = "경험 제목" + val parentTagId: UUID = UUID.randomUUID() + val childTagId: UUID = UUID.randomUUID() val contents: List = generateFixture() val experienceStrongPoints: List = generateFixture() val startedAt: LocalDateTime = generateFixture() @@ -56,4 +56,29 @@ class ExperienceTest : FunSpec({ ) } } + + test("날짜 입력 예외 처리 테스트") { + val title = "경험 제목" + val parentTagId: UUID = UUID.randomUUID() + val childTagId: UUID = UUID.randomUUID() + val contents: List = generateFixture() + val experienceStrongPoints: List = generateFixture() + val userId : UUID = generateFixture() + + val startedAt = LocalDateTime.now() + val endedAt = startedAt.minusDays(1) + + shouldThrow { + Experience.create( + title = title, + userId = userId, + parentTagId = parentTagId, + childTagId = childTagId, + contents = contents, + experienceStrongPoints = experienceStrongPoints, + startedAt = startedAt, + endedAt = endedAt, + ) + } + } }) diff --git a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/aggregate/JobDescriptionTest.kt b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/aggregate/JobDescriptionTest.kt index 80642807..81a4b230 100644 --- a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/aggregate/JobDescriptionTest.kt +++ b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/aggregate/JobDescriptionTest.kt @@ -13,10 +13,10 @@ class JobDescriptionTest : FunSpec({ test("JobDescription 생성") { // arrange - val enterpriseName: String = "기업 명" - val title: String = "제목" - val content: String = "내용" - val link: String = "링크" + val enterpriseName = "기업 명" + val title = "제목" + val content = "내용" + val link = "링크" val startedAt: LocalDateTime = LocalDateTime.now() val endedAt: LocalDateTime = startedAt.plusDays(1) val userId : UUID = UUID.randomUUID() From 8eed536c3da4fafcd5178ad816e38b257b513b4d Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Thu, 23 May 2024 15:35:56 +0900 Subject: [PATCH 3/6] =?UTF-8?q?refactor:=20=EA=B2=BD=ED=97=98=20=EB=82=B4?= =?UTF-8?q?=EC=9A=A9=20toDomain=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/experience/aggregate/ExperienceContent.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/ExperienceContent.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/ExperienceContent.kt index ea87e745..555970a5 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/ExperienceContent.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/ExperienceContent.kt @@ -10,13 +10,10 @@ data class ExperienceContent( val answer: String, ) : DomainEntity { + companion object { fun create(question: String, answer: String): ExperienceContent { return ExperienceContent(question = question, answer = answer) } - - fun toDomain(id: UUID, question: String, answer: String): ExperienceContent { - return ExperienceContent(id, question, answer) - } } } From 662b0f9c0415b76b03c938787321ec987db5a673 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Thu, 23 May 2024 15:36:08 +0900 Subject: [PATCH 4/6] =?UTF-8?q?refactor:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EB=A9=94=EC=86=8C=EB=93=9C=20=EC=82=AD=EC=A0=9C(#1?= =?UTF-8?q?59)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../experience/repository/ExperienceRepository.kt | 1 - .../domain/experience/service/ExperienceReader.kt | 4 ---- .../experience/ExperienceRepositoryImpl.java | 11 ----------- 3 files changed, 16 deletions(-) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt index 549f5cde..371dd1dd 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/repository/ExperienceRepository.kt @@ -14,7 +14,6 @@ interface ExperienceRepository { fun findByIds(experienceIds: List): List fun findByUserIdAndTitleContains(userId: UUID, search: String): List fun findByUserIdAndParentTagId(userId: UUID, parentTagId: UUID): List - fun findByUserIdAndParentTagIdAndYearDesc(year: Int, parentTagId: UUID, userId: UUID): List fun findByYear(year: Int): List fun findByChildTagId(childTag: UUID) : List fun findByTagIds(tagIds: List) : List diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt index 4c52c70f..f48b427e 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/experience/service/ExperienceReader.kt @@ -36,10 +36,6 @@ class ExperienceReader( return experienceRepository.findByUserIdAndParentTagId(userId, parentTagId) } - fun readByUserIdAndParentTagIdAndYearDesc(year: Int, parentTagId: UUID, userId: UUID): List { - return experienceRepository.findByUserIdAndParentTagIdAndYearDesc(year, parentTagId, userId) - } - fun readByChildTagIdAndYear(year: Int, childTagId: UUID): List { return experienceRepository.findByYearAndChildTagId(year, childTagId) } diff --git a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java index 3d8991c1..d239c46d 100644 --- a/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java +++ b/Infrastructure-Module/persistence/src/main/java/com/bamyanggang/persistence/experience/ExperienceRepositoryImpl.java @@ -94,17 +94,6 @@ public List findByUserIdAndParentTagId(UUID userId, UUID parentTagId return experienceJpaEntities.stream().map(experienceMapper::toExperienceDomainEntity).toList(); } - @Override - public List findByUserIdAndParentTagIdAndYearDesc(int year, UUID parentTagId, UUID userId) { - LocalDateTime startYear = LocalDateTime.of(year, 1, 1, 0, 0); - LocalDateTime endYear = LocalDateTime.of(year, 12, 31, 23, 59); - - List experienceJpaEntities = experienceJpaRepository - .findByUserIdAndParentTagIdAndCreatedAtBetweenOrderByCreatedAtDesc( - userId, parentTagId, startYear, endYear); - return experienceJpaEntities.stream().map(experienceMapper::toExperienceDomainEntity).toList(); - } - @Override public List findByYear(int year) { LocalDateTime startYear = LocalDateTime.of(year, 1, 1, 0, 0); From 8d7bcb090ac73768dc4bd5c428a2b025deee2292 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Thu, 23 May 2024 15:43:09 +0900 Subject: [PATCH 5/6] =?UTF-8?q?test:=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=84=B8?= =?UTF-8?q?=ED=8C=85=20=EB=A1=9C=EC=A7=81=20=EB=A6=AC=ED=8C=A9=ED=86=A0?= =?UTF-8?q?=EB=A7=81(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../experience/aggregate/ExperienceTest.kt | 27 +++++++++++++++---- .../service/StrongPointAppenderTest.kt | 5 ++-- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/ExperienceTest.kt b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/ExperienceTest.kt index fd3f956b..8a08e59f 100644 --- a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/ExperienceTest.kt +++ b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/experience/aggregate/ExperienceTest.kt @@ -13,11 +13,28 @@ class ExperienceTest : FunSpec({ val title = "경험 제목" val parentTagId: UUID = UUID.randomUUID() val childTagId: UUID = UUID.randomUUID() - val contents: List = generateFixture() - val experienceStrongPoints: List = generateFixture() - val startedAt: LocalDateTime = generateFixture() - val endedAt: LocalDateTime = generateFixture() - val userId : UUID = generateFixture() + val contents = arrayListOf( + ExperienceContent( + question = "질문 1", + answer = "대답 1" + ), + ExperienceContent( + question = "질문 2", + answer = "대답 2" + ) + ) + + val experienceStrongPoints: List = arrayListOf( + ExperienceStrongPoint.create( + UUID.randomUUID() + ), + ExperienceStrongPoint.create( + UUID.randomUUID() + ) + ) + val startedAt: LocalDateTime = LocalDateTime.now() + val endedAt: LocalDateTime = startedAt.plusDays(1) + val userId = UUID.randomUUID() val newExperience = Experience.create( title = title, diff --git a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/strongpoint/service/StrongPointAppenderTest.kt b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/strongpoint/service/StrongPointAppenderTest.kt index f008e968..dd5a7142 100644 --- a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/strongpoint/service/StrongPointAppenderTest.kt +++ b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/strongpoint/service/StrongPointAppenderTest.kt @@ -1,6 +1,5 @@ package com.bamyanggang.domainmodule.domain.strongpoint.service -import com.bamyanggang.commonmodule.fixture.generateFixture import com.bamyanggang.domainmodule.domain.strongpoint.repository.StrongPointRepository import io.kotest.core.spec.style.BehaviorSpec import io.mockk.mockk @@ -12,8 +11,8 @@ class StrongPointAppenderTest : BehaviorSpec({ val strongPointAppender = StrongPointAppender(strongPointRepository) Given("역량 키워드 입력 값이 주어졌을 때") { - val name: String = generateFixture() - val userId: UUID = generateFixture() + val name: String = "역량 키워드 이름" + val userId: UUID = UUID.randomUUID() When("StrongPointAppender.appendStrongPoint 함수가 호출되면") { strongPointAppender.appendStrongPoint(name, userId) From 5d224ac0b8946641e1c49b6d42337197db74d816 Mon Sep 17 00:00:00 2001 From: whereami0404 Date: Thu, 23 May 2024 16:09:38 +0900 Subject: [PATCH 6/6] =?UTF-8?q?feat:=20=ED=83=9C=EA=B7=B8=20=EC=9D=B4?= =?UTF-8?q?=EB=A6=84=20=EA=B3=B5=EB=B0=B1=20=EC=98=88=EC=99=B8=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1(#159)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domainmodule/domain/tag/aggregate/Tag.kt | 5 +++++ .../domainmodule/domain/tag/exception/TagException.kt | 3 +++ .../bamyanggang/domainmodule/domain/tag/TagTest.kt | 11 +++++++++++ 3 files changed, 19 insertions(+) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/aggregate/Tag.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/aggregate/Tag.kt index f1fd5746..176f413b 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/aggregate/Tag.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/aggregate/Tag.kt @@ -1,6 +1,7 @@ package com.bamyanggang.domainmodule.domain.tag.aggregate import com.bamyanggang.domainmodule.common.entity.DomainEntity +import com.bamyanggang.domainmodule.domain.tag.exception.TagException import com.example.uuid.UuidCreator import java.util.* @@ -11,6 +12,10 @@ data class Tag( val userId: UUID ) : DomainEntity{ + init { + require(name.isNotEmpty()) { TagException.EmptyName().message } + } + fun isDuplicatedName(name: String): Boolean = this.name == name companion object { diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/exception/TagException.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/exception/TagException.kt index cec0706e..0d98209d 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/exception/TagException.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/tag/exception/TagException.kt @@ -16,6 +16,9 @@ sealed class TagException( class NotFoundTag(message: String = "존재하지 않는 태그 입니다.") : TagException(errorCode = 3, message = message) + class EmptyName(message: String = "태그 이름은 공백일 수 없습니다.") : + TagException(errorCode = 4, message = message) + companion object { const val CODE_PREFIX = "TAG" } diff --git a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/tag/TagTest.kt b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/tag/TagTest.kt index a4a292f7..a86ac14d 100644 --- a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/tag/TagTest.kt +++ b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/tag/TagTest.kt @@ -1,6 +1,7 @@ package com.bamyanggang.domainmodule.domain.tag import com.bamyanggang.domainmodule.domain.tag.aggregate.Tag +import io.kotest.assertions.throwables.shouldThrow import io.kotest.core.spec.DisplayName import io.kotest.core.spec.style.DescribeSpec import io.kotest.matchers.shouldBe @@ -28,5 +29,15 @@ class TagTest: DescribeSpec({ originTag.isDuplicatedName(newTag.name) shouldBe false } } + + context("태그 이름으로 공백이 넘어오면") { + it("IllegalmentArgumentException을 발생시킨다.") { + val emptyTitle = "" + shouldThrow { + Tag.create(emptyTitle, null, UUID.randomUUID()) + Tag.create(emptyTitle, UUID.randomUUID(), UUID.randomUUID()) + } + } + } } })