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

[ST-4] Repository에 저장 실패하면 던져지는 예외에 cause가 안담긴 버그 픽스 #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/main/java/net/slipp/todo_list/TodoManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void create(Todo todo) {
notify_silently(todo.getTitle());

} catch (RepositoryFailedException e) {
throw new RuntimeException();
throw new RuntimeException(e);
}

}
Expand Down
21 changes: 21 additions & 0 deletions src/test/java/net/slipp/todo_list/TodoManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,27 @@ public NotiManager notiManager() {
todoManager.create(todo);
}

@Test
public void TodoRepository_store_호출_시에_RepositoryFailedException을_던지면_RepositoryFailedException을_cause로하는_Exception을_던지는지_확인 () {
String TITLE = "TITLE";
String CONTENT = "CONTENT";

Todo todo = new Todo();
todo.setTitle(TITLE);
todo.setContent(CONTENT);


MockTodoRepository.exception = new RepositoryFailedException();

try {
todoManager.create(todo);
fail();
} catch (Exception e) {
assertNotNull(e.getCause());
assertTrue(e.getCause() instanceof RepositoryFailedException);
}
}

@Test(expected = RuntimeException.class)
public void TodoRepository_store_호출_시에_RuntimeException을_던지면_그대로_RuntimeException_던지는_지_확인 () {
String TITLE = "TITLE";
Expand Down