Skip to content

Commit

Permalink
Refactor: PR 리뷰 피드백 적용(오타, 사용하지 않는 코드제거(Valid), Long -> long 타입 변환)
Browse files Browse the repository at this point in the history
  • Loading branch information
ku-kim committed Apr 28, 2022
1 parent b3cb1eb commit ecac1da
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 22 deletions.
@@ -1,9 +1,6 @@
package sidedish.com.controller;

import java.util.List;
import javax.validation.constraints.Negative;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -25,12 +22,12 @@ public ProductsController(ProductsService productsService) {

@GetMapping
public List<ProductBasicTypeResponse> findProductsMealType(
@RequestParam @NotEmpty String meal) {
@RequestParam String meal) {
return productsService.findByMealType(meal);
}

@GetMapping("/{id}")
public ProductDetailTypeResponse findById(@PathVariable @Negative @NotNull Long id) {
public ProductDetailTypeResponse findById(@PathVariable Long id) {
return productsService.findById(id);
}

Expand Down
Expand Up @@ -17,9 +17,9 @@ public class ProductDetailTypeResponse {
private long fixedPrice;
private long originalPrice;
private String event;
private Long mileage;
private long mileage;
private String deliveryInfo;
private Long deliveryCharge;
private Long freeDeliveryOverAmount;
private long deliveryCharge;
private long freeDeliveryOverAmount;

}
Expand Up @@ -33,10 +33,10 @@ void setUp() {
given()
.accept(MediaType.APPLICATION_JSON_VALUE)

.when()
.when()
.get("/api/products?meal=soup")

.then()
.then()
.statusCode(HttpStatus.OK.value())
.assertThat()
.body("[0].id", equalTo(5))
Expand Down Expand Up @@ -88,26 +88,26 @@ void setUp() {
}

@Test
void 만약_유요하지않은_product_id가_주어졌을때_음식_상세조회_실패() {
void 만약_유효하지않은_product_id가_주어졌을때_음식_상세조회_실패() {
given()
.accept(MediaType.APPLICATION_JSON_VALUE)

.when()
.when()
.get("api/products/-1")

.then()
.then()
.statusCode(HttpStatus.NOT_FOUND.value());
}

@Test
void 만약_유요한_product_id지만_해당_id음식_존재하지_않는경우_상세조회_실패() {
void 만약_유효한_product_id지만_해당_id음식_존재하지_않는경우_상세조회_실패() {
given()
.accept(MediaType.APPLICATION_JSON_VALUE)

.when()
.when()
.get("api/products/999999")

.then()
.then()
.statusCode(HttpStatus.NOT_FOUND.value());
}

Expand All @@ -116,10 +116,10 @@ void setUp() {
given()
.accept(MediaType.APPLICATION_JSON_VALUE)

.when()
.when()
.get("/api/products/best?category=meat")

.then()
.then()
.statusCode(HttpStatus.OK.value())
.assertThat()
.body("[0].id", equalTo(1))
Expand Down Expand Up @@ -150,10 +150,10 @@ void setUp() {
given()
.accept(MediaType.APPLICATION_JSON_VALUE)

.when()
.when()
.get("/api/products/best")

.then()
.then()
.statusCode(HttpStatus.BAD_REQUEST.value());
}

Expand All @@ -162,10 +162,10 @@ void setUp() {
given()
.accept(MediaType.APPLICATION_JSON_VALUE)

.when()
.when()
.get("/api/products/best?category=abc")

.then()
.then()
.statusCode(HttpStatus.NOT_FOUND.value());
}
}

0 comments on commit ecac1da

Please sign in to comment.