Add negative test cases for API error handling by devin-ai-integration[bot] · Pull Request #21 · jack-killian/Deere_OperationsCenterAPI-OAuth2-Java · GitHub
Skip to content

Add negative test cases for API error handling#21

Closed
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1769104929-add-negative-error-tests
Closed

Add negative test cases for API error handling#21
devin-ai-integration[bot] wants to merge 1 commit into
masterfrom
devin/1769104929-add-negative-error-tests

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Add negative test cases for API error handling

Summary

This PR adds comprehensive negative test cases for the Deere Operations Center API OAuth2 example application. The tests cover error scenarios that were previously untested, including transaction retrieval errors, authorization failures, and authentication failures.

Changes:

  • Added JUnit 5 (5.10.2) and Mockito (5.11.0) test dependencies to pom.xml
  • Added maven-surefire-plugin 3.2.5 to enable JUnit 5 test execution
  • Created 3 test classes with 42 total test cases:
    • TransactionRetrievalErrorTest - 404/403/5xx errors for transaction retrieval
    • AuthorizationFailureTest - private/restricted transaction access, comment attempts on restricted resources
    • AuthFailureTest - missing/expired tokens, invalid tokens, insufficient scope

Review & Testing Checklist for Human

  • Verify test coverage scope: Tests only exercise LoggingInterceptor.onResponse() behavior with mocked HTTP responses. They do not test the full error handling flow in Application.java (e.g., how callTheApi, processCallback handle these exceptions). Consider if additional integration-level tests are needed.
  • Review dependency versions: Confirm JUnit 5.10.2 and Mockito 5.11.0 are appropriate versions for this project
  • Run mvn test locally to verify all 42 tests pass in your environment

Test Plan

  1. Run mvn clean test - should see 42 tests pass
  2. Run mvn package - should build successfully with tests

Notes

- Add JUnit 5 and Mockito test dependencies
- Add maven-surefire-plugin 3.2.5 for JUnit 5 support
- Add TransactionRetrievalErrorTest: tests for 404/403/5xx errors
- Add AuthorizationFailureTest: tests for private/restricted transactions
- Add AuthFailureTest: tests for missing/expired tokens, insufficient scope

Total: 42 test cases covering:
- Transaction retrieval errors (404, 403, 500, 502, 503, 504)
- Authorization failures for private transactions and comments
- Auth failures (missing token, expired token, invalid token, insufficient scope)

Co-Authored-By: Jack <jack.l.killian@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Author

@devin-ai-integration

Copy link
Copy Markdown
Author

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.

0 participants