Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸš€ 3단계 - ν…ŒμŠ€νŠΈλ₯Ό ν†΅ν•œ μ½”λ“œ 보호 #698

Open
wants to merge 23 commits into
base: jinan159
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
afc8aaa
docs: step2 ν”Όλ“œλ°± 반영
jinan159 May 12, 2024
a3065e9
chore: mockk μ˜μ‘΄μ„± μΆ”κ°€
jinan159 May 12, 2024
82e9539
test: μƒν’ˆ 생성 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 13, 2024
3cab8d9
test: Fake Repository μΆ”κ°€
jinan159 May 14, 2024
fe24fc3
test: μƒν’ˆ 생성 ν…ŒμŠ€νŠΈ μ½”λ“œ μˆ˜μ •
jinan159 May 15, 2024
fcf6b5c
test: μƒν’ˆ 가격 μˆ˜μ • ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 15, 2024
e605b79
test: μƒν’ˆ λͺ©λ‘ 쑰회 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 16, 2024
fc5a00d
test: 메뉴 κ·Έλ£Ή 생성 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 17, 2024
d0e4fd7
test: 메뉴 κ·Έλ£Ή λͺ©λ‘ 쑰회 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 17, 2024
115417b
test: 메뉴 생성 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 17, 2024
a534738
test: 메뉴 가격 μˆ˜μ • ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 20, 2024
b3aa8aa
test: 메뉴 λ…ΈμΆœ 처리 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 20, 2024
874ef87
test: 메뉴 μˆ¨κΉ€ 처리 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 20, 2024
2e17fcf
test: μ£Όλ¬Έ ν…Œμ΄λΈ” 생성 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 21, 2024
fc50bd3
test: μ£Όλ¬Έ ν…Œμ΄λΈ” 착석, 곡석 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 22, 2024
6758d85
test: μ£Όλ¬Έ ν…Œμ΄λΈ” μ†λ‹˜ 수 λ³€κ²½ ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 22, 2024
f6cfba7
test: μ£Όλ¬Έ 생성 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 23, 2024
173035d
test: μ£Όλ¬Έ μ ‘μˆ˜ ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 23, 2024
c7c105e
test: μ£Όλ¬Έ 전달 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 23, 2024
442b945
test: μ£Όλ¬Έ 배달 μ‹œμž‘ 처리 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 23, 2024
6cbd2b6
test: μ£Όλ¬Έ 배달 μ™„λ£Œ 처리 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 23, 2024
cee895c
test: μ£Όλ¬Έ μ™„λ£Œ 처리 ν…ŒμŠ€νŠΈ μ½”λ“œ μΆ”κ°€
jinan159 May 23, 2024
d846ca9
refactor: JpaRepository 듀을 infra νŒ¨ν‚€μ§€λ‘œ 이동
jinan159 May 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ docker compose -p kitchenpos up -d

### μ£Όλ¬Έ

