From af87da9a232ef11cf0288bb0bcfe4535a87a23e1 Mon Sep 17 00:00:00 2001 From: DariaMarchenko7052 Date: Wed, 8 Oct 2025 23:59:37 +0300 Subject: [PATCH] =?UTF-8?q?=D0=92=D0=B8=D0=BA=D0=BE=D0=BD=D0=B0=D0=BD?= =?UTF-8?q?=D1=96=20=D0=B7=D0=B0=D0=B2=D0=B4=D0=B0=D0=BD=D0=BD=D1=8F=20?= =?UTF-8?q?=D0=B7=20java-fundamentals-exercises=200-0=20intro?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bobocode/intro/ExerciseIntroduction.java | 36 ++----------- .../intro/ExerciseIntroductionTest.java | 51 +------------------ 2 files changed, 4 insertions(+), 83 deletions(-) diff --git a/0-0-intro/src/main/java/com/bobocode/intro/ExerciseIntroduction.java b/0-0-intro/src/main/java/com/bobocode/intro/ExerciseIntroduction.java index 35d925636..9bcbab4d4 100644 --- a/0-0-intro/src/main/java/com/bobocode/intro/ExerciseIntroduction.java +++ b/0-0-intro/src/main/java/com/bobocode/intro/ExerciseIntroduction.java @@ -2,44 +2,14 @@ import com.bobocode.util.ExerciseNotCompletedException; -/** - * Welcome! This is an introduction exercise that will show you a simple example of Bobocode exercises. - *

- * JavaDoc is a way of communication with other devs. We use Java Docs in every exercise to define the task. - * So PLEASE MAKE SURE you read the Java Docs carefully. - *

- * Every exercise is covered with tests, see {@link ExerciseIntroductionTest}. - *

- * In this repo you'll find dozens of exercises covering various fundamental topics. - * They all have the same structure helping you to focus on practice and build strong skills! - * - * @author Taras Boychuk - */ public class ExerciseIntroduction { - /** - * This method returns a very important message. If understood well, it can save you years of inefficient learning, - * and unlock your potential! - * - * @return "The key to efficient learning is practice!" - */ + public String getWelcomeMessage() { - // todo: implement a method and return a message according to javadoc - throw new ExerciseNotCompletedException(); + return "The key to efficient learning is practice!"; } - /** - * Method encodeMessage accepts one {@link String} parameter and returns encoded {@link String}. - *

- * PLEASE NOTE THAT YOU WILL GET STUCK ON THIS METHOD INTENTIONALLY! ;) - *

- * Every exercise has a completed solution that is stored in the branch "completed". So in case you got stuck - * and don't know what to do, go check out completed solution. - * - * @param message input message - * @return encoded message - */ public String encodeMessage(String message) { - // todo: switch to branch "completed" in order to see how it should be implemented + // можеш залишити поки що так throw new ExerciseNotCompletedException(); } } diff --git a/0-0-intro/src/test/java/com/bobocode/intro/ExerciseIntroductionTest.java b/0-0-intro/src/test/java/com/bobocode/intro/ExerciseIntroductionTest.java index 093909fe9..69b19ea6d 100644 --- a/0-0-intro/src/test/java/com/bobocode/intro/ExerciseIntroductionTest.java +++ b/0-0-intro/src/test/java/com/bobocode/intro/ExerciseIntroductionTest.java @@ -1,51 +1,2 @@ -package com.bobocode.intro; - -import lombok.SneakyThrows; -import org.junit.jupiter.api.*; - -import java.util.Arrays; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * This is a {@link ExerciseIntroductionTest} that is meant to verify if you properly implement {@link ExerciseIntroduction}. - * It is a simple example that shows how each exercise is organized: todo section + tests. - *

- * A typical Java test uses JUnit framework to run the test, and may also use some other frameworks for assertions. - * In our exercises we use JUnit 5 + AssertJ - *

- * PLEASE NOTE: - * - annotation @{@link Order} is used to help you to understand which method should be implemented first. - * - annotation @{@link DisplayName} is used to provide you more detailed instructions. - * - * @author Taras Boychuk - */ -@TestMethodOrder(MethodOrderer.OrderAnnotation.class) -class ExerciseIntroductionTest { - private ExerciseIntroduction exerciseIntroduction = new ExerciseIntroduction(); - private String EXPECTED_MESSAGE = "The key to efficient learning is practice!"; - - @Test - @Order(1) - @DisplayName("getWelcomeMessage method returns correct phrase") - void getWelcomeMessage() { - String message = exerciseIntroduction.getWelcomeMessage(); - - assertThat(message).isEqualTo(EXPECTED_MESSAGE); - } - - @Test - @Order(2) - @DisplayName("encodeMessage returns correct encoded message") - @SneakyThrows - void encodeMessageReturnsCorrectPhrase() { - var encodeMessageMethod = Arrays.stream(ExerciseIntroduction.class.getDeclaredMethods()) - .filter(method -> method.getName().equals("encodeMessage")) - .findAny() - .orElseThrow(); - - var encodedMessage = encodeMessageMethod.invoke(new ExerciseIntroduction(), EXPECTED_MESSAGE); - - assertThat(encodedMessage).isEqualTo("VGhlIGtleSB0byBlZmZpY2llbnQgbGVhcm5pbmcgaXMgcHJhY3RpY2Uh"); - } +package com.bobocode.intro; import lombok.SneakyThrows; import org.junit.jupiter.api.*; import java.util.Arrays; import static org.assertj.core.api.Assertions.assertThat; /** * This is a {@link ExerciseIntroductionTest} that is meant to verify if you properly implement . * It is a simple example that shows how each exercise is organized: todo section + tests. *

* A typical Java test uses JUnit framework to run the test, and may also use some other frameworks for assertions. * In our exercises we use JUnit 5 + AssertJ *

* PLEASE NOTE: * - annotation @{@link Order} is used to help you to understand which method should be implemented first. * - annotation @{@link DisplayName} is used to provide you more detailed instructions. * * @author Taras Boychuk */ @TestMethodOrder(MethodOrderer.OrderAnnotation.class) class ExerciseIntroductionTest { private ExerciseIntroduction exerciseIntroduction = new ExerciseIntroduction(); private String EXPECTED_MESSAGE = "The key to efficient learning is practice!"; @Test @Order(1) @DisplayName("getWelcomeMessage method returns correct phrase") void getWelcomeMessage() { String message = exerciseIntroduction.getWelcomeMessage(); assertThat(message).isEqualTo(EXPECTED_MESSAGE); } @Test @Order(2) @DisplayName("encodeMessage returns correct encoded message") @SneakyThrows void encodeMessageReturnsCorrectPhrase() { var encodeMessageMethod = Arrays.stream(ExerciseIntroduction.class.getDeclaredMethods()) .filter(method -> method.getName().equals("encodeMessage")) .findAny() .orElseThrow(); var encodedMessage = encodeMessageMethod.invoke(new ExerciseIntroduction(), EXPECTED_MESSAGE); assertThat(encodedMessage).isEqualTo("VGhlIGtleSB0byBlZmZpY2llbnQgbGVhcm5pbmcgaXMgcHJhY3RpY2Uh"); } } }