From ccba919ef399992f13345bcd13a1838b47f0b2f9 Mon Sep 17 00:00:00 2001 From: Dae-Hwa Date: Sat, 20 Nov 2021 00:53:56 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20=EA=B7=B8=EB=A3=B9=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C=20=EB=AA=A9=EC=97=85=20API=20=EB=B0=8F=20?= =?UTF-8?q?=EB=AC=B8=EC=84=9C=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ✅ Closes: #216 --- src/docs/asciidoc/group/group-deletion.adoc | 7 ++++ src/docs/asciidoc/index.adoc | 3 ++ .../web/group/controller/GroupController.java | 6 +++ .../scoup/web/group/GroupAcceptanceTest.java | 42 +++++++++++++++++-- .../group/provider/DeleteGroupProvider.java | 24 +++++++++++ 5 files changed, 78 insertions(+), 4 deletions(-) create mode 100644 src/docs/asciidoc/group/group-deletion.adoc create mode 100644 src/test/java/com/postsquad/scoup/web/group/provider/DeleteGroupProvider.java diff --git a/src/docs/asciidoc/group/group-deletion.adoc b/src/docs/asciidoc/group/group-deletion.adoc new file mode 100644 index 00000000..1a43672c --- /dev/null +++ b/src/docs/asciidoc/group/group-deletion.adoc @@ -0,0 +1,7 @@ +== 그룹 삭제 + +=== `POST /api/groups/{groupId}` + +=== `204 No Content` + +operation::group_acceptance_test/delete_group[snippets='path-parameters,http-request,http-response'] diff --git a/src/docs/asciidoc/index.adoc b/src/docs/asciidoc/index.adoc index d694fe6a..c6da6844 100644 --- a/src/docs/asciidoc/index.adoc +++ b/src/docs/asciidoc/index.adoc @@ -32,6 +32,9 @@ include::group/group-creation.adoc[] // 그룹 수정 include::group/group-modification.adoc[] +// 그룹 삭제 +include::group/group-deletion.adoc[] + // 스케줄 후보 전체 조회 include::schedule/schedule-candidate-read-all.adoc[] diff --git a/src/main/java/com/postsquad/scoup/web/group/controller/GroupController.java b/src/main/java/com/postsquad/scoup/web/group/controller/GroupController.java index a56353a9..4cdfd53e 100644 --- a/src/main/java/com/postsquad/scoup/web/group/controller/GroupController.java +++ b/src/main/java/com/postsquad/scoup/web/group/controller/GroupController.java @@ -38,4 +38,10 @@ public ErrorResponse groupCreationFailedExceptionHandler(GroupCreationFailedExce public void update(@PathVariable Long groupId, @RequestBody @Valid GroupModificationRequest groupModificationRequest, @LoggedInUser User user) { groupService.update(groupId, groupModificationRequest, user); } + + @DeleteMapping("/{groupId}") + @ResponseStatus(HttpStatus.NO_CONTENT) + public void delete(@PathVariable Long groupId) { + // TODO: 삭제 서비스, 사용자 인증 + } } diff --git a/src/test/java/com/postsquad/scoup/web/group/GroupAcceptanceTest.java b/src/test/java/com/postsquad/scoup/web/group/GroupAcceptanceTest.java index 0fcbc284..12f04741 100644 --- a/src/test/java/com/postsquad/scoup/web/group/GroupAcceptanceTest.java +++ b/src/test/java/com/postsquad/scoup/web/group/GroupAcceptanceTest.java @@ -7,10 +7,7 @@ import com.postsquad.scoup.web.group.controller.request.GroupCreationRequest; import com.postsquad.scoup.web.group.controller.request.GroupModificationRequest; import com.postsquad.scoup.web.group.domain.Group; -import com.postsquad.scoup.web.group.provider.CreateGroupProvider; -import com.postsquad.scoup.web.group.provider.CreateGroupWithExistingNameProvider; -import com.postsquad.scoup.web.group.provider.ModifyGroupProvider; -import com.postsquad.scoup.web.group.provider.ValidateGroupCreationRequestProvider; +import com.postsquad.scoup.web.group.provider.*; import io.restassured.RestAssured; import io.restassured.http.ContentType; import io.restassured.response.Response; @@ -59,6 +56,11 @@ public class GroupAcceptanceTest extends AcceptanceTestBase { .optional() ); + private static final Snippet GROUP_DELETION_PATH_PARAMETERS = pathParameters( + parameterWithName("groupId") + .description("그룹 ID") + ); + @Autowired TestEntityManager testEntityManager; @@ -220,4 +222,36 @@ void modifyGroup(String description, Long givenGroupId, GroupModificationRequest .isEqualTo(expectedGroup) ); } + + @ParameterizedTest + @ArgumentsSource(DeleteGroupProvider.class) + @DisplayName("사용자가 그룹을 삭제 할 수 있다") + void deleteGroup(String description, Group givenGroup) { + testEntityManager.persist(givenGroup); + + String path = "/groups/{groupId}"; + RequestSpecification givenRequest = RestAssured.given(this.spec) + .baseUri(BASE_URL) + .port(port) + .basePath("/api") + .pathParam("groupId", givenGroup.getId()) + .contentType(ContentType.JSON) + .header("Accept-Language", "en-US") + .header("Authorization", TEST_TOKEN); + + // when + Response actualResponse = givenRequest.when() + .filter(document( + DEFAULT_RESTDOCS_PATH, + GROUP_DELETION_PATH_PARAMETERS + )) + .log().all() + .delete(path); + + // then + actualResponse.then() + .log().all() + .statusCode(HttpStatus.NO_CONTENT.value()); + // TODO: DB에 해당 그룹 존재하지 않는 것 확인 + } } diff --git a/src/test/java/com/postsquad/scoup/web/group/provider/DeleteGroupProvider.java b/src/test/java/com/postsquad/scoup/web/group/provider/DeleteGroupProvider.java new file mode 100644 index 00000000..084e6a9d --- /dev/null +++ b/src/test/java/com/postsquad/scoup/web/group/provider/DeleteGroupProvider.java @@ -0,0 +1,24 @@ +package com.postsquad.scoup.web.group.provider; + +import com.postsquad.scoup.web.group.domain.Group; +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.ArgumentsProvider; + +import java.util.stream.Stream; + +public class DeleteGroupProvider implements ArgumentsProvider { + + @Override + public Stream provideArguments(ExtensionContext context) throws Exception { + return Stream.of( + Arguments.of( + "성공", + Group.builder() + .name("groupToBeDeleted") + .description("description") + .build() + ) + ); + } +}