Skip to content

Commit

Permalink
refactor(review) 리뷰반영
Browse files Browse the repository at this point in the history
  • Loading branch information
seungjoopet committed Sep 4, 2023
1 parent 00f88dd commit 03fd8a0
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import java.util.List;
import kitchenpos.application.fakerepository.MenuGroupFakeRepository;
import kitchenpos.domain.MenuGroup;
import kitchenpos.domain.MenuGroupRepository;
import org.junit.jupiter.api.BeforeEach;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
import com.google.common.collect.ImmutableList;
import java.math.BigDecimal;
import java.util.UUID;
import kitchenpos.application.fakerepository.MenuFakeRepository;
import kitchenpos.application.fakerepository.MenuGroupFakeRepository;
import kitchenpos.application.fakerepository.ProductFakeRepository;
import kitchenpos.domain.Menu;
import kitchenpos.domain.MenuGroup;
import kitchenpos.domain.MenuGroupRepository;
Expand All @@ -21,7 +24,7 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class MenuServiceChangePriceTest extends AbstractApplicationServiceTest {
class MenuServiceChangePriceTest extends TestSetup {

private static final BigDecimal TEST_PRICE = BigDecimal.valueOf(1_000L);
private static final String TEST_MENU_NAME = "dummyMenuName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import java.util.List;
import java.util.NoSuchElementException;
import java.util.UUID;
import kitchenpos.application.fakerepository.MenuFakeRepository;
import kitchenpos.application.fakerepository.MenuGroupFakeRepository;
import kitchenpos.application.fakerepository.ProductFakeRepository;
import kitchenpos.domain.Menu;
import kitchenpos.domain.MenuGroup;
import kitchenpos.domain.MenuGroupRepository;
Expand All @@ -23,7 +26,7 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class MenuServiceDisplayTest extends AbstractApplicationServiceTest {
class MenuServiceDisplayTest extends TestSetup {

private static final BigDecimal TEST_PRICE = BigDecimal.valueOf(1_000L);
private static final String TEST_MENU_NAME = "dummyMenuName";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import java.math.BigDecimal;
import java.util.List;
import java.util.NoSuchElementException;
import kitchenpos.application.fakerepository.MenuFakeRepository;
import kitchenpos.application.fakerepository.MenuGroupFakeRepository;
import kitchenpos.application.fakerepository.ProductFakeRepository;
import kitchenpos.domain.Menu;
import kitchenpos.domain.MenuGroup;
import kitchenpos.domain.MenuGroupRepository;
Expand All @@ -28,7 +31,7 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class MenuServiceForCreateTest extends AbstractApplicationServiceTest {
class MenuServiceForCreateTest extends TestSetup {

private static final BigDecimal TEST_PRICE = BigDecimal.valueOf(1_000L);
private static final String TEST_MENU_NAME = "dummyMenuName";
Expand Down
5 changes: 4 additions & 1 deletion src/test/java/kitchenpos/application/MenuServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

import java.math.BigDecimal;
import java.util.List;
import kitchenpos.application.fakerepository.MenuFakeRepository;
import kitchenpos.application.fakerepository.MenuGroupFakeRepository;
import kitchenpos.application.fakerepository.ProductFakeRepository;
import kitchenpos.domain.Menu;
import kitchenpos.domain.MenuGroupRepository;
import kitchenpos.domain.MenuRepository;
Expand All @@ -17,7 +20,7 @@
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class MenuServiceTest extends AbstractApplicationServiceTest {
class MenuServiceTest extends TestSetup {

@Mock
private PurgomalumClient mockClient;
Expand Down
24 changes: 12 additions & 12 deletions src/test/java/kitchenpos/application/ProductServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.util.List;
import java.util.NoSuchElementException;
import java.util.UUID;
import kitchenpos.application.fakerepository.MenuFakeRepository;
import kitchenpos.application.fakerepository.ProductFakeRepository;
import kitchenpos.domain.Menu;
import kitchenpos.domain.MenuProduct;
import kitchenpos.domain.MenuRepository;
Expand All @@ -19,11 +21,14 @@
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.NullSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

@ExtendWith(MockitoExtension.class)
class ProductServiceTest extends AbstractApplicationServiceTest {
class ProductServiceTest extends TestSetup {

private static final String TEST_NAME = "dummyName";
private static final BigDecimal TEST_PRICE = BigDecimal.valueOf(1_000L);
Expand Down Expand Up @@ -58,18 +63,13 @@ void create_success() {
}

@DisplayName("product의 가격이 없거나 음수이면 예외를 발생시킨다.")
@Test
void create_invalid_price() {

// given
final Product nullPrice = createProductRequest(TEST_NAME, null);
final Product negativePrice = createProductRequest(TEST_NAME, BigDecimal.valueOf(-1L));

@ParameterizedTest
@NullSource
@ValueSource(strings = "-1")
void create_invalid_price(final BigDecimal value) {
// when & then
assertThatThrownBy(() -> service.create(nullPrice))
.isInstanceOf(IllegalArgumentException.class);

assertThatThrownBy(() -> service.create(negativePrice))
assertThatThrownBy(
() -> service.create(createProductRequest(TEST_NAME, value)))
.isInstanceOf(IllegalArgumentException.class);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import kitchenpos.domain.Product;


public abstract class AbstractApplicationServiceTest {
public abstract class TestSetup {

protected Product createProductRequest(final String name, final BigDecimal price) {
final Product product = new Product();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kitchenpos.application;
package kitchenpos.application.fakerepository;

import java.util.HashMap;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kitchenpos.application;
package kitchenpos.application.fakerepository;

import java.util.HashMap;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kitchenpos.application;
package kitchenpos.application.fakerepository;

import java.util.HashMap;
import java.util.List;
Expand Down

0 comments on commit 03fd8a0

Please sign in to comment.