Skip to content

Commit 6219c59

Browse files
committed
feat: 검수 장소 삭제 API 구현
1 parent 38fa3b2 commit 6219c59

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,28 @@
11
package com.now.naaga.temporaryplace.presentation;
22

3+
import com.now.naaga.temporaryplace.application.TemporaryPlaceService;
4+
import org.springframework.http.HttpStatus;
5+
import org.springframework.http.ResponseEntity;
6+
import org.springframework.web.bind.annotation.DeleteMapping;
7+
import org.springframework.web.bind.annotation.PathVariable;
38
import org.springframework.web.bind.annotation.RequestMapping;
49
import org.springframework.web.bind.annotation.RestController;
510

611
@RequestMapping("/temporary-places")
712
@RestController
813
public class TemporaryPlaceController {
14+
15+
private final TemporaryPlaceService temporaryPlaceService;
16+
17+
public TemporaryPlaceController(final TemporaryPlaceService temporaryPlaceService) {
18+
this.temporaryPlaceService = temporaryPlaceService;
19+
}
20+
21+
@DeleteMapping("/{temporaryPlaceId}")
22+
public ResponseEntity<Void> deleteTemporaryPlace(@PathVariable final Long temporaryPlaceId) {
23+
temporaryPlaceService.deleteById(temporaryPlaceId);
24+
return ResponseEntity
25+
.status(HttpStatus.NO_CONTENT)
26+
.build();
27+
}
928
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.now.naaga.temporaryplace.presentation;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import com.now.naaga.common.CommonControllerTest;
6+
import com.now.naaga.common.builder.TemporaryPlaceBuilder;
7+
import com.now.naaga.temporaryplace.domain.TemporaryPlace;
8+
import io.restassured.RestAssured;
9+
import io.restassured.response.ExtractableResponse;
10+
import io.restassured.response.Response;
11+
import org.junit.jupiter.api.BeforeEach;
12+
import org.junit.jupiter.api.DisplayNameGeneration;
13+
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
14+
import org.junit.jupiter.api.Test;
15+
import org.springframework.beans.factory.annotation.Autowired;
16+
import org.springframework.beans.factory.annotation.Value;
17+
import org.springframework.http.HttpStatus;
18+
import org.springframework.test.context.ActiveProfiles;
19+
20+
@SuppressWarnings("NonAsciiCharacters")
21+
@DisplayNameGeneration(ReplaceUnderscores.class)
22+
@ActiveProfiles("test")
23+
class TemporaryPlaceControllerTest extends CommonControllerTest {
24+
25+
@Autowired
26+
private TemporaryPlaceBuilder temporaryPlaceBuilder;
27+
28+
@Value("${manager.id}")
29+
private String id;
30+
31+
@Value("${manager.password}")
32+
private String password;
33+
34+
@BeforeEach
35+
protected void setUp() {
36+
super.setUp();
37+
}
38+
39+
@Test
40+
void ID를_통한_삭제_요청이_성공하면_204_응답코드를_반환한다() {
41+
// given
42+
final TemporaryPlace temporaryPlace = temporaryPlaceBuilder.init()
43+
.build();
44+
45+
// when
46+
final ExtractableResponse<Response> extract = RestAssured.given()
47+
.log().all()
48+
.auth().preemptive().basic(id, password)
49+
.when()
50+
.delete("/temporary-places/{temporaryPlaceId}", temporaryPlace.getId())
51+
.then()
52+
.log().all()
53+
.extract();
54+
55+
// then
56+
final int statusCode = extract.statusCode();
57+
assertThat(statusCode).isEqualTo(HttpStatus.NO_CONTENT.value());
58+
}
59+
}

0 commit comments

Comments
 (0)