From a261fe020cef39a9409ed7bbe8145b018ee138b6 Mon Sep 17 00:00:00 2001 From: seeunjang Date: Mon, 20 May 2024 02:15:47 +0900 Subject: [PATCH 1/4] =?UTF-8?q?feat=20:=20Apply=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EC=88=98=EC=A0=95=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80(#84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/jobDescription/aggregate/Apply.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/aggregate/Apply.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/aggregate/Apply.kt index 50f308d2..ecab1daf 100644 --- a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/aggregate/Apply.kt +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/aggregate/Apply.kt @@ -15,6 +15,16 @@ data class Apply( val jobDescriptionId: UUID, ): DomainEntity { + fun update( + contents: List, + ): Apply { + return copy( + contents = contents, + jobDescriptionId = jobDescriptionId, + updatedAt = LocalDateTime.now() + ) + } + companion object { fun create( contents: List, From f621cc46c0022c9f7ab64573fc90428f1702c204 Mon Sep 17 00:00:00 2001 From: seeunjang Date: Mon, 20 May 2024 02:18:51 +0900 Subject: [PATCH 2/4] =?UTF-8?q?refactor=20:=20dto=20=EC=88=98=EC=A0=95(#84?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/dto/{GetApplyInfo.kt => ApplyInfo.kt} | 6 +++++- .../domain/jobDescription/application/dto/CreateApply.kt | 5 +++++ .../jobDescription/application/dto/CreateApplyContent.kt | 7 ------- .../application/service/ApplyInfoGetService.kt | 8 ++++---- .../jobDescription/application/ApplyCreateServiceTest.kt | 3 +-- 5 files changed, 15 insertions(+), 14 deletions(-) rename Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/{GetApplyInfo.kt => ApplyInfo.kt} (73%) delete mode 100644 Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/CreateApplyContent.kt diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/GetApplyInfo.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/ApplyInfo.kt similarity index 73% rename from Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/GetApplyInfo.kt rename to Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/ApplyInfo.kt index c6dcf44b..51b1283b 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/GetApplyInfo.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/ApplyInfo.kt @@ -1,6 +1,10 @@ package com.bamyanggang.apimodule.domain.jobDescription.application.dto -class GetApplyInfo { +class ApplyInfo { + + data class Request( + val contents: List + ) data class Response( val applyContentList: List diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/CreateApply.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/CreateApply.kt index bf38dbf1..444cb210 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/CreateApply.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/CreateApply.kt @@ -6,4 +6,9 @@ class CreateApply { val contents : List ) + data class CreateApplyContent ( + val question: String, + val answer: String + ) + } diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/CreateApplyContent.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/CreateApplyContent.kt deleted file mode 100644 index c20568cd..00000000 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/dto/CreateApplyContent.kt +++ /dev/null @@ -1,7 +0,0 @@ -package com.bamyanggang.apimodule.domain.jobDescription.application.dto - -data class CreateApplyContent ( - val question: String, - val answer: String -) - diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/service/ApplyInfoGetService.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/service/ApplyInfoGetService.kt index bab63b51..c1eeb1ce 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/service/ApplyInfoGetService.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/service/ApplyInfoGetService.kt @@ -1,6 +1,6 @@ package com.bamyanggang.apimodule.domain.jobDescription.application.service -import com.bamyanggang.apimodule.domain.jobDescription.application.dto.GetApplyInfo +import com.bamyanggang.apimodule.domain.jobDescription.application.dto.ApplyInfo import com.bamyanggang.domainmodule.domain.jobDescription.service.ApplyReader import org.springframework.stereotype.Service import java.util.* @@ -10,14 +10,14 @@ class ApplyInfoGetService( private val applyReader: ApplyReader ) { - fun getApplyInfo(jobDescriptionId: UUID): GetApplyInfo.Response { + fun getApplyInfo(jobDescriptionId: UUID): ApplyInfo.Response { return applyReader.readApplyByJobDescriptionId(jobDescriptionId).contents.map { - GetApplyInfo.ContentInfo( + ApplyInfo.ContentInfo( it.question, it.answer ) }.let { - GetApplyInfo.Response(it) + ApplyInfo.Response(it) } } diff --git a/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/ApplyCreateServiceTest.kt b/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/ApplyCreateServiceTest.kt index ef9e908e..c030358e 100644 --- a/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/ApplyCreateServiceTest.kt +++ b/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/ApplyCreateServiceTest.kt @@ -1,7 +1,6 @@ package com.bamyanggang.apimodule.domain.jobDescription.application import com.bamyanggang.apimodule.domain.jobDescription.application.dto.CreateApply -import com.bamyanggang.apimodule.domain.jobDescription.application.dto.CreateApplyContent import com.bamyanggang.apimodule.domain.jobDescription.application.service.ApplyCreateService import com.bamyanggang.commonmodule.fixture.generateFixture import com.bamyanggang.domainmodule.domain.jobDescription.aggregate.JobDescription @@ -26,7 +25,7 @@ class ApplyCreateServiceTest : BehaviorSpec({ given("ApplyCreateService.createApply") { val request: CreateApply.Request = generateFixture { it.set("contents", listOf( - CreateApplyContent( + CreateApply.CreateApplyContent( question = "질문1", answer = "답변1" ) From c00a5f87602aa567bd8068f5f3a379ceb0df2a16 Mon Sep 17 00:00:00 2001 From: seeunjang Date: Mon, 20 May 2024 02:19:25 +0900 Subject: [PATCH 3/4] =?UTF-8?q?feat=20:=20=EC=9E=90=EA=B8=B0=EC=86=8C?= =?UTF-8?q?=EA=B0=9C=EC=84=9C=20=EC=88=98=EC=A0=95=20API=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84(#84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/service/ApplyUpdateService.kt | 26 +++++++++++++++++++ .../presentation/JobDescriptionApi.kt | 1 - .../presentation/JobDescriptionController.kt | 22 +++++++++------- .../jobDescription/service/ApplyModifier.kt | 26 +++++++++++++++++++ 4 files changed, 64 insertions(+), 11 deletions(-) create mode 100644 Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/service/ApplyUpdateService.kt create mode 100644 Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/service/ApplyModifier.kt diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/service/ApplyUpdateService.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/service/ApplyUpdateService.kt new file mode 100644 index 00000000..dcb619e8 --- /dev/null +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/service/ApplyUpdateService.kt @@ -0,0 +1,26 @@ +package com.bamyanggang.apimodule.domain.jobDescription.application.service + +import com.bamyanggang.apimodule.domain.jobDescription.application.dto.ApplyInfo +import com.bamyanggang.domainmodule.domain.jobDescription.aggregate.ApplyContent +import com.bamyanggang.domainmodule.domain.jobDescription.service.ApplyModifier +import org.springframework.stereotype.Service +import java.util.* + +@Service +class ApplyUpdateService( + private val applyModifier: ApplyModifier +) { + + fun updateApplyInfo(jobDescriptionId: UUID, request: ApplyInfo.Request) { + applyModifier.modifyApplyInfo( + jobDescriptionId = jobDescriptionId, + applyContentList = request.contents.map { + ApplyContent.create( + question = it.question, + answer = it.answer + ) + } + ) + } + +} diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionApi.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionApi.kt index f1d2865f..2b867c3e 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionApi.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionApi.kt @@ -4,5 +4,4 @@ object JobDescriptionApi { const val BASE_URL = "/api/job-description" const val APPLY = "${BASE_URL}/apply/{jobDescriptionId}" const val DETAIL = "${BASE_URL}/{jobDescriptionId}" - } diff --git a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionController.kt b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionController.kt index c66f301f..640f2d2f 100644 --- a/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionController.kt +++ b/Api-Module/src/main/kotlin/com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionController.kt @@ -1,20 +1,15 @@ package com.bamyanggang.apimodule.domain.jobDescription.presentation import com.bamyanggang.apimodule.common.dto.PageResponse -import com.bamyanggang.apimodule.domain.jobDescription.application.dto.CreateApply -import com.bamyanggang.apimodule.domain.jobDescription.application.dto.CreateJobDescription -import com.bamyanggang.apimodule.domain.jobDescription.application.dto.GetApplyInfo -import com.bamyanggang.apimodule.domain.jobDescription.application.dto.GetJobDescriptionInfo -import com.bamyanggang.apimodule.domain.jobDescription.application.service.ApplyCreateService -import com.bamyanggang.apimodule.domain.jobDescription.application.service.ApplyInfoGetService -import com.bamyanggang.apimodule.domain.jobDescription.application.service.JobDescriptionCreateService -import com.bamyanggang.apimodule.domain.jobDescription.application.service.JobDescriptionInfoGetService +import com.bamyanggang.apimodule.domain.jobDescription.application.dto.* +import com.bamyanggang.apimodule.domain.jobDescription.application.service.* import com.bamyanggang.domainmodule.domain.jobDescription.enums.SortType import com.bamyanggang.domainmodule.domain.jobDescription.enums.WriteStatus import org.springframework.data.domain.Pageable import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.PostMapping +import org.springframework.web.bind.annotation.PutMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController @@ -25,7 +20,8 @@ class JobDescriptionController( private val jobDescriptionCreateService: JobDescriptionCreateService, private val applyCreateService: ApplyCreateService, private val jobDescriptionInfoGetService: JobDescriptionInfoGetService, - private val applyInfoGetService: ApplyInfoGetService + private val applyInfoGetService: ApplyInfoGetService, + private val applyUpdateService: ApplyUpdateService ) { @PostMapping(JobDescriptionApi.BASE_URL) @@ -56,6 +52,12 @@ class JobDescriptionController( @GetMapping(JobDescriptionApi.APPLY) fun getApplyInfo( @PathVariable("jobDescriptionId") jobDescriptionId: UUID - ): GetApplyInfo.Response = applyInfoGetService.getApplyInfo(jobDescriptionId) + ): ApplyInfo.Response = applyInfoGetService.getApplyInfo(jobDescriptionId) + + @PutMapping(JobDescriptionApi.APPLY) + fun updateApplyInfo( + @PathVariable("jobDescriptionId") jobDescriptionId: UUID, + @RequestBody request: ApplyInfo.Request + ) = applyUpdateService.updateApplyInfo(jobDescriptionId, request) } diff --git a/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/service/ApplyModifier.kt b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/service/ApplyModifier.kt new file mode 100644 index 00000000..8d845e08 --- /dev/null +++ b/Domain-Module/src/main/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/service/ApplyModifier.kt @@ -0,0 +1,26 @@ +package com.bamyanggang.domainmodule.domain.jobDescription.service + +import com.bamyanggang.domainmodule.domain.jobDescription.aggregate.ApplyContent +import com.bamyanggang.domainmodule.domain.jobDescription.repository.ApplyRepository +import org.springframework.stereotype.Service +import java.util.* + +@Service +class ApplyModifier( + private val applyRepository: ApplyRepository +) { + + fun modifyApplyInfo( + jobDescriptionId: UUID, + applyContentList: List + ) { + applyRepository + .findByJobDescriptionId(jobDescriptionId) + .update( + contents = applyContentList + ) + .also { applyRepository.save(it) } + } + + +} From 59329162813f11137d0af9e2c449c63bdac04eb9 Mon Sep 17 00:00:00 2001 From: seeunjang Date: Mon, 20 May 2024 02:20:09 +0900 Subject: [PATCH 4/4] =?UTF-8?q?test=20:=20=EC=9E=90=EA=B8=B0=EC=86=8C?= =?UTF-8?q?=EA=B0=9C=EC=84=9C=20=EC=88=98=EC=A0=95=20API=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8=20=EC=BD=94=EB=93=9C=20=EC=9E=91=EC=84=B1,?= =?UTF-8?q?=20=EB=AA=85=EC=84=B8=20=EB=B0=98=EC=98=81(#84)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/docs/asciidoc/JobDescription.adoc | 6 +++ .../application/ApplyUpdateServiceTest.kt | 32 +++++++++++ .../JobDescriptionControllerTest.kt | 54 +++++++++++++++---- .../jobDescription/aggregate/ApplyTest.kt | 28 +++++++++- .../service/ApplyModifierTest.kt | 37 +++++++++++++ 5 files changed, 146 insertions(+), 11 deletions(-) create mode 100644 Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/ApplyUpdateServiceTest.kt create mode 100644 Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/service/ApplyModifierTest.kt diff --git a/Api-Module/src/docs/asciidoc/JobDescription.adoc b/Api-Module/src/docs/asciidoc/JobDescription.adoc index 97e17504..2f4851dc 100644 --- a/Api-Module/src/docs/asciidoc/JobDescription.adoc +++ b/Api-Module/src/docs/asciidoc/JobDescription.adoc @@ -41,6 +41,12 @@ operation::JobDescriptionControllerTest/getJobDescriptionDetail[snippets='http-r operation::JobDescriptionControllerTest/getApplyInfo[snippets='http-request,request-headers,path-parameters,http-response,response-fields'] +[[UPDATE-APPLY]] +=== 자기소개서 수정 + +operation::JobDescriptionControllerTest/updateApplyInfo[snippets='http-request,path-parameters,request-headers,request-fields,http-response'] + + diff --git a/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/ApplyUpdateServiceTest.kt b/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/ApplyUpdateServiceTest.kt new file mode 100644 index 00000000..c363c6fb --- /dev/null +++ b/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/jobDescription/application/ApplyUpdateServiceTest.kt @@ -0,0 +1,32 @@ +package com.bamyanggang.apimodule.domain.jobDescription.application + +import com.bamyanggang.apimodule.domain.jobDescription.application.dto.ApplyInfo +import com.bamyanggang.apimodule.domain.jobDescription.application.service.ApplyUpdateService +import com.bamyanggang.domainmodule.domain.jobDescription.service.ApplyModifier +import io.kotest.core.spec.style.BehaviorSpec +import io.mockk.mockk +import io.mockk.verify +import java.util.UUID + +class ApplyUpdateServiceTest: BehaviorSpec({ + val applyModifier = mockk(relaxed = true) + val service = ApplyUpdateService(applyModifier) + + given("ApplyUpdateService") { + val jobDescriptionId = UUID.randomUUID() + val request = ApplyInfo.Request( + contents = listOf( + ApplyInfo.ContentInfo( + question = "질문1", + answer = "답변1" + ) + ) + ) + `when`("updateApplyInfo") { + service.updateApplyInfo(jobDescriptionId, request) + then("should update apply info") { + verify { applyModifier.modifyApplyInfo(any(), any()) } + } + } + } +}) diff --git a/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionControllerTest.kt b/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionControllerTest.kt index fe2ad2d8..b0f22791 100644 --- a/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionControllerTest.kt +++ b/Api-Module/src/test/kotlin/com/bamyanggang/apimodule/domain/jobDescription/presentation/JobDescriptionControllerTest.kt @@ -3,10 +3,7 @@ package com.bamyanggang.apimodule.domain.jobDescription.presentation import com.bamyanggang.apimodule.BaseRestDocsTest import com.bamyanggang.apimodule.common.dto.PageResponse import com.bamyanggang.apimodule.domain.jobDescription.application.dto.* -import com.bamyanggang.apimodule.domain.jobDescription.application.service.ApplyCreateService -import com.bamyanggang.apimodule.domain.jobDescription.application.service.ApplyInfoGetService -import com.bamyanggang.apimodule.domain.jobDescription.application.service.JobDescriptionCreateService -import com.bamyanggang.apimodule.domain.jobDescription.application.service.JobDescriptionInfoGetService +import com.bamyanggang.apimodule.domain.jobDescription.application.service.* import com.bamyanggang.commonmodule.exception.ExceptionHandler import com.bamyanggang.commonmodule.fixture.generateFixture import com.bamyanggang.domainmodule.common.pagination.PageDomain @@ -46,6 +43,9 @@ class JobDescriptionControllerTest : BaseRestDocsTest() { @MockBean private lateinit var applyInfoGetService: ApplyInfoGetService + @MockBean + private lateinit var applyUpdateService: ApplyUpdateService + @Test @DisplayName("직무 공고를 등록한다.") fun createJobDescription() { @@ -179,7 +179,7 @@ class JobDescriptionControllerTest : BaseRestDocsTest() { fun createApply() { //given val jobDescriptionId = UUID.randomUUID() - val createApplyContentRequest: CreateApplyContent = generateFixture { + val createApplyContentRequest: CreateApply.CreateApplyContent = generateFixture { it.set("question", "질문") it.set("answer", "답변") } @@ -216,7 +216,7 @@ class JobDescriptionControllerTest : BaseRestDocsTest() { fun createApplyWithEmptyContent() { //given val jobDescriptionId = UUID.randomUUID() - val createApplyContentRequest: CreateApplyContent = generateFixture { + val createApplyContentRequest: CreateApply.CreateApplyContent = generateFixture { it.set("question", "질문") it.set("answer", "") } @@ -370,15 +370,15 @@ class JobDescriptionControllerTest : BaseRestDocsTest() { fun getApplyInfo() { // given val jobDescriptionId = UUID.randomUUID() - val contentInfo: GetApplyInfo.ContentInfo = generateFixture { + val contentInfo: ApplyInfo.ContentInfo = generateFixture { it.set("question", "질문") it.set("answer", "답변") } - val getApplyInfoResponse: GetApplyInfo.Response = generateFixture { + val applyInfoResponse: ApplyInfo.Response = generateFixture { it.set("applyContentList", listOf(contentInfo)) } - given(applyInfoGetService.getApplyInfo(jobDescriptionId)).willReturn(getApplyInfoResponse) + given(applyInfoGetService.getApplyInfo(jobDescriptionId)).willReturn(applyInfoResponse) val request = RestDocumentationRequestBuilders.get(JobDescriptionApi.APPLY, jobDescriptionId) .header("Authorization", "Bearer Access Token") @@ -405,4 +405,40 @@ class JobDescriptionControllerTest : BaseRestDocsTest() { ) } + @Test + @DisplayName("JD 공고 자기소개서 정보를 수정한다") + fun updateApplyInfo() { + // given + val jobDescriptionId = UUID.randomUUID() + val updateApplyRequest: ApplyInfo.Request = generateFixture { + it.set("contents", listOf(ApplyInfo.ContentInfo("질문", "답변"))) + } + + val request = RestDocumentationRequestBuilders.put(JobDescriptionApi.APPLY, jobDescriptionId) + .header("Authorization", "Bearer Access Token") + .contentType(MediaType.APPLICATION_JSON_VALUE) + .content(objectMapper.writeValueAsString(updateApplyRequest)) + + //when + val result = mockMvc.perform(request) + + //then + result.andExpect(status().isOk) + .andDo( + resultHandler.document( + requestHeaders( + headerWithName("Authorization").description("엑세스 토큰") + ), + pathParameters( + RequestDocumentation.parameterWithName("jobDescriptionId").description("jd 공고 ID") + ), + requestFields( + fieldWithPath("contents").description("내용"), + fieldWithPath("contents[].question").description("질문"), + fieldWithPath("contents[].answer").description("답변") + ) + ) + ) + } + } diff --git a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/aggregate/ApplyTest.kt b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/aggregate/ApplyTest.kt index 8913a35b..7891bd9f 100644 --- a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/aggregate/ApplyTest.kt +++ b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/aggregate/ApplyTest.kt @@ -10,7 +10,22 @@ import io.kotest.matchers.shouldBe import java.util.* class ApplyTest : FunSpec({ - test("Apply.create 생성") { + + test("Apply 생성") { + val applyContent: ApplyContent = generateFixture{ + it.set("question", "질문") + it.set("answer", "답변") + } + val contents = listOf(applyContent) + val jobDescriptionId: UUID = UUID.randomUUID() + + val apply = Apply.create(contents,jobDescriptionId) + + apply.contents shouldBe contents + apply.jobDescriptionId shouldBe jobDescriptionId + } + + test("Apply.update 업데이트") { val contents = listOf( ApplyContent.create( question = generateFixture { it.set("question", "질문") }, @@ -21,7 +36,16 @@ class ApplyTest : FunSpec({ val apply = Apply.create(contents,jobDescriptionId) - apply.jobDescriptionId shouldBe jobDescriptionId + val newContents = listOf( + ApplyContent.create( + question = generateFixture { it.set("question", "질문2") }, + answer = generateFixture { it.set("answer", "답변2") } + ) + ) + + val updatedApply = apply.update(newContents) + + updatedApply.contents shouldBe newContents } }) diff --git a/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/service/ApplyModifierTest.kt b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/service/ApplyModifierTest.kt new file mode 100644 index 00000000..7fa18f11 --- /dev/null +++ b/Domain-Module/src/test/kotlin/com/bamyanggang/domainmodule/domain/jobDescription/service/ApplyModifierTest.kt @@ -0,0 +1,37 @@ +package com.bamyanggang.domainmodule.domain.jobDescription.service + +import com.bamyanggang.commonmodule.fixture.generateFixture +import com.bamyanggang.domainmodule.domain.jobDescription.aggregate.ApplyContent +import com.bamyanggang.domainmodule.domain.jobDescription.repository.ApplyRepository +import io.kotest.core.spec.style.BehaviorSpec +import io.mockk.mockk +import io.mockk.verify +import java.util.UUID + +class ApplyModifierTest: BehaviorSpec({ + val applyRepository = mockk(relaxed = true) + val applyModifier = ApplyModifier(applyRepository) + + given("ApplyModifier.modifyApplyInfo") { + `when`("jobDescriptionId와 applyContentList가 주어지면") { + val jobDescriptionId = UUID.randomUUID() + val applyContent: ApplyContent = generateFixture{ + it.set("question", "질문") + it.set("answer", "답변") + } + val applyContentList = listOf(applyContent) + applyModifier.modifyApplyInfo(jobDescriptionId, applyContentList) + then("applyRepository.findByJobDescriptionId가 호출된다.") { + verify { + applyRepository.findByJobDescriptionId(jobDescriptionId) + } + } + then("applyRepository.save가 호출된다.") { + verify { + applyRepository.save(any()) + } + } + } + } + +})