kevinlu1248 / CoralME

A simple, fast and garbage-free matching engine order book that you can use as a starting point for your matching engines.
Apache License 2.0
0 stars 0 forks source link

Implement Enums and Add Unit Tests for Order Management System #6

Open sweep-nightly[bot] opened 3 weeks ago

sweep-nightly[bot] commented 3 weeks ago

Purpose

This pull request implements several enum classes to represent various aspects of an order management system and adds corresponding unit tests to ensure their correctness.

This pull request was created to solve the following GitHub issue:

(Refactor) Move enums from Order.java to separate files and delete the enums from Order.java

Currently, several enums are defined within the Order.java file. To improve code organization and maintainability, move these enums to their own respective files.

Handle all imports and references in the files.

Enums to be moved (this is not an exhaustive list, please check for any additional enums): Remove the enums from the original Order.java file and move them to their own files.

CancelReason ExecuteSide RejectReason Side TimeInForce Type


Move enums from Order.java to separate files

Description:

Refactor the Order.java file by moving the enum definitions to their own separate files. This will improve code organization and maintainability. Update all necessary imports and references in affected files.

Tasks:

  • Create new enum files in the src/main/java/com/coralblocks/coralme directory:

    • CancelReason.java
    • ExecuteSide.java
    • RejectReason.java
    • Side.java
    • TimeInForce.java
    • Type.java
    • CancelRejectReason.java
    • ReduceRejectReason.java
  • Move the corresponding enum definitions from Order.java to their respective new files

  • Update Order.java:

    • Remove the enum definitions
    • Add import statements for the newly created enum files
  • Update any other files that reference these enums:

    • Add import statements for the new enum files
    • Update any fully qualified enum references
  • Review and update any documentation that mentions these enums

Test:

  • Verify that all existing tests in src/test/java/com/coralblocks/coralme still pass after the refactoring
  • Add new unit tests for each enum in their respective test files (e.g., SideTest.java, TypeTest.java, etc.) to ensure they function correctly after the move

Description

This pull request introduces the following enum classes:

Each enum class implements the CharEnum interface and includes a CharMap for efficient lookup by character representation. The classes also include methods for converting between enum values and FIX protocol codes where applicable.

Additionally, this pull request adds comprehensive unit tests for each enum class to verify their functionality, including value retrieval, character representation, and FIX code conversion.

The Order class has been updated to use these new enum classes, improving type safety and readability.

Summary

Fixes

Fixes #5. Continue the conversation here: http://localhost:3000/c/3561a532-beb1-40da-ac7c-c6edab41e1da.

To have Sweep make further changes, please add a comment to this PR starting with "Sweep:".

:book: For more information on how to use Sweep, please read our documentation.

Tracking ID: 847b5aa3cc
sweep-nightly[bot] commented 3 weeks ago

Some of the CI runs failed, but I couldn't access the logs. Check Sweep's permissions at https://github.com/organizations/kevinlu1248/settings/installations/.

:book: For more information on how to use Sweep, please read our documentation.

Tracking ID: 847b5aa3cc-ci-0