Skip to content

Linus gren#16

Closed
LinusWestling wants to merge 8 commits intomainfrom
linusGren
Closed

Linus gren#16
LinusWestling wants to merge 8 commits intomainfrom
linusGren

Conversation

@LinusWestling
Copy link

@LinusWestling LinusWestling commented Nov 13, 2025

En pull request

Summary by CodeRabbit

  • New Features

    • Added messaging interface: users can now send messages and receive incoming notifications.
    • Added file attachment support: users can upload and download files attached to messages.
    • Enhanced message display with topic, timestamp, and optional download links for attachments.
    • Added message input field with dedicated send buttons for messages and files.
  • Styling

    • Added dark-themed CSS stylesheet for improved UI appearance.

@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces a comprehensive notification/messaging system to a JavaFX application. It adds new data models (DTOs), a messaging interface with HTTP-based implementation, enhances the model and controller with observable state and async send/receive capabilities, updates UI components with message lists and input fields, adds necessary dependencies, applies CSS styling, and includes test coverage with mocking utilities.

Changes

Cohort / File(s) Summary
Configuration & Build
.gitignore, pom.xml, src/main/java/module-info.java
Added .env to gitignore. Added four dependencies: dotenv-java, javafx-swing, jackson-databind, and wiremock. Updated module-info.java with new module requirements (javafx.base, java.net.http, java.desktop, etc.).
Data Transfer Objects
src/main/java/com/example/AttachmentDto.java, src/main/java/com/example/NtfyMessageDto.java
New record types: AttachmentDto (name, url, type, size) and NtfyMessageDto (id, time, event, topic, message, attachment) with Jackson annotations and convenience method attachmentUrl().
Messaging Infrastructure
src/main/java/com/example/NtfyConnection.java, src/main/java/com/example/NtfyConnectionImpl.java
New interface NtfyConnection defining async send/receive/sendFile contract. NtfyConnectionImpl provides HTTP-based implementation with Dotenv-backed configuration, streaming JSON parsing, and file upload support.
Application Model & Controller
src/main/java/com/example/HelloModel.java, src/main/java/com/example/HelloController.java, src/main/java/com/example/HelloFX.java
HelloModel now accepts NtfyConnection dependency, exposes observable message list and message input property, implements async sendMessage/sendFile methods. HelloController wired with ListView, TextField, custom cell factory rendering messages with timestamps and attachments. HelloFX loads external stylesheet.
Utility Classes
src/main/java/com/example/ManyParameters.java, src/main/java/com/example/ManyParametersBuilder.java, src/main/java/com/example/Singelton.java
New classes demonstrating builder pattern (ManyParametersBuilder) and singleton pattern (Singelton with getInstance).
UI Resources
src/main/resources/com/example/hello-view.fxml, src/main/resources/com/example/style.css
Replaced simple StackPane with VBox layout containing message list, text input, and send buttons. Added dark-themed CSS stylesheet with styling for input fields, buttons, and message list.
Test Suite
src/test/java/com/example/HelloModelTest.java, src/test/java/com/example/NtfyConnectionSpy.java
New test class exercising HelloModel with spy and real HTTP connections via WireMock. NtfyConnectionSpy provides mock implementation for unit testing.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Controller as HelloController
    participant Model as HelloModel
    participant Conn as NtfyConnection
    participant HTTP as HTTP Server

    User->>Controller: Types message, clicks "Skicka"
    Controller->>Model: setMessageToSend(text)
    Controller->>Model: sendMessage()
    Model->>Conn: send(message)
    Conn->>HTTP: POST /mytopic (message)
    HTTP-->>Conn: 200 OK
    Conn-->>Model: CompletableFuture<true>
    Model->>User: (async update UI)

    Note over User,HTTP: Receive flow (background)
    Conn->>HTTP: GET /mytopic/json (stream)
    HTTP-->>Conn: newline-delimited JSON
    Conn->>Model: messageHandler.accept(NtfyMessageDto)
    Model->>Controller: ObservableList updates
    Controller->>User: ListView renders new message
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

  • NtfyConnectionImpl.java: HTTP streaming logic, JSON parsing, error handling, and Dotenv integration require careful verification.
  • HelloModel.java: New async state management (CompletableFuture) and observable bindings need validation for thread safety and FX dispatcher correctness.
  • HelloController.java: Custom cell factory rendering and event binding logic; verify proper lifecycle and memory management.
  • HelloModelTest.java: WireMock integration and async test patterns need scrutiny for test reliability and edge cases.
  • Cross-file consistency: Verify message flow end-to-end from UI through model to HTTP layer and back.

Poem

🐰 Messages hop through the network, swift and true,
Observable streams bring notifications to you.
With builders and singletons standing by,
Our JavaFX chat now reaches the sky! 📨✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21c51e8 and f1a7498.

📒 Files selected for processing (17)
  • .gitignore (1 hunks)
  • pom.xml (3 hunks)
  • src/main/java/com/example/AttachmentDto.java (1 hunks)
  • src/main/java/com/example/HelloController.java (1 hunks)
  • src/main/java/com/example/HelloFX.java (1 hunks)
  • src/main/java/com/example/HelloModel.java (1 hunks)
  • src/main/java/com/example/ManyParameters.java (1 hunks)
  • src/main/java/com/example/ManyParametersBuilder.java (1 hunks)
  • src/main/java/com/example/NtfyConnection.java (1 hunks)
  • src/main/java/com/example/NtfyConnectionImpl.java (1 hunks)
  • src/main/java/com/example/NtfyMessageDto.java (1 hunks)
  • src/main/java/com/example/Singelton.java (1 hunks)
  • src/main/java/module-info.java (1 hunks)
  • src/main/resources/com/example/hello-view.fxml (1 hunks)
  • src/main/resources/com/example/style.css (1 hunks)
  • src/test/java/com/example/HelloModelTest.java (1 hunks)
  • src/test/java/com/example/NtfyConnectionSpy.java (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant