Skip to content

Commit

Permalink
Merge branch 'dev' into refactor/#396_belljun3395
Browse files Browse the repository at this point in the history
  • Loading branch information
belljun3395 authored Sep 11, 2024
2 parents 4b9e9c4 + 6aa3191 commit 1efd676
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 96 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.few.api.web.controller.subscription.request

import com.fasterxml.jackson.annotation.JsonProperty

data class UpdateSubscriptionDayRequest(
@JsonProperty("date")
val dayCode: String,
val workbookId: Long?,
)
Original file line number Diff line number Diff line change
Expand Up @@ -411,113 +411,113 @@ class SubscriptionControllerTest : ControllerTestSpec() {
)
)
)
}

@Test
@DisplayName("[PATCH] /api/v1/subscriptions/time")
@WithUserDetails(userDetailsServiceBeanName = "testTokenUserDetailsService")
fun updateSubscriptionTime() {
// given
val api = "UpdateSubscriptionTime"
val token = "thisisaccesstoken"
val uri = UriComponentsBuilder.newInstance()
.path("$BASE_URL/subscriptions/time")
.build()
.toUriString()
@Test
@DisplayName("[PATCH] /api/v1/subscriptions/time")
@WithUserDetails(userDetailsServiceBeanName = "testTokenUserDetailsService")
fun updateSubscriptionTime() {
// given
val api = "UpdateSubscriptionTime"
val token = "thisisaccesstoken"
val uri = UriComponentsBuilder.newInstance()
.path("$BASE_URL/subscriptions/time")
.build()
.toUriString()

val time = LocalTime.of(8, 0)
val workbookId = 1L
val body = objectMapper.writeValueAsString(
UpdateSubscriptionTimeRequest(
time = time,
workbookId = workbookId
)
val time = LocalTime.of(8, 0)
val workbookId = 1L
val body = objectMapper.writeValueAsString(
UpdateSubscriptionTimeRequest(
time = time,
workbookId = workbookId
)
)

// when
mockMvc.perform(
patch(uri)
.header("Authorization", "Bearer $token")
.content(body)
.contentType(MediaType.APPLICATION_JSON)
).andExpect(MockMvcResultMatchers.status().is2xxSuccessful)
.andDo(
document(
api.toIdentifier(),
ResourceDocumentation.resource(
ResourceSnippetParameters.builder()
.description("구독 시간을 변경합니다.")
.summary(api.toIdentifier())
.privateResource(false)
.deprecated(false)
.tag(TAG)
.requestSchema(Schema.schema(api.toRequestSchema()))
.requestHeaders(
ResourceDocumentation.headerWithName("Authorization")
.defaultValue("{{accessToken}}")
.description("Bearer 어세스 토큰")
)
.responseSchema(Schema.schema(api.toResponseSchema()))
.responseFields(
*Description.describe()
)
.build()
)
// when
mockMvc.perform(
patch(uri)
.header("Authorization", "Bearer $token")
.content(body)
.contentType(MediaType.APPLICATION_JSON)
).andExpect(MockMvcResultMatchers.status().is2xxSuccessful)
.andDo(
document(
api.toIdentifier(),
ResourceDocumentation.resource(
ResourceSnippetParameters.builder()
.description("구독 시간을 변경합니다.")
.summary(api.toIdentifier())
.privateResource(false)
.deprecated(false)
.tag(TAG)
.requestSchema(Schema.schema(api.toRequestSchema()))
.requestHeaders(
ResourceDocumentation.headerWithName("Authorization")
.defaultValue("{{accessToken}}")
.description("Bearer 어세스 토큰")
)
.responseSchema(Schema.schema(api.toResponseSchema()))
.responseFields(
*Description.describe()
)
.build()
)
)
}
)
}

@Test
@DisplayName("[PATCH] /api/v1/subscriptions/day")
@WithUserDetails(userDetailsServiceBeanName = "testTokenUserDetailsService")
fun updateSubscriptionDay() {
// given
val api = "UpdateSubscriptionDay"
val token = "thisisaccesstoken"
val uri = UriComponentsBuilder.newInstance()
.path("$BASE_URL/subscriptions/day")
.build()
.toUriString()
@Test
@DisplayName("[PATCH] /api/v1/subscriptions/day")
@WithUserDetails(userDetailsServiceBeanName = "testTokenUserDetailsService")
fun updateSubscriptionDay() {
// given
val api = "UpdateSubscriptionDay"
val token = "thisisaccesstoken"
val uri = UriComponentsBuilder.newInstance()
.path("$BASE_URL/subscriptions/day")
.build()
.toUriString()

val dateTimeCode = DayCode.MON_TUE_WED_THU_FRI_SAT_SUN
val workbookId = 1L
val body = objectMapper.writeValueAsString(
UpdateSubscriptionDayRequest(
workbookId = workbookId,
dayCode = dateTimeCode.code
)
val dateTimeCode = DayCode.MON_TUE_WED_THU_FRI_SAT_SUN
val workbookId = 1L
val body = objectMapper.writeValueAsString(
UpdateSubscriptionDayRequest(
workbookId = workbookId,
dayCode = dateTimeCode.code
)
)

// when
mockMvc.perform(
patch(uri)
.header("Authorization", "Bearer $token")
.content(body)
.contentType(MediaType.APPLICATION_JSON)
).andExpect(MockMvcResultMatchers.status().is2xxSuccessful)
.andDo(
document(
api.toIdentifier(),
ResourceDocumentation.resource(
ResourceSnippetParameters.builder()
.description("구독 요일을 변경합니다.")
.summary(api.toIdentifier())
.privateResource(false)
.deprecated(false)
.tag(TAG)
.requestSchema(Schema.schema(api.toRequestSchema()))
.requestHeaders(
ResourceDocumentation.headerWithName("Authorization")
.defaultValue("{{accessToken}}")
.description("Bearer 어세스 토큰")
)
.responseSchema(Schema.schema(api.toResponseSchema()))
.responseFields(
*Description.describe()
)
.build()
)
// when
mockMvc.perform(
patch(uri)
.header("Authorization", "Bearer $token")
.content(body)
.contentType(MediaType.APPLICATION_JSON)
).andExpect(MockMvcResultMatchers.status().is2xxSuccessful)
.andDo(
document(
api.toIdentifier(),
ResourceDocumentation.resource(
ResourceSnippetParameters.builder()
.description("구독 요일을 변경합니다.")
.summary(api.toIdentifier())
.privateResource(false)
.deprecated(false)
.tag(TAG)
.requestSchema(Schema.schema(api.toRequestSchema()))
.requestHeaders(
ResourceDocumentation.headerWithName("Authorization")
.defaultValue("{{accessToken}}")
.description("Bearer 어세스 토큰")
)
.responseSchema(Schema.schema(api.toResponseSchema()))
.responseFields(
*Description.describe()
)
.build()
)
)
}
)
}
}

0 comments on commit 1efd676

Please sign in to comment.