Skip to content

Commit 268f5f9

Browse files
committed
Minor updates for exercise Introduction
1 parent d3b836d commit 268f5f9

File tree

3 files changed

+52
-66
lines changed

3 files changed

+52
-66
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.bobocode.intro;
2+
3+
import com.bobocode.util.ExerciseNotCompletedException;
4+
5+
/**
6+
* Welcome! This is an introduction exercise that will show you a simple example of Bobocode exercises.
7+
* <p>
8+
* JavaDoc is a way of communication with other devs. We use Java Docs in every exercise to define the task.
9+
* So PLEASE MAKE SURE you read the Java Docs carefully.
10+
* <p>
11+
* Every exercise is covered with tests, see {@link ExerciseIntroductionTest}.
12+
* <p>
13+
* In this repo you'll find dozens of exercises covering various fundamental topics.
14+
* They all have the same structure helping you to focus on practice and build strong skills!
15+
*
16+
* @author Taras Boychuk
17+
*/
18+
public class ExerciseIntroduction {
19+
/**
20+
* This method returns a very important message. If understood well, it can save you years of inefficient learning,
21+
* and unlock your potential!
22+
*
23+
* @return "The key to efficient learning is practice!"
24+
*/
25+
public String getWelcomeMessage() {
26+
// todo: implement a method and return a message according to javadoc
27+
throw new ExerciseNotCompletedException();
28+
}
29+
30+
/**
31+
* Method encodeMessage accepts one {@link String} parameter and returns encoded {@link String}.
32+
* <p>
33+
* PLEASE NOTE THAT YOU WILL GET STUCK ON THIS METHOD INTENTIONALLY! ;)
34+
* <p>
35+
* Every exercise has a completed solution that is stored in the branch "completed". So in case you got stuck
36+
* and don't know what to do, go check out completed solution.
37+
*
38+
* @param message input message
39+
* @return encoded message
40+
*/
41+
public String encodeMessage(String message) {
42+
// todo: switch to branch "completed" in order to see how it should be implemented
43+
throw new ExerciseNotCompletedException();
44+
}
45+
}

0-0-intro/src/main/java/com/bobocode/intro/Introduction.java

Lines changed: 0 additions & 45 deletions
This file was deleted.

0-0-intro/src/test/java/com/bobocode/intro/IntroductionTest.java renamed to 0-0-intro/src/test/java/com/bobocode/intro/ExerciseIntroductionTest.java

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
import static org.assertj.core.api.Assertions.assertThat;
99

1010
/**
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.
1413
* <p>
1514
* A typical Java test uses JUnit framework to run the test, and may also use some other frameworks for assertions.
1615
* In our exercises we use JUnit 5 + AssertJ
@@ -22,44 +21,31 @@
2221
* @author Taras Boychuk
2322
*/
2423
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
25-
class IntroductionTest {
26-
private Introduction introduction = new Introduction();
24+
class ExerciseIntroductionTest {
25+
private ExerciseIntroduction exerciseIntroduction = new ExerciseIntroduction();
2726
private String EXPECTED_MESSAGE = "The key to efficient learning is practice!";
2827

2928
@Test
3029
@Order(1)
3130
@DisplayName("getWelcomeMessage method returns correct phrase")
3231
void getWelcomeMessage() {
33-
String message = introduction.getWelcomeMessage();
32+
String message = exerciseIntroduction.getWelcomeMessage();
3433

3534
assertThat(message).isEqualTo(EXPECTED_MESSAGE);
3635
}
3736

3837
@Test
3938
@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)
5239
@DisplayName("encodeMessage returns correct encoded message")
5340
@SneakyThrows
5441
void encodeMessageReturnsCorrectPhrase() {
55-
var encodeMessageMethod = Arrays.stream(Introduction.class.getDeclaredMethods())
42+
var encodeMessageMethod = Arrays.stream(ExerciseIntroduction.class.getDeclaredMethods())
5643
.filter(method -> method.getName().equals("encodeMessage"))
5744
.findAny()
5845
.orElseThrow();
5946

60-
var encodedMessage = encodeMessageMethod.invoke(new Introduction(), EXPECTED_MESSAGE);
47+
var encodedMessage = encodeMessageMethod.invoke(new ExerciseIntroduction(), EXPECTED_MESSAGE);
6148

6249
assertThat(encodedMessage).isEqualTo("VGhlIGtleSB0byBlZmZpY2llbnQgbGVhcm5pbmcgaXMgcHJhY3RpY2Uh");
63-
6450
}
6551
}

0 commit comments

Comments
 (0)