|
| 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