Skip to content
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

chore: Remove unused usings #1223

Merged
merged 1 commit into from
Oct 3, 2024
Merged

chore: Remove unused usings #1223

merged 1 commit into from
Oct 3, 2024

Conversation

oskogstad
Copy link
Collaborator

@oskogstad oskogstad commented Oct 3, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced error handling in the SetSystemLabel method, providing detailed feedback for various outcomes.
    • Added new test cases for dialog creation validations, ensuring robustness against invalid inputs.
  • Bug Fixes

    • Improved handling of dialog creation scenarios to prevent invalid UUID formats and future timestamps.
  • Chores

    • Removed unused import statements across various files for code cleanup.

@oskogstad oskogstad requested a review from a team as a code owner October 3, 2024 15:14
Copy link
Contributor

coderabbitai bot commented Oct 3, 2024

📝 Walkthrough

Walkthrough

The pull request introduces several changes across multiple files, primarily focusing on the handling and querying of dialog label assignment logs, as well as modifications to dialog creation and update processes. Key updates include the addition of new classes for handling search queries and results, enhancements to error handling in GraphQL mutations, and the removal of unused import statements in various files. Additionally, the test suite for dialog creation has been expanded to include new validation scenarios.

Changes

File Change Summary
src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogLabelAssignmentLog/Queries/Search/SearchDialogLabelAssignmentLogQuery.cs Added SearchDialogLabelAssignmentLogQuery, SearchDialogLabelAssignmentLogResult, and SearchDialogLabelAssignmentLogQueryHandler classes.
src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Get/MappingProfile.cs Removed unused import statement for Digdir.Domain.Dialogporten.Domain.DialogEndUserContexts.Entities.
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs Modified CreateDialogCommandHandler to enhance error handling and validation logic.
src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogDto.cs Removed unused import statement for Digdir.Domain.Dialogporten.Domain.DialogEndUserContexts.Entities.
src/Digdir.Domain.Dialogporten.Application/Features/V1/WellKnown/OauthAuthorizationServer/Queries/Get/GetOauthAuthorizationServerQuery.cs Removed unused import statement; no changes to class functionality.
src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogCreatedDomainEvent.cs Removed unused import statement for Digdir.Library.Entity.Abstractions.Features.EventPublisher.
src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogDeletedDomainEvent.cs Removed unused import statement for Digdir.Library.Entity.Abstractions.Features.EventPublisher.
src/Digdir.Domain.Dialogporten.GraphQL/EndUser/MutationTypes/Mutations.cs Updated SetSystemLabel method to include comprehensive error handling logic.
tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/DeletedDialogTests.cs Removed unused import statement; no changes to test logic.
tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs Removed unused imports and added new test cases for dialog creation validation.

Possibly related PRs

Suggested reviewers

  • MagnusSandgren

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

sonarqubecloud bot commented Oct 3, 2024

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range comments (2)
src/Digdir.Domain.Dialogporten.Application/Features/V1/WellKnown/OauthAuthorizationServer/Queries/Get/GetOauthAuthorizationServerQuery.cs (1)

Line range hint 9-30: LGTM: Handler implementation remains correct.

The implementation of GetOauthAuthorizationServerQueryHandler is unchanged, which aligns with the PR objective. A few observations:

  1. The use of Constants.DialogTokenIssuerVersion in the URL construction is correct and follows the project's conventions.
  2. The hardcoded string "/.well-known/jwks.json" is a standard endpoint for JWKS and doesn't need to be replaced with a constant.

Consider adding a comment explaining the use of the hardcoded "/.well-known/jwks.json" string to improve code readability and maintainability.

tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs (1)

Line range hint 35-52: LGTM: New test for UUIDv7 little-endian format validation

This new test case effectively ensures that a dialog cannot be created with a UUIDv7 in little-endian format. The test logic is sound, and it follows the existing naming conventions and structure of other tests in the file.

Consider using a constant or a more descriptive variable name for the hardcoded GUID to improve readability and maintainability. For example:

private const string UuidV7LittleEndian = "638e9101-6bc7-7975-b392-ba5c5a528c23";
var invalidDialogId = Guid.Parse(UuidV7LittleEndian);

This change would make the intent clearer and easier to update if needed.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 6e7dfe4 and 5e1638f.

📒 Files selected for processing (10)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogLabelAssignmentLog/Queries/Search/SearchDialogLabelAssignmentLogQuery.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Get/MappingProfile.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogDto.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/WellKnown/OauthAuthorizationServer/Queries/Get/GetOauthAuthorizationServerQuery.cs (1 hunks)
  • src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogCreatedDomainEvent.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogDeletedDomainEvent.cs (0 hunks)
  • src/Digdir.Domain.Dialogporten.GraphQL/EndUser/MutationTypes/Mutations.cs (0 hunks)
  • tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/DeletedDialogTests.cs (0 hunks)
  • tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs (1 hunks)
