Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 9 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@
# cp .env.example .env

# --- Postgres ---
POSTGRES_HOST=db
POSTGRES_PORT=5432
POSTGRES_DB=pks_dev
POSTGRES_USER=pks_user
POSTGRES_PASSWORD=changeme

# --- Backend app settings (used by the backend, not by compose) ---
# --- Backend app settings ---
JWT_SECRET=replace-me-with-64-hex-chars # openssl rand -hex 32
JWT_ACCESS_EXPIRATION_IN_MS=900000 # 15 minutes
JWT_REFRESH_EXPIRATION_IN_MS=604800000 # 7 days
APP_PORT=8080
REDIS_PASSWORD=changeme

# --- MinIO (only needed with: docker compose --profile files up -d) ---
# --- MinIO ---
MINIO_HOST=minio
MINIO_PORT=9000
MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=changeme-minio-root
MINIO_BUCKET_NAME=local-bucket
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ buildNumber.properties
# JDT-specific (Eclipse Java Development Tools)
.classpath

.vscode
.vscode/launch.json
.idea

tools/scenicview/
Expand Down
10 changes: 9 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
{
"recommendations": ["vscjava.vscode-lombok"]
"recommendations": [
"vscjava.vscode-lombok",
"github.vscode-github-actions",
"dhruv.maven-dependency-explorer",
"vscjava.vscode-maven",
"vscjava.vscode-java-dependency",
"vscjava.vscode-java-test",
"shengchen.vscode-checkstyle"
]
}
24 changes: 24 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"[java]": {
"editor.detectIndentation": false,
},
"java.project.sourcePaths": [
"src/main/java/com/DesktopApplicationClientJava",
],
"java.format.settings.url": ".vscode/eclipse-java-google-style.xml",
"java.format.settings.profile": "GoogleStyle",
"java.configuration.updateBuildConfiguration": "automatic",
"xml.validation.noGrammar": "ignore",
"java.checkstyle.configuration": "${workspaceFolder}/checkstyle.xml",
"java.checkstyle.version": "14.3.0",
"java.autobuild.enabled": false,
"files.watcherExclude": {
"**/target/**": true
},
"files.exclude": {
"**/target": true
},
"java.import.exclusions": [
"**/target/**"
]
}
96 changes: 61 additions & 35 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
---

# Test infrastructure for DesktopApplicationClientJava integration tests.
#
# Mirrors the contract of the backend (pks-java) compose file: same services,
Expand All @@ -6,10 +8,6 @@
#
# Default: postgres + redis (enough for auth/resource/user/admin ITs):
# docker compose up -d
# With object storage (for file/export ITs):
# docker compose --profile files up -d
# Desktop client (GUI: нужен X-сервер, подробности в README; к бэкенду ходит по HTTP, поэтому без depends_on):
# docker compose --profile gui run --rm client

services:
client:
Expand All @@ -23,58 +21,85 @@ services:
volumes:
- /tmp/.X11-unix:/tmp/.X11-unix:ro

backend:
image: detfiniktn/java-pks:latest
container_name: backend
depends_on:
postgres:
condition: service_healthy
redis:
condition: service_healthy
minio:
condition: service_healthy
healthcheck:
interval: 10s
retries: 5
test: ["CMD-SHELL", "curl -f http://localhost:8080/java-pks/health/live || exit 1"]
timeout: 5s
ports:
- "8080:8080"
environment:
SPRING_DATASOURCE_URL: jdbc:postgresql://db:5432/pks_dev
SPRING_DATASOURCE_USERNAME: ${POSTGRES_USER}
SPRING_DATASOURCE_PASSWORD: ${POSTGRES_PASSWORD}
SPRING_DATA_REDIS_HOST: redis
SPRING_DATA_REDIS_PORT: "6379"
JWT_SECRET: ${JWT_SECRET}
volumes:
- ./.env:/workspace/.env:ro
restart: on-failure:1

postgres:
image: postgres:16-alpine
container_name: db
environment:
- POSTGRES_DB=${POSTGRES_DB}
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
ports:
- '5432:5432'
volumes:
- postgres_data:/var/lib/postgresql/data
restart: unless-stopped
- POSTGRES_USER=${POSTGRES_USER}
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 5
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
timeout: 5s
ports:
- "5432:5432"
restart: on-failure
volumes:
- postgres_data:/var/lib/postgresql/data

redis:
image: redis:7-alpine
ports:
- '6379:6379'
volumes:
- redis_basic_data:/data
restart: unless-stopped
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 10s
timeout: 5s
retries: 5
test: ["CMD", "redis-cli", "ping"]
timeout: 5s
ports:
- "6379:6379"
restart: on-failure
volumes:
- redis_basic_data:/data

minio:
image: quay.io/minio/minio
profiles: [files]
image: pgsty/minio:latest
command: server /data --console-address ":9001"
environment:
- MINIO_ROOT_USER=${MINIO_ROOT_USER}
- MINIO_ROOT_PASSWORD=${MINIO_ROOT_PASSWORD}
ports:
- '9000:9000' # S3 API
- '9001:9001' # Web Console
volumes:
- minio_data:/data
restart: unless-stopped
- MINIO_ROOT_USER=${MINIO_ROOT_USER}
healthcheck:
test: ["CMD-SHELL", "curl -f http://localhost:9000/minio/health/live || exit 1"]
interval: 10s
timeout: 5s
retries: 5
test: ["CMD-SHELL", "curl -f http://localhost:9000/minio/health/live || exit 1"]
timeout: 5s
ports:
- "9000:9000" # S3 API
- "9001:9001" # Web Console
restart: on-failure
volumes:
- minio_data:/data

minio-init:
image: minio/mc:latest
profiles: [files]
image: pgsty/mc:latest
depends_on:
minio:
condition: service_healthy
Expand All @@ -86,10 +111,11 @@ services:
mc admin policy attach myminio readwrite --user ${MINIO_ACCESS_TOKEN};
exit 0;
"
restart: on-failure

volumes:
redis_basic_data:
postgres_data:
driver: local
minio_data:
driver: local
postgres_data:
driver: local
redis_basic_data:
29 changes: 7 additions & 22 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
# Lefthook config for this Java/Maven project (replaces pre-commit).
#
# All jobs are CHECK-ONLY (no auto-fix):
# - lint via `mvn checkstyle:check`
# - format via `mvn spotless:check` (use `mvn spotless:apply` manually to fix)
# - unit tests via `mvn test` (integration tests tagged `integration` are
# already excluded from the default build via surefire `excludedGroups`
# in pom.xml, so no live backend is needed)
#
# Install/activate (per clone):
# brew install lefthook # or: winget install evilmartians.lefthook / scoop install lefthook
# lefthook install
#
# Run manually:
# lefthook run pre-commit
pre-commit:
parallel: false
parallel: true
jobs:
- name: "lint: mvn checkstyle:check"
run: mvn -B checkstyle:check
- name: "format: mvn spotless:check"
run: mvn -B spotless:check
- name: "test: mvn test (unit only, integration excluded)"
run: mvn -B test
- name: "lint"
run: mvn -B -q checkstyle:check
- name: "format"
run: mvn -B -q spotless:check
- name: "unit tests"
run: mvn -B -q clean test
19 changes: 17 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,18 @@
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.11.0</version>
<executions>
<execution>
<goals>
<goal>properties</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand All @@ -148,14 +160,17 @@
-Dprism.text=t2k
-Djava.awt.headless=true
--enable-native-access=ALL-UNNAMED
-XX:+EnableDynamicAgentLoading
-Djdk.instrument.traceUsage=false
-javaagent:${org.mockito:mockito-core:jar}
-Djava.util.logging.config.file=${project.basedir}/src/test/resources/logging.properties
-Xshare:off
</argLine>
<!-- Integration tests (tag "integration") need a live backend,
so they never run in the default build or CI.
Run them explicitly:
mvn test -Dgroups=integration -DexcludedGroups= -->
<excludedGroups>${excludedGroups}</excludedGroups>
<!-- Path to the local .env file for integration tests (java-dotenv).
Missing file is fine: tests skip via assumeTrue. -->
<systemPropertyVariables>
<dotenv.path>${project.basedir}/.env</dotenv.path>
</systemPropertyVariables>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@

public class LoginFormController extends Controller {

@FXML private TextField emailField;
@FXML private PasswordField passwordField;
@FXML private Label errorLabel;
@FXML private Button submitButton;
@FXML TextField emailField;
@FXML PasswordField passwordField;
@FXML Label errorLabel;
@FXML Button submitButton;

@FXML
private void onSubmit(ActionEvent event) {
void onSubmit(ActionEvent event) {
String email = emailField.getText() == null ? "" : emailField.getText().trim();
String password = passwordField.getText() == null ? "" : passwordField.getText();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ public class ResourceDetailsController extends Controller {

static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm");

@FXML private Label titleLabel;
@FXML private Label descriptionLabel;
@FXML private Label createdLabel;
@FXML private Label updatedLabel;
@FXML private Label uuidLabel;
@FXML private Label errorLabel;
@FXML private Label statusLabel;
@FXML private TableView<FileInfo> filesTable;
@FXML private TableColumn<FileInfo, String> nameColumn;
@FXML private TableColumn<FileInfo, String> sizeColumn;
@FXML private TableColumn<FileInfo, String> contentTypeColumn;
@FXML private TableColumn<FileInfo, Void> downloadColumn;
@FXML private Button backButton;
@FXML private Button editButton;
@FXML Label titleLabel;
@FXML Label descriptionLabel;
@FXML Label createdLabel;
@FXML Label updatedLabel;
@FXML Label uuidLabel;
@FXML Label errorLabel;
@FXML Label statusLabel;
@FXML TableView<FileInfo> filesTable;
@FXML TableColumn<FileInfo, String> nameColumn;
@FXML TableColumn<FileInfo, String> sizeColumn;
@FXML TableColumn<FileInfo, String> contentTypeColumn;
@FXML TableColumn<FileInfo, Void> downloadColumn;
@FXML Button backButton;
@FXML Button editButton;

private UUID resourceId;

Expand Down Expand Up @@ -101,11 +101,12 @@ public void load() {
}

@FXML
private void onBack(ActionEvent event) {
void onBack(ActionEvent event) {
navigator.goTo("/fxml/ResourceList.fxml");
}

private void onDownload(FileInfo file) {
@FXML
void onDownload(FileInfo file) {
File dir = chooseDirectory(backButton.getScene().getWindow());
if (dir == null) {
return;
Expand Down
Loading
Loading