Skip to content

Refactor FiltersDecoder with Map-based parsing #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

tcheeric
Copy link
Owner

Summary

  • refactor FiltersDecoder to parse filters using TypeReference Map instead of JsonNode iteration
  • add a unit test for decoding a JSON with multiple filter types

Testing

  • mvn verify -DskipTests

https://chatgpt.com/codex/tasks/task_b_6889085c8350833193e92decedf6ccf5

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the FiltersDecoder to improve its JSON parsing approach by replacing Jackson JsonNode field iteration with a Map-based TypeReference approach, and adds comprehensive test coverage for multi-filter scenarios.

  • Replaces field iteration approach with Map-based parsing using TypeReference
  • Adds test coverage for decoding JSON with multiple filter types (ids, kinds, since)

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
FiltersDecoder.java Refactors JSON parsing from JsonNode field iteration to Map-based approach with TypeReference
FiltersDecoderTest.java Adds unit test for multiple filter types to validate decoder functionality
Comments suppressed due to low confidence (1)

nostr-java-event/src/test/java/nostr/event/unit/FiltersDecoderTest.java:384

  • Using Instant.now() creates a non-deterministic test that could fail due to timing. Consider using a fixed timestamp like Instant.parse("2023-01-01T00:00:00Z").toEpochMilli() for more reliable testing.
    Long since = Date.from(Instant.now()).getTime();

@@ -1,5 +1,7 @@
package nostr.event.json.codec;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonNode;
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The JsonNode import is now unused after the refactor. Consider removing this import to keep the code clean.

Copilot uses AI. Check for mistakes.

@tcheeric tcheeric merged commit 1596341 into develop Jul 29, 2025
@tcheeric tcheeric deleted the codex/refactor-filtersdecoder-to-use-mapper_afterburner branch July 29, 2025 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant