-
-
Notifications
You must be signed in to change notification settings - Fork 756
Issue #2971 display names #3055
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
Changes from 14 commits
29f2d68
cf13ec2
1ec5bfa
abeab3c
240a2d2
b78d58c
8947790
d742b56
0911db6
3263b85
b00d461
4b9f11a
caa9560
d96f651
991ec6c
7b1165b
b382016
a51cf75
5f39489
44618f2
37981c3
6db2931
9805fec
311de45
40302ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,23 +1,26 @@ | ||||||
| import static org.assertj.core.api.Assertions.assertThat; | ||||||
| import static org.assertj.core.api.Assertions.assertThatExceptionOfType; | ||||||
|
|
||||||
| import org.junit.jupiter.api.Disabled; | ||||||
| import org.junit.jupiter.api.DisplayName; | ||||||
| import org.junit.jupiter.api.Test; | ||||||
|
|
||||||
| import java.util.Optional; | ||||||
|
|
||||||
| import static org.assertj.core.api.Assertions.assertThat; | ||||||
| import static org.assertj.core.api.Assertions.assertThatExceptionOfType; | ||||||
|
|
||||||
| public class ErrorHandlingTest { | ||||||
|
|
||||||
| private ErrorHandling errorHandling = new ErrorHandling(); | ||||||
|
|
||||||
| @Test | ||||||
| @DisplayName("Throws a general exception when requested") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| public void testThrowIllegalArgumentException() { | ||||||
| assertThatExceptionOfType(Exception.class) | ||||||
| .isThrownBy(() -> errorHandling.handleErrorByThrowingIllegalArgumentException()); | ||||||
| } | ||||||
|
|
||||||
| @Disabled("Remove to run test") | ||||||
| @Test | ||||||
| @DisplayName("Throws IllegalArgumentException with provided detail message") | ||||||
| public void testThrowIllegalArgumentExceptionWithDetailMessage() { | ||||||
| assertThatExceptionOfType(IllegalArgumentException.class) | ||||||
| .isThrownBy(() -> errorHandling.handleErrorByThrowingIllegalArgumentExceptionWithDetailMessage( | ||||||
|
|
@@ -27,6 +30,7 @@ public void testThrowIllegalArgumentExceptionWithDetailMessage() { | |||||
|
|
||||||
| @Disabled("Remove to run test") | ||||||
| @Test | ||||||
| @DisplayName("Throws a checked exception (not a RuntimeException)") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kahgoh
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| public void testThrowAnyCheckedException() { | ||||||
| assertThatExceptionOfType(Exception.class) | ||||||
| .isThrownBy(() -> errorHandling.handleErrorByThrowingAnyCheckedException()) | ||||||
|
|
@@ -35,6 +39,7 @@ public void testThrowAnyCheckedException() { | |||||
|
|
||||||
| @Disabled("Remove to run test") | ||||||
| @Test | ||||||
| @DisplayName("Throws a checked exception with the provided detail message") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| public void testThrowAnyCheckedExceptionWithDetailMessage() { | ||||||
| assertThatExceptionOfType(Exception.class) | ||||||
| .isThrownBy(() -> errorHandling.handleErrorByThrowingAnyCheckedExceptionWithDetailMessage( | ||||||
|
|
@@ -45,13 +50,15 @@ public void testThrowAnyCheckedExceptionWithDetailMessage() { | |||||
|
|
||||||
| @Disabled("Remove to run test") | ||||||
| @Test | ||||||
| @DisplayName("Throws an unchecked RuntimeException when requested") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| public void testThrowAnyUncheckedException() { | ||||||
| assertThatExceptionOfType(RuntimeException.class) | ||||||
| .isThrownBy(() -> errorHandling.handleErrorByThrowingAnyUncheckedException()); | ||||||
| } | ||||||
|
|
||||||
| @Disabled("Remove to run test") | ||||||
| @Test | ||||||
| @DisplayName("Throws an unchecked RuntimeException with provided detail message") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| public void testThrowAnyUncheckedExceptionWithDetailMessage() { | ||||||
| assertThatExceptionOfType(RuntimeException.class) | ||||||
| .isThrownBy(() -> errorHandling.handleErrorByThrowingAnyUncheckedExceptionWithDetailMessage( | ||||||
|
|
@@ -61,13 +68,15 @@ public void testThrowAnyUncheckedExceptionWithDetailMessage() { | |||||
|
|
||||||
| @Disabled("Remove to run test") | ||||||
| @Test | ||||||
| @DisplayName("Throws a custom checked exception") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| public void testThrowCustomCheckedException() { | ||||||
| assertThatExceptionOfType(CustomCheckedException.class) | ||||||
| .isThrownBy(() -> errorHandling.handleErrorByThrowingCustomCheckedException()); | ||||||
| } | ||||||
|
|
||||||
| @Disabled("Remove to run test") | ||||||
| @Test | ||||||
| @DisplayName("Throws a custom checked exception with provided message") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| public void testThrowCustomCheckedExceptionWithDetailMessage() { | ||||||
| assertThatExceptionOfType(CustomCheckedException.class) | ||||||
| .isThrownBy(() -> errorHandling.handleErrorByThrowingCustomCheckedExceptionWithDetailMessage( | ||||||
|
|
@@ -77,13 +86,15 @@ public void testThrowCustomCheckedExceptionWithDetailMessage() { | |||||
|
|
||||||
| @Disabled("Remove to run test") | ||||||
| @Test | ||||||
| @DisplayName("Throws a custom unchecked exception") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| public void testThrowCustomUncheckedException() { | ||||||
| assertThatExceptionOfType(CustomUncheckedException.class) | ||||||
| .isThrownBy(() -> errorHandling.handleErrorByThrowingCustomUncheckedException()); | ||||||
| } | ||||||
|
|
||||||
| @Disabled("Remove to run test") | ||||||
| @Test | ||||||
| @DisplayName("Throws a custom unchecked exception with provided message") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| public void testThrowCustomUncheckedExceptionWithDetailMessage() { | ||||||
| assertThatExceptionOfType(CustomUncheckedException.class) | ||||||
| .isThrownBy(() -> errorHandling.handleErrorByThrowingCustomUncheckedExceptionWithDetailMessage( | ||||||
|
|
@@ -93,6 +104,7 @@ public void testThrowCustomUncheckedExceptionWithDetailMessage() { | |||||
|
|
||||||
| @Disabled("Remove to run test") | ||||||
| @Test | ||||||
| @DisplayName("Returns Optional<Integer> for valid input and empty Optional for invalid input") | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| public void testReturnOptionalInstance() { | ||||||
| Optional<Integer> successfulResult = errorHandling.handleErrorByReturningOptionalInstance("1"); | ||||||
| assertThat(successfulResult).isPresent().hasValue(1); | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |||||||||||
| import io.reactivex.disposables.Disposable; | ||||||||||||
| import org.junit.jupiter.api.BeforeEach; | ||||||||||||
|
Comment on lines
3
to
5
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||||||||||||
| import org.junit.jupiter.api.Disabled; | ||||||||||||
| import org.junit.jupiter.api.DisplayName; | ||||||||||||
| import org.junit.jupiter.api.Test; | ||||||||||||
|
|
||||||||||||
| import java.util.ArrayList; | ||||||||||||
|
|
@@ -22,6 +23,7 @@ public void init() { | |||||||||||
| } | ||||||||||||
|
|
||||||||||||
| @Test | ||||||||||||
| @DisplayName("Initial game state is set correctly for a new word") | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The same goes with this one!
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| public void initialization() { | ||||||||||||
| Observable<Output> result = hangman.play( | ||||||||||||
| Observable.fromArray("secret"), | ||||||||||||
|
|
@@ -39,6 +41,7 @@ public void initialization() { | |||||||||||
|
|
||||||||||||
| @Disabled("Remove to run test") | ||||||||||||
| @Test | ||||||||||||
| @DisplayName("First correct guess updates discovered and guess lists") | ||||||||||||
| public void firstGuess() { | ||||||||||||
| Observable<Output> result = hangman.play( | ||||||||||||
| Observable.fromArray("secret"), | ||||||||||||
|
|
@@ -54,6 +57,7 @@ public void firstGuess() { | |||||||||||
|
|
||||||||||||
| @Disabled("Remove to run test") | ||||||||||||
| @Test | ||||||||||||
| @DisplayName("First incorrect guess registers a miss and adds a part") | ||||||||||||
| public void firstMiss() { | ||||||||||||
| Observable<Output> result = hangman.play( | ||||||||||||
| Observable.fromArray("secret"), | ||||||||||||
|
|
@@ -69,6 +73,7 @@ public void firstMiss() { | |||||||||||
|
|
||||||||||||
| @Disabled("Remove to run test") | ||||||||||||
| @Test | ||||||||||||
| @DisplayName("Game in progress accumulates guesses, misses and parts correctly") | ||||||||||||
| public void gameInProgress() { | ||||||||||||
| Observable<Output> result = hangman.play( | ||||||||||||
| Observable.fromArray("secret"), | ||||||||||||
|
|
@@ -84,6 +89,7 @@ public void gameInProgress() { | |||||||||||
|
|
||||||||||||
| @Disabled("Remove to run test") | ||||||||||||
| @Test | ||||||||||||
| @DisplayName("Winning the game reveals full word and marks WIN status") | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| public void wonGame() { | ||||||||||||
| Observable<Output> result = hangman.play( | ||||||||||||
| Observable.fromArray("secret"), | ||||||||||||
|
|
@@ -97,6 +103,7 @@ public void wonGame() { | |||||||||||
|
|
||||||||||||
| @Disabled("Remove to run test") | ||||||||||||
| @Test | ||||||||||||
| @DisplayName("Losing the game results in LOSS status and all parts present") | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| public void lostGame() { | ||||||||||||
| Observable<Output> result = hangman.play( | ||||||||||||
| Observable.fromArray("secret"), | ||||||||||||
|
|
@@ -118,6 +125,7 @@ public void lostGame() { | |||||||||||
|
|
||||||||||||
| @Disabled("Remove to run test") | ||||||||||||
| @Test | ||||||||||||
| @DisplayName("Handles consecutive games correctly with ordered emissions") | ||||||||||||
| public void consecutiveGames() { | ||||||||||||
| // This test setup is more complex because we have to order the emission of values in the | ||||||||||||
| // different observers. | ||||||||||||
|
|
@@ -189,6 +197,7 @@ Observable createLetterObservable(ObservableEmitter[] emitters, Runnable emit) { | |||||||||||
|
|
||||||||||||
| @Disabled("Remove to run test") | ||||||||||||
| @Test | ||||||||||||
| @DisplayName("Cannot play the same correct guess twice") | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||
| public void cannotPlayAGuessTwice() { | ||||||||||||
| Observable<Output> result = hangman.play( | ||||||||||||
| Observable.fromArray("secret"), | ||||||||||||
|
|
@@ -201,6 +210,7 @@ public void cannotPlayAGuessTwice() { | |||||||||||
|
|
||||||||||||
| @Disabled("Remove to run test") | ||||||||||||
| @Test | ||||||||||||
| @DisplayName("Cannot play the same miss twice") | ||||||||||||
| public void cannotPlayAMissTwice() { | ||||||||||||
| Observable<Output> result = hangman.play( | ||||||||||||
| Observable.fromArray("secret"), | ||||||||||||
|
|
||||||||||||
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.
Can you please keep all of them the same as the descriptions in the
canonical-data.jsonfile?And something to discuss, @kahgoh: only the tests up to this one are fully in sync with the canonical data. There are three more tests after this:
random character is valid,random ability is within range, andeach ability is only calculated once. But there are several extra tests in this file that are not present in the canonical data. Do you think we should keep them or make this file consistent with the canonical data?