Skip to content

Commit

Permalink
Fix | CAKK-85 | 테스트 생성 필드 지정 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
YongsHub committed Sep 23, 2024
1 parent b5b83fa commit 9f04a4a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class ShopService {
public CakeShopCreateResponse createCakeShopByCertification(final CreateShopParam param) {
final CakeShop cakeShop = ShopMapper.supplyCakeShopBy(param);
final BusinessInformation businessInformation = ShopMapper.supplyBusinessInformationBy(param, cakeShop);
final List<CakeShopOperation> cakeShopOperations = ShopMapper.supplyCakeShopOperationsBy(cakeShop, param.getOperationsDays());
final List<CakeShopOperation> cakeShopOperations = ShopMapper.supplyCakeShopOperationsBy(cakeShop, param.getOperationDays());
final List<CakeShopLink> cakeShopLinks = LinkMapper.supplyCakeShopLinksBy(cakeShop, param.getLinks());

final CakeShop result = cakeShopManageFacade.create(cakeShop, cakeShopOperations, businessInformation, cakeShopLinks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,14 @@ import com.cakk.api.dto.request.shop.PromotionRequest
import com.cakk.api.dto.response.shop.CakeShopCreateResponse
import com.cakk.api.dto.response.shop.CakeShopOwnerCandidateResponse
import com.cakk.api.dto.response.shop.CakeShopOwnerCandidatesResponse
import com.cakk.common.enums.Days
import com.cakk.common.enums.LinkKind
import com.cakk.common.enums.ReturnCode
import com.cakk.common.response.ApiResponse
import com.cakk.core.dto.param.shop.ShopLinkParam
import com.cakk.core.dto.param.shop.ShopOperationParam
import net.jqwik.api.Arbitraries
import java.time.LocalTime

@SqlGroup(
Sql(
Expand All @@ -44,7 +50,17 @@ class AdminIntegrationTest(
.fromUriString(baseUrl)
.path("/shops/create")
.build()

val request = getConstructorMonkey().giveMeBuilder(CreateShopRequest::class.java)
.set("businessNumber", Arbitraries.strings().withCharRange('a', 'z').ofMaxLength(20))
.set("operationDays", listOf(ShopOperationParam(Days.MON, LocalTime.now(), LocalTime.now())))
.set("shopName", Arbitraries.strings().withCharRange('a', 'z').ofMaxLength(30).ofMinLength(1))
.set("shopBio", Arbitraries.strings().withCharRange('a', 'z').ofMaxLength(30).ofMinLength(1))
.set("shopDescription", Arbitraries.strings().withCharRange('a', 'z').ofMaxLength(30).ofMinLength(1))
.set("shopAddress", Arbitraries.strings().withCharRange('a', 'z').ofMaxLength(30).ofMinLength(1))
.set("latitude", Arbitraries.doubles().between(-90.0, 90.0))
.set("longitude", Arbitraries.doubles().between(-180.0, 180.0))
.set("links", listOf(ShopLinkParam(LinkKind.WEB, "www.cake-shop.com")))
.sample()

// when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;

import java.time.LocalTime;
import java.util.List;
import java.util.Set;

Expand All @@ -25,12 +26,16 @@
import com.cakk.api.dto.response.shop.CakeShopSimpleResponse;
import com.cakk.api.mapper.PointMapper;
import com.cakk.api.mapper.ShopMapper;
import com.cakk.common.enums.Days;
import com.cakk.common.enums.LinkKind;
import com.cakk.common.enums.ReturnCode;
import com.cakk.common.enums.VerificationStatus;
import com.cakk.common.exception.CakkException;
import com.cakk.core.dto.param.search.CakeShopSearchByViewsParam;
import com.cakk.core.dto.param.shop.CreateShopParam;
import com.cakk.core.dto.param.shop.PromotionParam;
import com.cakk.core.dto.param.shop.ShopLinkParam;
import com.cakk.core.dto.param.shop.ShopOperationParam;
import com.cakk.core.facade.cake.CakeShopReadFacade;
import com.cakk.core.facade.shop.CakeShopManageFacade;
import com.cakk.core.facade.user.UserReadFacade;
Expand Down Expand Up @@ -73,12 +78,13 @@ public class ShopServiceTest extends ServiceTest {
private CreateShopParam getCreateShopParamFixture() {
return getConstructorMonkey().giveMeBuilder(CreateShopParam.class)
.set("businessNumber", Arbitraries.strings().withCharRange('a', 'z').ofMinLength(1).ofMaxLength(7))
.setNotNull("operationDays")
.set("operationDays", List.of(new ShopOperationParam(Days.MON, LocalTime.now(), LocalTime.now()),
new ShopOperationParam(Days.TUE, LocalTime.now(), LocalTime.now())))
.setNotNull("shopName")
.setNotNull("shopAddress")
.setNotNull("latitude")
.setNotNull("longitude")
.setNotNull("links")
.set("links", List.of(new ShopLinkParam(LinkKind.WEB, "cake-shop.com")))
.set("shopBio", Arbitraries.strings().withCharRange('a', 'z').ofMaxLength(20))
.set("shopDescription", Arbitraries.strings().withCharRange('a', 'z').ofMaxLength(20))
.sample();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package com.cakk.core.dto.param.shop

data class CreateShopParam(
val businessNumber: String?,
val operationsDays: List<ShopOperationParam>,
val operationDays: List<ShopOperationParam>,
val shopName: String,
val shopBio: String?,
val shopDescription: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.cakk.common.enums.Role
import com.cakk.domain.mysql.entity.cake.Cake
import com.cakk.domain.mysql.entity.shop.CakeShop
import com.cakk.domain.mysql.entity.user.User
import org.springframework.test.util.ReflectionTestUtils

private const val SPATIAL_REFERENCE_IDENTIFIER_NUMBER: Int = 4326

Expand Down Expand Up @@ -72,8 +73,10 @@ abstract class FacadeTest {
}

protected fun getCakeShopFixture(): CakeShop {
return getConstructorMonkey().giveMeBuilder(CakeShop::class.java)
val cakeShop = getConstructorMonkey().giveMeBuilder(CakeShop::class.java)
.set("shopName", Arbitraries.strings().withCharRange('a', 'z').ofMaxLength(30))
.set("thumbnailUrl", Arbitraries.strings().withCharRange('a', 'z').ofMaxLength(30))
.set("shopAddress", Arbitraries.strings().withCharRange('a', 'z').ofMaxLength(30))
.set("shopBio", Arbitraries.strings().withCharRange('a', 'z').ofMaxLength(40))
.set("shopDescription", Arbitraries.strings().withCharRange('a', 'z').ofMaxLength(500))
.set(
Expand All @@ -83,6 +86,9 @@ abstract class FacadeTest {
)
)
.sample()
ReflectionTestUtils.setField(cakeShop, "heartCount", 0)
ReflectionTestUtils.setField(cakeShop, "likeCount", 0)
return cakeShop
}

fun supplyPointBy(latitude: Double, longitude: Double): Point {
Expand Down

0 comments on commit 9f04a4a

Please sign in to comment.