Skip to content

Commit

Permalink
feat: 검수 장소 삭제 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
kokodak committed Oct 3, 2023
1 parent 38fa3b2 commit 6219c59
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,28 @@
package com.now.naaga.temporaryplace.presentation;

import com.now.naaga.temporaryplace.application.TemporaryPlaceService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/temporary-places")
@RestController
public class TemporaryPlaceController {

private final TemporaryPlaceService temporaryPlaceService;

public TemporaryPlaceController(final TemporaryPlaceService temporaryPlaceService) {
this.temporaryPlaceService = temporaryPlaceService;
}

@DeleteMapping("/{temporaryPlaceId}")
public ResponseEntity<Void> deleteTemporaryPlace(@PathVariable final Long temporaryPlaceId) {
temporaryPlaceService.deleteById(temporaryPlaceId);
return ResponseEntity
.status(HttpStatus.NO_CONTENT)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.now.naaga.temporaryplace.presentation;

import static org.assertj.core.api.Assertions.assertThat;

import com.now.naaga.common.CommonControllerTest;
import com.now.naaga.common.builder.TemporaryPlaceBuilder;
import com.now.naaga.temporaryplace.domain.TemporaryPlace;
import io.restassured.RestAssured;
import io.restassured.response.ExtractableResponse;
import io.restassured.response.Response;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator.ReplaceUnderscores;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.test.context.ActiveProfiles;

@SuppressWarnings("NonAsciiCharacters")
@DisplayNameGeneration(ReplaceUnderscores.class)
@ActiveProfiles("test")
class TemporaryPlaceControllerTest extends CommonControllerTest {

@Autowired
private TemporaryPlaceBuilder temporaryPlaceBuilder;

@Value("${manager.id}")
private String id;

@Value("${manager.password}")
private String password;

@BeforeEach
protected void setUp() {
super.setUp();
}

@Test
void ID_통한_삭제_요청이_성공하면_204_응답코드를_반환한다() {
// given
final TemporaryPlace temporaryPlace = temporaryPlaceBuilder.init()
.build();

// when
final ExtractableResponse<Response> extract = RestAssured.given()
.log().all()
.auth().preemptive().basic(id, password)
.when()
.delete("/temporary-places/{temporaryPlaceId}", temporaryPlace.getId())
.then()
.log().all()
.extract();

// then
final int statusCode = extract.statusCode();
assertThat(statusCode).isEqualTo(HttpStatus.NO_CONTENT.value());
}
}

0 comments on commit 6219c59

Please sign in to comment.