Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
801e19e
initial commit
KatiaVasileva Jan 16, 2026
005fd63
ADD entities (Quest, Question, Answer)
KatiaVasileva Jan 20, 2026
7067bcb
ADD services and repositories (Quest, Question)
KatiaVasileva Jan 20, 2026
593b08d
ADD json mapper for quests + quest.json
KatiaVasileva Jan 20, 2026
325a5ee
ADD servlet/jsp (Home, QuestPage) + Config
KatiaVasileva Jan 20, 2026
32a68c0
ADD PlayGame and service/repository for Answer
KatiaVasileva Jan 21, 2026
83adc8f
MOVE from question to question
KatiaVasileva Jan 21, 2026
e0d132d
ADD new quest
KatiaVasileva Jan 22, 2026
7cfd4b0
ADD automatic id generation for quests
KatiaVasileva Jan 22, 2026
d5f4c86
CHANGE field names in Question and Answer
KatiaVasileva Jan 22, 2026
3ef86fc
FIX paths and ADD final buttons
KatiaVasileva Jan 22, 2026
c9b55f0
MOVE logic from servlet to service
KatiaVasileva Jan 22, 2026
91a0a30
ADD html/css for home page
KatiaVasileva Jan 23, 2026
4b99552
CHANGE json
KatiaVasileva Jan 23, 2026
39e6c4e
minor fixes
KatiaVasileva Jan 23, 2026
3b4e2b5
ADD html/css for quest page
KatiaVasileva Jan 23, 2026
ea524d8
MOVE quest info block to play-game page
KatiaVasileva Jan 25, 2026
ea05fd5
ADD create quest
KatiaVasileva Jan 25, 2026
4620329
FIX styles
KatiaVasileva Jan 26, 2026
0545da8
ADD update quest
KatiaVasileva Jan 26, 2026
e0ef74f
ADD edit quest (instead of create/update quest) DRY
KatiaVasileva Jan 26, 2026
cfb9d73
ADD edit quest (instead of create/update quest) DRY
KatiaVasileva Jan 26, 2026
83a791f
minor fixes
KatiaVasileva Jan 26, 2026
f30bd8d
minor fixws
KatiaVasileva Jan 26, 2026
fa74f44
FIX styles for quest edit
KatiaVasileva Jan 26, 2026
f935277
ADD list of quests in edit quest page
KatiaVasileva Jan 27, 2026
00e4794
ADD static variables (Key, Value, Link)
KatiaVasileva Jan 27, 2026
2c50cf0
ADD static variables (Link)
KatiaVasileva Jan 27, 2026
12bb2f4
ADD exception
KatiaVasileva Jan 28, 2026
9c95013
ADD filter for exception
KatiaVasileva Jan 28, 2026
5b4c2dd
ADD delete quest in servlet, command, jsp
KatiaVasileva Jan 29, 2026
febf578
ADD user repository and service
KatiaVasileva Jan 29, 2026
14b02fb
ADD login page + doGet
KatiaVasileva Jan 29, 2026
20cdb27
ADD login in navbar
KatiaVasileva Jan 29, 2026
785cf6b
ADD logout
KatiaVasileva Jan 29, 2026
4d76324
ADD register
KatiaVasileva Jan 29, 2026
5b2bcd5
ADD profile
KatiaVasileva Jan 29, 2026
49fbf0b
ADD user list, user create/edit/delete
KatiaVasileva Jan 29, 2026
5a40f98
ADD admin authorization
KatiaVasileva Jan 30, 2026
52504ea
FIX EditQuest and EditUser
KatiaVasileva Jan 30, 2026
509e48a
FIX Home, ListUser, Login, Logout
KatiaVasileva Jan 30, 2026
f5a7367
FIX rename UserList
KatiaVasileva Jan 30, 2026
26fbbba
FIX PlayGame, Register
KatiaVasileva Jan 30, 2026
625de00
ADD user repository fill in config
KatiaVasileva Jan 31, 2026
6f153a8
ADD stats view and command
KatiaVasileva Jan 31, 2026
26a932d
ADD number of completed quests
KatiaVasileva Jan 31, 2026
fac1c82
ADD number of completed quests
KatiaVasileva Jan 31, 2026
5e64e86
FIX minor fixes
KatiaVasileva Jan 31, 2026
db4d95a
ADD Game
KatiaVasileva Feb 2, 2026
47f33cc
ADD statistics
KatiaVasileva Feb 2, 2026
124cd37
ADD logging for commands
KatiaVasileva Feb 2, 2026
6a65e8d
ADD json
KatiaVasileva Feb 2, 2026
0b57b86
ADD unit tests for UserService and integration tests for Login
KatiaVasileva Feb 3, 2026
c90bd02
ADD integration tests for Register and Home
KatiaVasileva Feb 3, 2026
69e14e5
ADD integration tests for PlayGame
KatiaVasileva Feb 3, 2026
4985c66
ADD integration tests for EditUser
KatiaVasileva Feb 3, 2026
94d3194
ADD integration tests for UserList
KatiaVasileva Feb 3, 2026
4f54aa9
ADD integration tests for EditQuest
KatiaVasileva Feb 4, 2026
754add9
ADD integration tests for Stats and Logout
KatiaVasileva Feb 4, 2026
d3cd724
ADD test data for unit tests and unit tests for QuestService
KatiaVasileva Feb 4, 2026
d1b4ed3
ADD test data and unit tests for QuestionService
KatiaVasileva Feb 4, 2026
fbb3dc5
ADD test data and unit tests for AnswerService, GameService
KatiaVasileva Feb 4, 2026
d272780
ADD test data and unit tests for UserStats
KatiaVasileva Feb 4, 2026
e881283
ADD tests for AuthService + img for quests
KatiaVasileva Feb 4, 2026
8416f93
ADD img2 for quests
KatiaVasileva Feb 4, 2026
dd92bd3
ADD img1,3 for quests
KatiaVasileva Feb 4, 2026
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
41 changes: 41 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>

