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 안담긴 버그 픽스 김윤희 #10

Open
wants to merge 3 commits 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
25 changes: 24 additions & 1 deletion src/test/java/net/slipp/todo_list/TodoManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,29 @@ public NotiManager notiManager() {
todoManager.create(todo);
}

@Test
public void TodoRepository_store_호출_시에_Exception을_던지면_TodoManager_Create_에서_cause_포함하는지_확인 () {
String TITLE = "TITLE";
String CONTENT = "CONTENT";

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

MockTodoRepository.exception = new RepositoryFailedException();

RuntimeException todoManangerException = null;

try {
todoManager.create(todo);
} catch (RuntimeException e) {
todoManangerException = e;
}

assertNotNull(todoManangerException);
assertNotNull(todoManangerException.getCause());
}

private static class MockTodoRepository extends TodoRepository {

private static Todo passedTodo;
Expand All @@ -331,10 +354,10 @@ private static class MockNotiManager extends NotiManager {

@Override
public void notify(String title) throws RuntimeException {
passedTitle = title;

if(exception!=null && exception.getClass()==RuntimeException.class) { throw (RuntimeException)exception; }

passedTitle = title;
}
}
}