빌드 수정
This commit is contained in:
@@ -7,6 +7,8 @@ plugins {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
tasks.bootJar { enabled = false }
|
||||
tasks.jar { enabled = true }
|
||||
|
||||
dependencies {
|
||||
implementation project(':domain')
|
||||
|
||||
@@ -8,6 +8,9 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
tasks.bootJar { enabled = false }
|
||||
tasks.jar { enabled = true }
|
||||
|
||||
dependencies {
|
||||
implementation project(':domain')
|
||||
implementation 'org.springframework.boot:spring-boot-starter-web'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.github.sejoung.product.rest.mapper;
|
||||
|
||||
import io.github.sejoung.product.entities.Product;
|
||||
import io.github.sejoung.product.rest.constants.ProductStatus;
|
||||
import io.github.sejoung.product.rest.constants.ProductType;
|
||||
import io.github.sejoung.product.rest.dto.SaveRoundProduct;
|
||||
import io.github.sejoung.product.usecases.port.in.SaveRoundProductInUseCase;
|
||||
@@ -22,6 +23,7 @@ public interface SaveRoundProductMapper {
|
||||
.productId(command.getProductId())
|
||||
.productName(command.getProductName())
|
||||
.categoryId(command.getCategoryId())
|
||||
.status(ProductStatus.valueOf(command.getStatus().name()))
|
||||
.count(command.getCount())
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -28,13 +28,20 @@ class SaveRoundProductControllerTest {
|
||||
void saveRoundProduct() throws Exception {
|
||||
|
||||
var objectMapper = new ObjectMapper();
|
||||
var roundProductCommand = RestTestUtil.defaultSaveRoundProductCommand(null);
|
||||
var json = objectMapper.writeValueAsString(RestTestUtil.defaultSaveRoundProductCommand(null));
|
||||
mockMvc.perform(post(URL)
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.content(json))
|
||||
.andDo(print())
|
||||
.andExpect(status().isOk());
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.productId").value(1))
|
||||
.andExpect(jsonPath("$.categoryId").value(roundProductCommand.getCategoryId()))
|
||||
.andExpect(jsonPath("$.productType").value(roundProductCommand.getProductType().name()))
|
||||
.andExpect(jsonPath("$.status").value(roundProductCommand.getStatus().name()))
|
||||
.andExpect(jsonPath("$.productName").value(roundProductCommand.getProductName()))
|
||||
.andExpect(jsonPath("$.count").value(roundProductCommand.getCount()));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,13 +7,16 @@ import lombok.extern.slf4j.Slf4j;
|
||||
public class SaveRoundProductInUseCaseStub implements SaveRoundProductInUseCase {
|
||||
@Override
|
||||
public SaveRoundProductCommand save(SaveRoundProductCommand command) {
|
||||
log.debug("{}", command);
|
||||
return SaveRoundProductCommand.builder()
|
||||
log.debug("input {}", command);
|
||||
var output = SaveRoundProductCommand.builder()
|
||||
.categoryId(command.getCategoryId())
|
||||
.productName(command.getProductName())
|
||||
.productId(1L)
|
||||
.status(command.getStatus())
|
||||
.count(command.getCount())
|
||||
.build();
|
||||
log.debug("output {}", output);
|
||||
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package io.github.sejoung.product.configuration;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import io.github.sejoung.product.usecases.port.in.SaveRoundProductInUseCase;
|
||||
|
||||
@SpringBootTest
|
||||
class DIConfigurationTest {
|
||||
|
||||
@Autowired
|
||||
private SaveRoundProductInUseCase saveRoundProductInUseCase;
|
||||
|
||||
@Test
|
||||
void diTest() {
|
||||
assertThat(saveRoundProductInUseCase).isNotNull();
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package io.github.sejoung.product.rest.controller;
|
||||
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.*;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
import org.junit.jupiter.api.DisplayName;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import io.github.sejoung.product.rest.util.RestTestUtil;
|
||||
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
class SaveRoundProductControllerTest {
|
||||
|
||||
private static final String URL = "/product/round";
|
||||
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
@DisplayName("회차권 API 테스트")
|
||||
@Test
|
||||
void saveRoundProduct() throws Exception {
|
||||
|
||||
var objectMapper = new ObjectMapper();
|
||||
var json = objectMapper.writeValueAsString(RestTestUtil.defaultSaveRoundProductCommand(null));
|
||||
mockMvc.perform(post(URL)
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.accept(MediaType.APPLICATION_JSON)
|
||||
.content(json))
|
||||
.andDo(print())
|
||||
.andExpect(status().isOk());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package io.github.sejoung.product.rest.util;
|
||||
|
||||
import io.github.sejoung.product.entities.Product;
|
||||
import io.github.sejoung.product.usecases.port.in.SaveRoundProductInUseCase;
|
||||
|
||||
public interface RestTestUtil {
|
||||
|
||||
static SaveRoundProductInUseCase.SaveRoundProductCommand defaultSaveRoundProductCommand(Long productId) {
|
||||
return SaveRoundProductInUseCase.SaveRoundProductCommand.builder()
|
||||
.count(1)
|
||||
.status(Product.ProductStatus.CREATE)
|
||||
.productId(productId)
|
||||
.productName("회차권")
|
||||
.categoryId(1L)
|
||||
.build();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user