-
Notifications
You must be signed in to change notification settings - Fork 227
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
Step 3 : 테스트를 통한 코드 보호 #832
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요~! 성훈님,
리뷰가 늦어져서 죄송합니다~! 🙏
이번 미션 너무 잘 진행해 주셔서 간단한 코멘트만 있네요~! 👍
즐거운 하루 되세요~! 😄
import kitchenpos.infra.client.PurgomalumClient; | ||
import org.springframework.boot.web.client.RestTemplateBuilder; | ||
|
||
public class FakePurgomalumClient extends PurgomalumClient { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fake Object를 잘 활용해 주셨네요~! 👍 👍
import kitchenpos.domain.MenuGroup; | ||
import kitchenpos.domain.MenuProduct; | ||
|
||
public class MenuFixture { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixture을 이용한다면 반복되는 코드들이 줄어들죠~! 👍 👍
|
||
public class FakeMenuGroupRepository implements MenuGroupRepository { | ||
|
||
private final Map<UUID, MenuGroup> dataMap = new ConcurrentHashMap<>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Map을 활용하여 저장/조회 Method 구성이 가능하죠~! 👍 👍
.extracting(MenuGroup::getName) | ||
.containsExactlyInAnyOrder(names.toArray(String[]::new)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
마지막은 개행으로 끝날 수 있도록 설정해보면 어떨까요~!?
import org.springframework.boot.web.client.RestTemplateBuilder; | ||
import org.springframework.data.util.Pair; | ||
|
||
class ProductServiceTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요구사항 중 이름은 필수 입력 값이며, 비속어를 사용할 수 없다.
항목에 대해서 이름이 필수다를 검증해보면 어떨까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(테스트 케이스 추가)
@DisplayName("이름 없이 상품을 생성 시, 예외가 발생한다.") | |
@ParameterizedTest | |
@NullSource | |
void createNameException(String name) { | |
// given | |
Product product = ProductFixture.create(name, PRICE); | |
// when then | |
assertThatThrownBy(() -> productService.create(product)) | |
.isInstanceOf(IllegalArgumentException.class); | |
} |
|
||
@DisplayName("배달 주문을 생성할 수 있다.") | ||
@Test | ||
void createDelivery() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
주문 생성시 특정상태에 대해서 검증할 필요하지 않을까요~!?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(주문 상태가 WAITING인지 검증 추가)
assertThat(savedOrder.getStatus()).isEqualTo(OrderStatus.WAITING); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요~! 성훈님,
피드백 잘 반영해주셨네요~! 💯
다음 미션을 위해서 Merge 하겠습니다
그동안 고생하셨습니다~! 😄
리베이스를 잘못하여 step2 커밋이 섞었습니다😂
test: 메뉴그룹 리팩토링, 테스트 코드 작성
커밋부터 리뷰 부탁드립니다.언제나 감사합니다.🙇♂️