Skip to content

Commit

Permalink
feat: ๐ŸŽธ ๊ทธ๋ฃน ์‚ญ์ œ ๋ชฉ์—… API ๋ฐ ๋ฌธ์„œ ์ž‘์„ฑ
Browse files Browse the repository at this point in the history
โœ… Closes: #216
  • Loading branch information
Dae-Hwa committed Nov 19, 2021
1 parent a76c56c commit ccba919
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/docs/asciidoc/group/group-deletion.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
== ๊ทธ๋ฃน ์‚ญ์ œ

=== `POST /api/groups/{groupId}`

=== `204 No Content`

operation::group_acceptance_test/delete_group[snippets='path-parameters,http-request,http-response']
3 changes: 3 additions & 0 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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[]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: ์‚ญ์ œ ์„œ๋น„์Šค, ์‚ฌ์šฉ์ž ์ธ์ฆ
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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์— ํ•ด๋‹น ๊ทธ๋ฃน ์กด์žฌํ•˜์ง€ ์•Š๋Š” ๊ฒƒ ํ™•์ธ
}
}
Original file line number Diff line number Diff line change
@@ -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<? extends Arguments> provideArguments(ExtensionContext context) throws Exception {
return Stream.of(
Arguments.of(
"์„ฑ๊ณต",
Group.builder()
.name("groupToBeDeleted")
.description("description")
.build()
)
);
}
}

0 comments on commit ccba919

Please sign in to comment.