Ebyrdeu / spring_boot_library

0 stars 0 forks source link

Integration test of controllers And Refactoring for project #33

Closed Ebyrdeu closed 8 months ago

Ebyrdeu commented 8 months ago

Related Issue(s)

Closes #7

Proposed Changes

Description

In the beginning, the focus was on implementing integration tests. However, after conducting several rounds of testing, it became evident that the existing setup, particularly concerning endpoints and other layers, would lead to complications in future maintenance and scalability. Therefore, alongside the integration test refactoring, efforts have been directed towards optimizing the project for future use.

The introduction of integration tests for both UserController and MessageController serves as a step towards ensuring robustness and reliability in handling user and message-related operations. Additionally, a more modular and maintainable architecture has been achieved by introducing an intermediate layer for services. Services are now defined as interfaces, with concrete implementations residing in the impl package, thus enhancing code clarity and facilitating future modifications.

A new utility class, Utils, has been introduced, housing a method isNullable designed to facilitate partial updates. This utility simplifies the process of handling nullable fields when updating entities. For improved testing capabilities, a dedicated TestDataUtils class has been added, providing utilities tailored for testing purposes. This includes methods for generating test data and setting up test scenarios.

Both PUT and PATCH methods have been implemented for UserController and MessageController, offering flexibility in handling resource updates. Refactoring efforts extend to test suites as well. The UserRepositoryTest and MessageRepositoryTest have been updated to adopt a more cohesive approach, moving away from the @DataJpaTest annotation to ensure alignment with integration tests.

Naming conventions have been standardized across entities, repositories, and services, enhancing code consistency and readability. Furthermore, adjustments have been made to entity constraints to accurately reflect their behavior and constraints.

Finally, redundant endpoints in MessageController have been removed, streamlining the API and reducing complexity.

Overall, these changes contribute to a more robust, maintainable, and efficient project structure, laying a solid foundation for future development and scalability. Moving forward, the focus shifts towards ensuring security measures are in place, anticipating smoother development and maintenance processes.

sonarcloud[bot] commented 8 months ago

Quality Gate Passed Quality Gate passed

Issues
7 New issues
0 Accepted issues

Measures
0 Security Hotspots
81.8% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud