|
8 | 8 | import static org.assertj.core.api.Assertions.assertThat; |
9 | 9 |
|
10 | 10 | /** |
11 | | - * This is a {@link IntroductionTest} that is meant to verify if you properly implement {@link Introduction}. It is a |
12 | | - * simple example that show how each exercise is organized: a class to implement + test to verify if the implementation |
13 | | - * is correct. |
| 11 | + * This is a {@link ExerciseIntroductionTest} that is meant to verify if you properly implement {@link ExerciseIntroduction}. |
| 12 | + * It is a simple example that shows how each exercise is organized: todo section + tests. |
14 | 13 | * <p> |
15 | 14 | * A typical Java test uses JUnit framework to run the test, and may also use some other frameworks for assertions. |
16 | 15 | * In our exercises we use JUnit 5 + AssertJ |
|
22 | 21 | * @author Taras Boychuk |
23 | 22 | */ |
24 | 23 | @TestMethodOrder(MethodOrderer.OrderAnnotation.class) |
25 | | -class IntroductionTest { |
26 | | - private Introduction introduction = new Introduction(); |
| 24 | +class ExerciseIntroductionTest { |
| 25 | + private ExerciseIntroduction exerciseIntroduction = new ExerciseIntroduction(); |
27 | 26 | private String EXPECTED_MESSAGE = "The key to efficient learning is practice!"; |
28 | 27 |
|
29 | 28 | @Test |
30 | 29 | @Order(1) |
31 | 30 | @DisplayName("getWelcomeMessage method returns correct phrase") |
32 | 31 | void getWelcomeMessage() { |
33 | | - String message = introduction.getWelcomeMessage(); |
| 32 | + String message = exerciseIntroduction.getWelcomeMessage(); |
34 | 33 |
|
35 | 34 | assertThat(message).isEqualTo(EXPECTED_MESSAGE); |
36 | 35 | } |
37 | 36 |
|
38 | 37 | @Test |
39 | 38 | @Order(2) |
40 | | - @DisplayName("encodeMessage method exists") |
41 | | - @SneakyThrows |
42 | | - void encodeMessageExists() { |
43 | | - var encodeMessageMethod = Arrays.stream(Introduction.class.getDeclaredMethods()) |
44 | | - .filter(method -> method.getName().equals("encodeMessage")) |
45 | | - .findAny(); |
46 | | - |
47 | | - assertThat(encodeMessageMethod).isPresent(); |
48 | | - } |
49 | | - |
50 | | - @Test |
51 | | - @Order(3) |
52 | 39 | @DisplayName("encodeMessage returns correct encoded message") |
53 | 40 | @SneakyThrows |
54 | 41 | void encodeMessageReturnsCorrectPhrase() { |
55 | | - var encodeMessageMethod = Arrays.stream(Introduction.class.getDeclaredMethods()) |
| 42 | + var encodeMessageMethod = Arrays.stream(ExerciseIntroduction.class.getDeclaredMethods()) |
56 | 43 | .filter(method -> method.getName().equals("encodeMessage")) |
57 | 44 | .findAny() |
58 | 45 | .orElseThrow(); |
59 | 46 |
|
60 | | - var encodedMessage = encodeMessageMethod.invoke(new Introduction(), EXPECTED_MESSAGE); |
| 47 | + var encodedMessage = encodeMessageMethod.invoke(new ExerciseIntroduction(), EXPECTED_MESSAGE); |
61 | 48 |
|
62 | 49 | assertThat(encodedMessage).isEqualTo("VGhlIGtleSB0byBlZmZpY2llbnQgbGVhcm5pbmcgaXMgcHJhY3RpY2Uh"); |
63 | | - |
64 | 50 | } |
65 | 51 | } |
0 commit comments