-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: kbsat <[email protected]>
- Loading branch information
Showing
3 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
src/test/kotlin/apply/acceptance/fixture/RecruitmentFixture.kt
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,80 @@ | ||
package apply.acceptance.fixture | ||
|
||
import apply.application.RecruitmentResponse | ||
import apply.application.TermResponse | ||
import apply.ui.api.ApiResponse | ||
import io.restassured.RestAssured | ||
import io.restassured.http.ContentType | ||
import io.restassured.mapper.TypeRef | ||
import java.time.LocalDateTime | ||
|
||
data class RecruitmentRequest( | ||
var title: String, | ||
var term: TermResponse, | ||
var startDateTime: LocalDateTime, | ||
var endDateTime: LocalDateTime, | ||
var recruitable: Boolean, | ||
var hidden: Boolean, | ||
var recruitmentItems: List<RecruitmentItemRequest>, | ||
) | ||
|
||
class RecruitmentBuilder { | ||
var title: String = "웹 백엔드 3기" | ||
var termId: Long = 0L | ||
var startDateTime: LocalDateTime = LocalDateTime.now().minusYears(1) | ||
var endDateTime: LocalDateTime = LocalDateTime.now().plusYears(1) | ||
var recruitable: Boolean = false | ||
var hidden: Boolean = true | ||
var recruitmentItems: List<RecruitmentItemRequest> = recruitmentItems { | ||
recruitmentItem() | ||
recruitmentItem { | ||
title = "프로그래밍 학습 과정과 현재 자신이 생각하는 역량은?" | ||
position = 2 | ||
maximumLength = 1500 | ||
description = "우아한테크코스는..." | ||
} | ||
recruitmentItem { | ||
title = "프로그래밍 학습 과정과 현재 자신이 생각하는 역량은?" | ||
position = 3 | ||
maximumLength = 2000 | ||
description = "우아한테크코스는..." | ||
} | ||
} | ||
|
||
fun build(): RecruitmentResponse { | ||
val term = when (termId) { | ||
0L -> term() | ||
else -> getTermById(termId) | ||
} | ||
|
||
val recruitmentRequest = RecruitmentRequest( | ||
title, | ||
term, | ||
startDateTime, | ||
endDateTime, | ||
recruitable, | ||
hidden, | ||
recruitmentItems | ||
) | ||
|
||
return postRecruitment(recruitmentRequest) | ||
} | ||
|
||
private fun postRecruitment(recruitmentRequest: RecruitmentRequest): RecruitmentResponse { | ||
return RestAssured.given().log().all() | ||
.contentType(ContentType.JSON) | ||
.body(recruitmentRequest) | ||
.`when`() | ||
.post("/api/recruitments") | ||
.`as`(object : TypeRef<ApiResponse<RecruitmentResponse>>() {}) | ||
.body as RecruitmentResponse | ||
} | ||
} | ||
|
||
fun recruitment(builder: RecruitmentBuilder.() -> Unit): RecruitmentResponse { | ||
return RecruitmentBuilder().apply(builder).build() | ||
} | ||
|
||
fun recruitment(): RecruitmentResponse { | ||
return RecruitmentBuilder().build() | ||
} |
39 changes: 39 additions & 0 deletions
39
src/test/kotlin/apply/acceptance/fixture/RecruitmentItemFixture.kt
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,39 @@ | ||
package apply.acceptance.fixture | ||
|
||
class RecruitmentItemRequest( | ||
val title: String, | ||
val position: Int, | ||
val maximumLength: Int, | ||
val description: String | ||
) | ||
|
||
class RecruitmentItemBuilder { | ||
var title: String = "프로그래밍 학습 과정과 현재 자신이 생각하는 역량은?" | ||
var position: Int = 1 | ||
var maximumLength: Int = 1000 | ||
var description: String = "우아한테크코스는..." | ||
|
||
fun build(): RecruitmentItemRequest { | ||
return RecruitmentItemRequest(title, position, maximumLength, description) | ||
} | ||
} | ||
|
||
class RecruitmentItemsBuilder { | ||
private var recruitmentItems = mutableListOf<RecruitmentItemRequest>() | ||
|
||
fun recruitmentItem(builder: RecruitmentItemBuilder.() -> Unit) { | ||
recruitmentItems.add(RecruitmentItemBuilder().apply(builder).build()) | ||
} | ||
|
||
fun recruitmentItem() { | ||
recruitmentItems.add(RecruitmentItemBuilder().build()) | ||
} | ||
|
||
fun build(): List<RecruitmentItemRequest> { | ||
return recruitmentItems | ||
} | ||
} | ||
|
||
fun recruitmentItems(builder: RecruitmentItemsBuilder.() -> Unit): List<RecruitmentItemRequest> { | ||
return RecruitmentItemsBuilder().apply(builder).build() | ||
} |
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