<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
Expand All @@ -55,6 +70,7 @@
<artifactId>lombok</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand All @@ -65,6 +81,23 @@
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>17.0.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</dependency>


</dependencies>

Expand All @@ -88,6 +121,14 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<useModulePath>false</useModulePath>
</configuration>
</plugin>
</plugins>

</build>
Expand Down
52 changes: 0 additions & 52 deletions src/main/java/com/javarush/khmelov/cmd/EditUser.java

This file was deleted.

26 changes: 0 additions & 26 deletions src/main/java/com/javarush/khmelov/cmd/ListUser.java

This file was deleted.

6 changes: 0 additions & 6 deletions src/main/java/com/javarush/khmelov/cmd/StartPage.java

This file was deleted.

19 changes: 0 additions & 19 deletions src/main/java/com/javarush/khmelov/repository/Repository.java

This file was deleted.

50 changes: 0 additions & 50 deletions src/main/java/com/javarush/khmelov/repository/UserRepository.java

This file was deleted.

36 changes: 0 additions & 36 deletions src/main/java/com/javarush/khmelov/service/UserService.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.javarush.khmelov.cmd;
package com.javarush.vasileva.cmd;

import jakarta.servlet.http.HttpServletRequest;

Expand All @@ -15,6 +15,10 @@ default String doPost(HttpServletRequest request) {
return getView();
}

default String doDelete(HttpServletRequest request) {
return getView();
}

default String getView() {
String simpleName = this.getClass().getSimpleName();
return convertCamelCaseToKebabStyle(simpleName);
Expand All @@ -32,6 +36,4 @@ private static String convertCamelCaseToKebabStyle(String string) {
? snakeName.substring(1)
: snakeName;
}


}
101 changes: 101 additions & 0 deletions src/main/java/com/javarush/vasileva/cmd/EditQuest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.javarush.vasileva.cmd;

import com.javarush.vasileva.config.Config;
import com.javarush.vasileva.config.Winter;
import com.javarush.vasileva.entity.Quest;
import com.javarush.vasileva.exception.AppException;
import com.javarush.vasileva.mapper.QuestMapper;
import com.javarush.vasileva.service.AuthService;
import com.javarush.vasileva.service.QuestService;
import jakarta.servlet.http.HttpServletRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.List;

import static com.javarush.vasileva.util.Key.*;
import static com.javarush.vasileva.util.Link.HOME;
import static com.javarush.vasileva.util.Value.*;

@SuppressWarnings("unused")
public class EditQuest implements Command {

private static final Logger LOGGER = LoggerFactory.getLogger(EditQuest.class.getName());

private final QuestService questService;
private final AuthService authService;
private final QuestMapper questMapper = Winter.find(QuestMapper.class);
private final Config config;

@SuppressWarnings("unused")
public EditQuest(QuestService questService, AuthService authService, Config config) {
this.questService = questService;
this.authService = authService;
this.config = config;
}

@Override
public String doGet(HttpServletRequest req) {
LOGGER.info("Received GET request to edit quests");

authService.checkAdminAuthorization(req, EDIT_QUEST_AUTH_ERROR);

List<Quest> quests = questService.getAll();
req.setAttribute(QUESTS, quests);
LOGGER.debug("Loaded quests: {}", quests.size());

String questIdStr = req.getParameter(QUEST_ID);
if (questIdStr != null && !questIdStr.isEmpty()) {
LOGGER.info("Editing quest with id: {}", questIdStr);
Quest quest = questService.getValidatedQuest(questIdStr)
.orElseThrow(() -> new AppException(QUEST_NOT_FOUND + questIdStr));
req.setAttribute(EDIT, true);
try {
String questJson = questMapper.toJsonString(quest);
req.setAttribute(QUEST_JSON, questJson);
LOGGER.debug("Quest is mapped to JSON. ID: {}", quest.getId());
} catch (IOException e) {
return getView();
}
} else {
LOGGER.info("Creating quest");
req.setAttribute(EDIT, false);
req.setAttribute(QUEST_JSON, JSON_SAMPLE);
}
return getView();
}

@Override
public String doPost(HttpServletRequest req) {
LOGGER.info("Processing POST-request for saving quest. Параметры: {}", req.getParameterMap());
String questJson = req.getParameter(QUEST_JSON);

if (questJson == null || questJson.isEmpty()) {
LOGGER.error(JSON_SAVE_ERROR + ". JSON parameter is missing or empty");
req.getSession().setAttribute(ERROR, JSON_SAVE_ERROR);
return getView();
}

try {
Quest quest = questMapper.fromJsonString(questJson);
LOGGER.debug("Quest is successfully received from JSON. Title: {}", quest.getTitle());
if (quest.getId() != null) {
LOGGER.info("Updating quest with ID: {}", quest.getId());
questService.update(quest);
} else {
LOGGER.info("Creating new quest");
questService.create(quest);
}
config.setQuestParameters(quest);
LOGGER.info("Quest is successfully saved. ID: {}", quest.getId());
return HOME;
} catch (IOException e) {
LOGGER.error(JSON_SAVE_ERROR + ". JSON: {}. Cause: {}",
questJson, e.getMessage(), e);
req.getSession().setAttribute(QUEST_JSON, questJson);
req.getSession().setAttribute(ERROR, JSON_SAVE_ERROR);
return getView();
}
}
}
Loading