- μ£Όλ¬Έ μƒνƒœλŠ” `λŒ€κΈ°μ€‘`, `μ ‘μˆ˜λ¨`, `전달됨`, `배달쀑`, `배달됨`, `μ£Όλ¬Έμ™„λ£Œ` 둜 λ‚˜νƒ€λ‚Ό 수 μžˆλ‹€.
- μ£Όλ¬Έ 방식은 `배달주문`, `포μž₯μ£Όλ¬Έ`, `맀μž₯μ£Όλ¬Έ` 쀑 ν•˜λ‚˜λ₯Ό 선택해야 ν•œλ‹€.
- μ£Όλ¬Έ μƒνƒœλŠ” μ£Όλ¬Έ 방식에 따라 λ‹€μŒκ³Ό 같은 μˆœμ„œλ‘œ μ§„ν–‰λœλ‹€.
- `배달주문` 의 경우 `λŒ€κΈ°μ€‘`, `μ ‘μˆ˜λ¨`, `전달됨`, `배달쀑`, `배달됨`, `μ£Όλ¬Έμ™„λ£Œ` μˆœμ„œλ‘œ μ§„ν–‰λœλ‹€.
- `포μž₯μ£Όλ¬Έ`, `맀μž₯μ£Όλ¬Έ` 의 경우 `λŒ€κΈ°μ€‘`, `μ ‘μˆ˜λ¨`, `전달됨`, `μ£Όλ¬Έμ™„λ£Œ` μˆœμ„œλ‘œ μ§„ν–‰λœλ‹€.
- 주문을 생성할 수 μžˆλ‹€.
- μ£Όλ¬Έ 방식은 `배달주문`, `포μž₯μ£Όλ¬Έ`, `맀μž₯식사` 쀑 ν•˜λ‚˜λ₯Ό 선택해야 ν•œλ‹€.
- 주문은 μ΅œμ†Œ ν•˜λ‚˜ μ΄μƒμ˜ μ£Όλ¬Έ μƒν’ˆμ΄ ν•„μš”ν•˜λ‹€.
- λ“±λ‘λœ 메뉴에 μ—†λŠ” μ£Όλ¬Έ μƒν’ˆμ€ μ£Όλ¬Έν•  수 μ—†λ‹€.
- μ£Όλ¬Έ μƒν’ˆμ˜ μˆ˜λŸ‰μ΄ 0 미만이 될 수 μ—†λ‹€.
- 단, `맀μž₯식사` 인 κ²½μš°μ—λŠ” μ£Όλ¬Έ μƒν’ˆ μˆ˜λŸ‰μ„ 0 미만으둜 μ„€μ •ν•  수 μžˆλ‹€.
- 단, `맀μž₯μ£Όλ¬Έ` 인 κ²½μš°μ—λŠ” μ£Όλ¬Έ μƒν’ˆ μˆ˜λŸ‰μ„ 0 미만으둜 μ„€μ •ν•  수 μžˆλ‹€.
- λΉ„λ…ΈμΆœ 처리된 λ©”λ‰΄λŠ” μ£Όλ¬Έν•  수 μ—†λ‹€.
- μ£Όλ¬Έ μƒν’ˆμ˜ 가격은 λ©”λ‰΄μ˜ 가격과 κ°™μ•„μ•Ό ν•œλ‹€.
- `배달주문` 인 κ²½μš°μ—λŠ” 배달 μ£Όμ†Œκ°€ μžˆμ–΄μ•Ό ν•œλ‹€.
Expand All @@ -74,8 +76,8 @@ docker compose -p kitchenpos up -d
- μ£Όλ¬Έ 배달 μ™„λ£Œ μ²˜λ¦¬κ°€ 되면 μ£Όλ¬Έ μƒνƒœλŠ” `배달됨` 이 λ˜μ–΄μ•Ό ν•œλ‹€.
- μ£Όλ¬Έ μ™„λ£Œ 처리λ₯Ό ν•  수 μžˆλ‹€.
- `배달주문` 인 경우 `배달됨` μƒνƒœμ—¬μ•Ό μ£Όλ¬Έ μ™„λ£Œ 처리λ₯Ό ν•  수 μžˆλ‹€.
- `포μž₯μ£Όλ¬Έ`, `맀μž₯식사` 인 경우 `전달됨` μƒνƒœμ—¬μ•Ό μ£Όλ¬Έ μ™„λ£Œ 처리λ₯Ό ν•  수 μžˆλ‹€.
- `맀μž₯식사` 인 경우 μ™„λ£Œλœ 주문의 ν…Œμ΄λΈ”μ€ 곡석 μ²˜λ¦¬κ°€ λ˜μ–΄μ•Ό ν•œλ‹€.
- `포μž₯μ£Όλ¬Έ`, `맀μž₯μ£Όλ¬Έ` 인 경우 `전달됨` μƒνƒœμ—¬μ•Ό μ£Όλ¬Έ μ™„λ£Œ 처리λ₯Ό ν•  수 μžˆλ‹€.
- `맀μž₯μ£Όλ¬Έ` 인 경우 μ™„λ£Œλœ 주문의 ν…Œμ΄λΈ”μ€ 곡석 μ²˜λ¦¬κ°€ λ˜μ–΄μ•Ό ν•œλ‹€.
- μ£Όλ¬Έ μ™„λ£Œ μ²˜λ¦¬κ°€ 되면 μ£Όλ¬Έ μƒνƒœλŠ” `μ™„λ£Œλ¨` 이 λ˜μ–΄μ•Ό ν•œλ‹€.
- μ£Όλ¬Έ λͺ©λ‘μ„ μ‘°νšŒν•  수 μžˆλ‹€.

Expand Down
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies {
runtimeOnly("com.mysql:mysql-connector-j")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("io.kotest:kotest-runner-junit5:5.8.1")
testImplementation("io.mockk:mockk:1.13.10")
}