💤 Files with no reviewable changes (8)
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/DialogLabelAssignmentLog/Queries/Search/SearchDialogLabelAssignmentLogQuery.cs
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/EndUser/Dialogs/Queries/Get/MappingProfile.cs
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Create/CreateDialogCommand.cs
  • src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Commands/Update/UpdateDialogDto.cs
  • src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogCreatedDomainEvent.cs
  • src/Digdir.Domain.Dialogporten.Domain/Dialogs/Events/DialogDeletedDomainEvent.cs
  • src/Digdir.Domain.Dialogporten.GraphQL/EndUser/MutationTypes/Mutations.cs
  • tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/EndUser/Dialogs/Queries/DeletedDialogTests.cs
🧰 Additional context used
📓 Learnings (2)
src/Digdir.Domain.Dialogporten.Application/Features/V1/WellKnown/OauthAuthorizationServer/Queries/Get/GetOauthAuthorizationServerQuery.cs (1)
Learnt from: oskogstad
PR: digdir/dialogporten#1124
File: src/Digdir.Domain.Dialogporten.Application/Features/V1/WellKnown/OauthAuthorizationServer/Queries/Get/GetOauthAuthorizationServerQuery.cs:22-22
Timestamp: 2024-09-25T13:49:51.143Z
Learning: Hardcoded `"/api/v1"` strings in the codebase correspond to external APIs the project integrates with and should not be replaced with internal constants.
tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs (1)
Learnt from: oskogstad
PR: digdir/dialogporten#1210
File: tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs:282-282
Timestamp: 2024-10-01T17:03:49.291Z
Learning: Using square brackets `[]` for collection initialization is acceptable in the codebase's C# code.
🔇 Additional comments (7)
src/Digdir.Domain.Dialogporten.Application/Features/V1/WellKnown/OauthAuthorizationServer/Queries/Get/GetOauthAuthorizationServerQuery.cs (1)

1-3: LGTM: Unused import removed successfully.

The removal of the unused import Digdir.Domain.Dialogporten.Application.Common.Authorization aligns with the PR objective of removing unused usings. The remaining imports are kept intact, which is correct as they are likely still in use within the file.

tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Features/V1/ServiceOwner/Dialogs/Commands/CreateDialogTests.cs (6)

1-6: LGTM: Unused using directives removed

The removal of unused using directives, including Castle.Core.Logging, aligns with the PR objective. The remaining using directives are relevant to the tests in this file. This change improves code cleanliness and reduces potential confusion.


Line range hint 17-33: LGTM: New test for UUIDv4 format validation

This new test case effectively ensures that a dialog cannot be created with a UUIDv4 format. The test logic is sound, and it follows the existing naming conventions and structure of other tests in the file.


Line range hint 54-114: LGTM: New tests for timestamp validation in dialog creation

These new test cases effectively cover important scenarios for dialog creation with different timestamp conditions:

  1. Preventing creation with a future timestamp
  2. Allowing creation with a past timestamp
  3. Successful creation of a simple dialog

The test logic is sound, and the methods follow the existing naming conventions and structure. The consistent use of GenerateBigEndianUuidV7 across the tests is good for maintaining uniformity in ID generation.


Line range hint 116-224: LGTM: Comprehensive tests for UpdatedAt and CreatedAt validation

These new test cases effectively cover various scenarios involving UpdatedAt and CreatedAt timestamps:

  1. Creating a dialog with UpdatedAt supplied
  2. Preventing creation when UpdatedAt is supplied without CreatedAt
  3. Preventing creation when UpdatedAt is earlier than CreatedAt
  4. Preventing creation with future timestamps
  5. Allowing creation when UpdatedAt and CreatedAt are equal

The test logic is sound, and the methods follow the existing naming conventions and structure. These tests ensure that the business rules for UpdatedAt and CreatedAt are properly enforced.


Line range hint 226-290: LGTM: Thorough tests for transmission content validation

These new test cases effectively cover various scenarios involving transmission content:

  1. Preventing creation of a transmission without content
  2. Preventing creation of a transmission without content value
  3. Preventing creation of a transmission with empty content localization values

The test logic is sound, and the methods follow the existing naming conventions and structure. These tests ensure that the business rules for transmission content are properly enforced.

The use of collection initialization with square brackets [] is consistent with the learning from oskogstad in PR #1210, which is good for maintaining consistency across the codebase.


Line range hint 1-290: Great job on expanding test coverage!

This PR successfully removes unused using directives and significantly expands the test coverage for the CreateDialog command. The new test cases cover a wide range of scenarios, including:

  1. UUID format validation
  2. Timestamp validation for dialog creation
  3. UpdatedAt and CreatedAt validation
  4. Transmission content validation

All new tests follow the existing naming conventions and code style, maintaining consistency throughout the file. These additions will greatly improve the robustness of the test suite and help catch potential issues in the dialog creation process.

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.

None yet

1 participant