Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(test): create recruitment fixture #576

Closed
wants to merge 27 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
5d5f74e
refactor(Term): change response of create api
summerlunaa Jul 16, 2022
167f820
refactor(Recruitment): change response of create api
summerlunaa Jul 16, 2022
785593a
refactor(Mission): change response of create api
summerlunaa Jul 16, 2022
f89f58d
refactor(Evaluation): change response of create api
summerlunaa Jul 16, 2022
ef10ede
refactor(Cheater): change response of create api
summerlunaa Jul 16, 2022
7cdff9e
refactor(Assignment): change response of create api
summerlunaa Jul 16, 2022
813ef60
refactor(Mail): change response of create api
summerlunaa Jul 16, 2022
de9b9d6
refactor: change variable name
summerlunaa Jul 16, 2022
ec6a95b
refactor: change variable name
summerlunaa Jul 16, 2022
0ebb612
feat(Mission): getById api
summerlunaa Jul 16, 2022
d194515
feat(Cheater): getById api
summerlunaa Jul 16, 2022
b68f355
refactor(Term): add administrator authorization
summerlunaa Jul 16, 2022
2b28b1c
refactor(Term): add entity to response of create api
summerlunaa Jul 18, 2022
18ccfb2
refactor(Recruitment): add entity to response of create api
summerlunaa Jul 18, 2022
82591c6
refactor(Term): change response type of create api
summerlunaa Jul 18, 2022
9633834
refactor(Mission): add entity to response of create api
summerlunaa Jul 18, 2022
f00a755
refactor(Evaluation): add entity to response of create api
summerlunaa Jul 18, 2022
3e00b4b
refactor(Cheater): add entity to response of create api
summerlunaa Jul 19, 2022
8560310
refactor(MailHistory): add entity to response of create api
summerlunaa Jul 19, 2022
d3d6a69
refactor(Assignment): add entity to response of create api
summerlunaa Jul 19, 2022
b6024a7
chore: add RestAssured dependency
summerlunaa Jul 24, 2022
5ada03c
test(Term): add TermFixture
summerlunaa Jul 24, 2022
7cf3109
test(RecruitmentItem): add RecruitmentItem Fixture
summerlunaa Jul 24, 2022
f7ed647
test(Recruitment): add Recruitment Fixture
summerlunaa Jul 24, 2022
ef02010
test(Term): add Term id in Term object
summerlunaa Jul 24, 2022
60e24ae
test(RecruitmentItem): create constructor for recruitmentItemData
summerlunaa Jul 24, 2022
6cb48de
test(Recruitment): add Recruitment id in Recruitment object
summerlunaa Jul 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
refactor(Mission): change response of create api
Co-authored-by: dongho108 <dongho108@naver.com>
  • Loading branch information
summerlunaa and dongho108 committed Jul 24, 2022
commit 785593ad89dc5803f441ae1bec6fe6ee56a131b0
5 changes: 3 additions & 2 deletions src/main/kotlin/apply/application/MissionService.kt
Original file line number Diff line number Diff line change
@@ -18,9 +18,9 @@ class MissionService(
private val evaluationTargetRepository: EvaluationTargetRepository,
private val assignmentRepository: AssignmentRepository
) {
fun save(request: MissionData) {
fun save(request: MissionData): Long {
validate(request)
missionRepository.save(
val mission = missionRepository.save(
request.let {
Mission(
it.title,
@@ -34,6 +34,7 @@ class MissionService(
)
}
)
return mission.id
}

private fun validate(request: MissionData) {
5 changes: 3 additions & 2 deletions src/main/kotlin/apply/ui/api/MissionRestController.kt
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import java.net.URI

@RestController
@RequestMapping("/api/recruitments/{recruitmentId}")
@@ -26,8 +27,8 @@ class MissionRestController(
@RequestBody missionData: MissionData,
@LoginUser(administrator = true) user: User
): ResponseEntity<Unit> {
missionService.save(missionData)
return ResponseEntity.ok().build()
val saveId = missionService.save(missionData)
return ResponseEntity.created(URI.create("/api/recruitments/$recruitmentId/missions/$saveId")).build()
}

@GetMapping("/missions")
6 changes: 4 additions & 2 deletions src/test/kotlin/apply/ui/api/MissionRestControllerTest.kt
Original file line number Diff line number Diff line change
@@ -34,7 +34,8 @@ internal class MissionRestControllerTest : RestControllerTest() {

@Test
fun `과제를 추가한다`() {
every { missionService.save(any()) } just Runs
val missionId = 1L
every { missionService.save(any()) } returns missionId

mockMvc.post(
"/api/recruitments/{recruitmentId}/missions",
@@ -44,7 +45,8 @@ internal class MissionRestControllerTest : RestControllerTest() {
contentType = MediaType.APPLICATION_JSON
content = objectMapper.writeValueAsString(createMissionData())
}.andExpect {
status { isOk }
status { isCreated }
header { string(HttpHeaders.LOCATION, "/api/recruitments/$recruitmentId/missions/$missionId") }
}
}