tasks.withType<KotlinCompile> {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/kitchenpos/application/OrderService.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public Order create(final Order request) {
if (Objects.isNull(orderLineItemRequests) || orderLineItemRequests.isEmpty()) {
throw new IllegalArgumentException();
}

final List<Menu> menus = menuRepository.findAllByIdIn(
orderLineItemRequests.stream()
.map(OrderLineItem::getMenuId)
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/kitchenpos/domain/JpaMenuGroupRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package kitchenpos.domain;

import org.springframework.data.jpa.repository.JpaRepository;

import java.util.UUID;

public interface JpaMenuGroupRepository extends MenuGroupRepository, JpaRepository<MenuGroup, UUID> {
}
19 changes: 19 additions & 0 deletions src/main/java/kitchenpos/domain/JpaMenuRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package kitchenpos.domain;

import jakarta.annotation.Nonnull;
import java.util.List;
import java.util.UUID;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

public interface JpaMenuRepository extends MenuRepository, JpaRepository<Menu, UUID> {
@Nonnull
@Override
List<Menu> findAllByIdIn(@Nonnull List<UUID> ids);

@Nonnull
@Override
@Query("select m from Menu m join m.menuProducts mp where mp.product.id = :productId")
List<Menu> findAllByProductId(@Nonnull @Param("productId") UUID productId);
}
11 changes: 11 additions & 0 deletions src/main/java/kitchenpos/domain/JpaOrderRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package kitchenpos.domain;

import jakarta.annotation.Nonnull;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.UUID;

public interface JpaOrderRepository extends OrderRepository, JpaRepository<Order, UUID> {
@Override
boolean existsByOrderTableAndStatusNot(@Nonnull OrderTable orderTable, @Nonnull OrderStatus status);
}
8 changes: 8 additions & 0 deletions src/main/java/kitchenpos/domain/JpaOrderTableRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package kitchenpos.domain;

import org.springframework.data.jpa.repository.JpaRepository;

import java.util.UUID;

public interface JpaOrderTableRepository extends OrderTableRepository, JpaRepository<OrderTable, UUID> {
}
12 changes: 12 additions & 0 deletions src/main/java/kitchenpos/domain/JpaProductRepository.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package kitchenpos.domain;

import jakarta.annotation.Nonnull;
import org.springframework.data.jpa.repository.JpaRepository;

import java.util.List;
import java.util.UUID;

public interface JpaProductRepository extends ProductRepository, JpaRepository<Product, UUID> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ProductRepository와 같은 λ ˆνŒŒμ§€ν† λ¦¬λ“€μ΄ 도메인 νŒ¨ν‚€μ§€μ— μžˆλŠ” 것은 이해가 κ°€λŠ”λ°μš”, μΈν„°νŽ˜μ΄μŠ€κΈ΄ ν•˜μ§€λ§Œ 사싀상 Jpa와 직접 μ—°κ΄€λ˜μ–΄ 있기 λ•Œλ¬Έμ— domain μ˜μ—­μ΄ μ•„λ‹ˆλΌκ³  λ³Ό 수 μžˆμ„ 것 κ°™μ•„μš”. 이에 λŒ€ν•΄ μ–΄λ–»κ²Œ μƒκ°ν•˜μ‹œλ‚˜μš”?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

λ§μ”€ν•˜μ‹ λŒ€λ‘œ, Jpa κ΄€λ ¨ κΈ°λŠ₯이닀 λ³΄λ‹ˆ domain λ³΄λ‹€λŠ” infra μ˜μ—­μ— μžˆλŠ”κ²Œ μ–΄μšΈλ¦΄ 것 κ°™μŠ΅λ‹ˆλ‹€!

@Nonnull
List<Product> findAllByIdIn(@Nonnull List<UUID> ids);
}
15 changes: 12 additions & 3 deletions src/main/java/kitchenpos/domain/MenuGroupRepository.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package kitchenpos.domain;

import org.springframework.data.jpa.repository.JpaRepository;

import jakarta.annotation.Nonnull;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

public interface MenuGroupRepository extends JpaRepository<MenuGroup, UUID> {
public interface MenuGroupRepository {
Comment on lines -7 to +8

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JpaRepository와 λ„λ©”μΈμ˜ λ ˆνŒŒμ§€ν† λ¦¬λ₯Ό 잘 λ‚˜λˆ„μ–΄μ£Όμ…¨λ„€μš” πŸ‘

@Nonnull
MenuGroup save(@Nonnull MenuGroup menuGroup);

@Nonnull
List<MenuGroup> findAll();

@Nonnull
Optional<MenuGroup> findById(@Nonnull UUID menuGroupId);
}
24 changes: 16 additions & 8 deletions src/main/java/kitchenpos/domain/MenuRepository.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
package kitchenpos.domain;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import jakarta.annotation.Nonnull;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

public interface MenuRepository extends JpaRepository<Menu, UUID> {
List<Menu> findAllByIdIn(List<UUID> ids);
public interface MenuRepository {
@Nonnull
Menu save(@Nonnull Menu menu);

@Nonnull
List<Menu> findAll();

@Nonnull
List<Menu> findAllByIdIn(@Nonnull List<UUID> list);

@Nonnull
List<Menu> findAllByProductId(@Nonnull UUID productId);

@Query("select m from Menu m join m.menuProducts mp where mp.product.id = :productId")
List<Menu> findAllByProductId(@Param("productId") UUID productId);
@Nonnull
Optional<Menu> findById(@Nonnull UUID menuId);
}
18 changes: 14 additions & 4 deletions src/main/java/kitchenpos/domain/OrderRepository.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
package kitchenpos.domain;

import org.springframework.data.jpa.repository.JpaRepository;

import jakarta.annotation.Nonnull;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

public interface OrderRepository extends JpaRepository<Order, UUID> {
boolean existsByOrderTableAndStatusNot(OrderTable orderTable, OrderStatus status);
public interface OrderRepository {
@Nonnull
Order save(@Nonnull Order order);

@Nonnull
Optional<Order> findById(@Nonnull UUID orderId);

boolean existsByOrderTableAndStatusNot(@Nonnull OrderTable orderTable, @Nonnull OrderStatus orderStatus);

@Nonnull
List<Order> findAll();
}
15 changes: 12 additions & 3 deletions src/main/java/kitchenpos/domain/OrderTableRepository.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package kitchenpos.domain;

import org.springframework.data.jpa.repository.JpaRepository;

import jakarta.annotation.Nonnull;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

public interface OrderTableRepository extends JpaRepository<OrderTable, UUID> {
public interface OrderTableRepository {
@Nonnull
Optional<OrderTable> findById(@Nonnull UUID orderTableId);

@Nonnull
OrderTable save(@Nonnull OrderTable orderTable);

@Nonnull
List<OrderTable> findAll();
}
18 changes: 14 additions & 4 deletions src/main/java/kitchenpos/domain/ProductRepository.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
package kitchenpos.domain;

import org.springframework.data.jpa.repository.JpaRepository;

import jakarta.annotation.Nonnull;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

public interface ProductRepository extends JpaRepository<Product, UUID> {
List<Product> findAllByIdIn(List<UUID> ids);
public interface ProductRepository {
@Nonnull
List<Product> findAllByIdIn(@Nonnull List<UUID> list);

@Nonnull
Optional<Product> findById(@Nonnull UUID productId);

@Nonnull
List<Product> findAll();

@Nonnull
Product save(@Nonnull Product product);
}
79 changes: 79 additions & 0 deletions src/test/java/kitchenpos/application/MenuGroupServiceCreateTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package kitchenpos.application

import io.kotest.assertions.throwables.shouldThrowAny
import io.kotest.core.spec.style.ShouldSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.types.shouldBeTypeOf
import java.util.UUID
import kitchenpos.domain.MenuGroup
import kitchenpos.testsupport.FakeMenuGroupRepository

class MenuGroupServiceCreateTest : ShouldSpec({
lateinit var service: MenuGroupService

beforeTest {
service = MenuGroupService(
FakeMenuGroupRepository()
)
}

context("메뉴 κ·Έλ£Ή 생성") {
should("성곡") {
// given
val request = createRequest(
id = null
)

// when
val result = service.create(request)

// then
result.name shouldBe request.name
}

should("μ‹€νŒ¨ - 메뉴 κ·Έλ£Ήλͺ…이 μž…λ ₯λ˜μ§€ μ•Šμ€ 경우") {
// given
val request = createRequest(
id = null,
name = null
)

// when
val result = shouldThrowAny {
service.create(request)
}

// then
result.shouldBeTypeOf<IllegalArgumentException>()
}

should("μ‹€νŒ¨ - 메뉴 κ·Έλ£Ήλͺ…이 λΉ„μ–΄μžˆλŠ” 경우") {
// given
val request = createRequest(
id = null,
name = ""
)

// when
val result = shouldThrowAny {
service.create(request)
}

// then
result.shouldBeTypeOf<IllegalArgumentException>()
}
}
}) {
companion object {
private fun createRequest(
id: UUID? = UUID.randomUUID(),
name: String? = "test-menu-group-name"
): MenuGroup {
return MenuGroup().apply {
this.id = id
this.name = name

}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package kitchenpos.application

import io.kotest.core.spec.style.ShouldSpec
import io.kotest.matchers.collections.shouldNotBeEmpty
import io.kotest.matchers.should
import io.kotest.matchers.shouldBe
import kitchenpos.domain.MenuGroupRepository
import kitchenpos.testsupport.FakeMenuGroupRepository
import kitchenpos.testsupport.MenuGroupFixtures.createMenuGroup

class MenuGroupServiceFindAllTest : ShouldSpec({

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FindAllμ΄λ‚˜ Create와 같은 λ©”μ„œλ“œ λ‹¨μœ„λ‘œ λ‚˜λˆ„κ²Œ λ˜λŠ” 경우 이후 λ§Žμ€ λ©”μ„œλ“œκ°€ 생기면 ν…ŒμŠ€νŠΈ ν΄λž˜μŠ€κ°€ λ„ˆλ¬΄ λ§Žμ•„μ§ˆ 것 κ°™μ•„μš”.

쑰회 / μˆ˜μ • / μ‚­μ œμ™€ 같은 λ‹¨μœ„λ‘œ λ‚˜λˆ„κ±°λ‚˜ ν˜Ήμ€ λ³΅μž‘λ„κ°€ λ†’μ•„μ§€λŠ” μ‹œμ μ— 클래슀 자체λ₯Ό λ‚˜λˆ„λŠ” 것도 방법일 것 κ°™μŠ΅λ‹ˆλ‹€.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

쑰회 / μˆ˜μ • / μ‚­μ œ λ‹¨μœ„λ‘œ λ‚˜λˆ„κ±°λ‚˜, ν•˜λ‚˜λ‘œ μž‘μ„±ν–ˆλ‹€ λ³΅μž‘λ„κ°€ λ†’μ•„μ§€λŠ” μ‹œμ μ— λΆ„λ¦¬ν•˜λŠ” 방법도 μ’‹λ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€!
λ‹€λ§Œ, 각 κΈ°λŠ₯(λ©”μ„œλ“œ)λ§ˆλ‹€ ν•„μš”ν•œ Fixture 의 μƒνƒœλ‚˜ ν…ŒμŠ€νŠΈ 쑰건이 μ‘°κΈˆμ”© λ‹¬λΌμ„œ, λΆ„λ¦¬ν•˜κΈ° μœ„ν•΄ λ³„λ„μ˜ 클래슀둜 λ‚˜λˆ΄μ—ˆμŠ΅λ‹ˆλ‹€.

이처럼 클래슀λ₯Ό 많이 λ‚˜λˆ„κ²Œ 되면 λ°œμƒν•  수 μžˆλŠ” 단점을 생각해보면,,
μ €λŠ” λ‹Ήμž₯ μƒκ°λ‚˜λŠ”κ±΄ 도메인 변경이 λ°œμƒν–ˆμ„λ•Œ, μˆ˜μ •ν•΄μ•Όν•˜λŠ” μ˜μ—­μ΄ λ§Žμ•„μ§ˆ 수 μžˆκ² λ‹€λŠ” 생각이 λ“€μ—ˆλŠ”λ°μš”.
ν•˜μ§€λ§Œ 클래슀λ₯Ό λ‚˜λˆ”μœΌλ‘œμ„œ ν…ŒμŠ€νŠΈ μž‘μ„±κ³Ό 관리가 μš©μ΄ν•œ μž₯점도 μžˆμ–΄μ„œ μ €λŠ” 클래슀λ₯Ό λ‚˜λˆ„λŠ” 선택을 ν–ˆμ—ˆμŠ΅λ‹ˆλ‹€.

ν˜Ήμ‹œ ν…ŒμŠ€νŠΈ ν΄λž˜μŠ€κ°€ λ„ˆλ¬΄ 많으면 또 μ–΄λ–€ 단점이 μžˆμ„κΉŒμš”?

lateinit var menuGroupRepository: MenuGroupRepository
lateinit var service: MenuGroupService

beforeTest {
menuGroupRepository = FakeMenuGroupRepository()

service = MenuGroupService(
menuGroupRepository
)
}

context("메뉴 κ·Έλ£Ή λͺ©λ‘ 쑰회") {
should("성곡") {
// given
val savedMenuGroup = menuGroupRepository.save(
createMenuGroup()
)

// when
val result = service.findAll()

// then
result.shouldNotBeEmpty()
result.first() should { menuGroup ->
menuGroup.id shouldBe savedMenuGroup.id
menuGroup.name shouldBe savedMenuGroup.name
}
}
}
})
Loading