Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughReplaces the Changes
Sequence Diagram(s)sequenceDiagram
participant Client as LoginServiceImpl
participant Agent as RequestAgent
participant Proxy as ResponseProxy
participant Deserializer as ResponseDeserializer
participant Domain as Response
Client->>Agent: send(Request<Void>)
Agent-->>Client: ResponseProxy
Client->>Proxy: getResponse()
Proxy-->>Client: Response
Client->>Domain: body()
Domain-->>Client: String body / throws Exception
Client->>Deserializer: deserialize(body, Credentials.class)
Deserializer-->>Client: Credentials
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java`:
- Around line 89-93: The lambda used for ResponseDeserializer in
instanceWithSuccessResponse cannot implement its generic method; replace the
lambda with an anonymous class that implements ResponseDeserializer and
overrides the deserialize(...) method to return deserializedCredentials. Keep
the RequestAgent lambda (RequestAgent<Void> requestAgent = _ ->
successResponseProxy()) as-is and construct the LoginServiceImpl with the new
anonymous ResponseDeserializer implementation so LoginServiceImpl(...) receives
a proper ResponseDeserializer instance.
- Around line 52-56: The lambda passed to ResponseDeserializer.deserialize
cannot implement its generic method; replace the lambda with an anonymous class
that explicitly implements ResponseDeserializer and overrides the generic method
signature (e.g. in LoginServiceImplTest replace the lambda block with new
ResponseDeserializer() { `@Override` public <R> R deserialize(Response response,
Class<R> type) { return null; } } ), keeping the thrown
IncorrectUsernameOrPasswordException path unchanged.
- Around line 99-101: The test helper method encoded(String value) uses
value.getBytes() which relies on the platform default charset; update encoded to
call value.getBytes(StandardCharsets.UTF_8) and add the
java.nio.charset.StandardCharsets import so the test matches the production
LoginServiceImpl charset handling and is portable across environments.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a7fe2f7a-4df1-40a7-b435-66b64097b205
📒 Files selected for processing (8)
README.mdsrc/main/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImpl.javasrc/main/java/pl/vtt/wpi/core/application/util/RequestAgent.javasrc/main/java/pl/vtt/wpi/core/application/util/RequestHandler.javasrc/main/java/pl/vtt/wpi/core/application/util/ResponseDeserializer.javasrc/main/java/pl/vtt/wpi/core/application/util/ResponseProxy.javasrc/main/java/pl/vtt/wpi/core/domain/model/Response.javasrc/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java
💤 Files with no reviewable changes (1)
- src/main/java/pl/vtt/wpi/core/application/util/RequestHandler.java
src/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java
Show resolved
Hide resolved
src/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java
Show resolved
Hide resolved
src/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java`:
- Around line 46-64: The test name implies verifying the "agent returns invalid
credentials" path but the provided RequestAgent lambda throws an
IncorrectUsernameOrPasswordException, so update the test to match the name by
making the agent return a successful Response and have the anonymous
ResponseDeserializer.deserialize return null (so
LoginServiceImpl.login(USERNAME, PASSWORD) sees null credentials), or
alternatively keep the agent-throwing lambda and rename the test method to
shouldThrowWhenAgentThrowsException; locate the setup in the LoginServiceImpl
constructor call (the RequestAgent lambda and the anonymous ResponseDeserializer
implementation) and change the agent to return a success Response or rename the
test accordingly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 68d15184-3ea9-4538-81f4-eccf3c793274
📒 Files selected for processing (1)
src/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java
src/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java (1)
65-66: Add cleanup assertion for the exception path.After Line 65, assert that
AuthorizationHolderis cleared. This directly verifies the failure cleanup behavior oflogin().✅ Suggested assertion addition
assertThrows(IncorrectUsernameOrPasswordException.class, () -> instance.login(USERNAME, PASSWORD)); +assertNull(AuthorizationHolder.get());🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java` around lines 65 - 66, After the assertThrows(IncorrectUsernameOrPasswordException.class, () -> instance.login(USERNAME, PASSWORD)); add an assertion that AuthorizationHolder is cleared to verify failure cleanup; specifically, in LoginServiceImplTest assert after the exception that AuthorizationHolder (the static holder used by the service) contains no credentials / is null/empty as your project convention dictates, ensuring login() on error does not leave state behind.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In
`@src/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java`:
- Around line 86-94: The test should seed AuthorizationHolder before calling
LoginServiceImpl.logout() so it actually verifies state transition; update the
shouldClearAuthorizationOnLogout test to set a non-null value into
AuthorizationHolder (e.g., AuthorizationHolder.set(...) or equivalent) prior to
calling instance.logout(), then call instance.logout() and
assertNull(AuthorizationHolder.get()) to ensure logout() clears the holder;
reference LoginServiceImpl.logout() and AuthorizationHolder.get()/set() when
making the change.
---
Nitpick comments:
In
`@src/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java`:
- Around line 65-66: After the
assertThrows(IncorrectUsernameOrPasswordException.class, () ->
instance.login(USERNAME, PASSWORD)); add an assertion that AuthorizationHolder
is cleared to verify failure cleanup; specifically, in LoginServiceImplTest
assert after the exception that AuthorizationHolder (the static holder used by
the service) contains no credentials / is null/empty as your project convention
dictates, ensuring login() on error does not leave state behind.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 7c66ced8-ea6e-460f-8511-76398a7c5aa1
📒 Files selected for processing (1)
src/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java
| @Test | ||
| @DisplayName("Tests a logout") | ||
| void logout_ok() { | ||
| LoginServiceImpl instance = new LoginServiceImpl(null, null, null); | ||
| @DisplayName("Should clear authorization on logout") | ||
| void shouldClearAuthorizationOnLogout() { | ||
| LoginServiceImpl instance = new LoginServiceImpl(null, null, null, null); | ||
|
|
||
| instance.logout(); | ||
|
|
||
| assertNull(AuthorizationHolder.get()); | ||
| } |
There was a problem hiding this comment.
logout() test is vacuous right now.
Because @BeforeEach already clears the holder, Line 93 passes even if logout() does nothing. Seed AuthorizationHolder first, then verify it transitions to null after logout.
✅ Proposed test fix
`@Test`
`@DisplayName`("Should clear authorization on logout")
void shouldClearAuthorizationOnLogout() {
LoginServiceImpl instance = new LoginServiceImpl(null, null, null, null);
+ AuthorizationHolder.authorize("Basic", "dummy");
+ assertNotNull(AuthorizationHolder.get());
instance.logout();
assertNull(AuthorizationHolder.get());
}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In
`@src/test/java/pl/vtt/wpi/core/application/service/impl/LoginServiceImplTest.java`
around lines 86 - 94, The test should seed AuthorizationHolder before calling
LoginServiceImpl.logout() so it actually verifies state transition; update the
shouldClearAuthorizationOnLogout test to set a non-null value into
AuthorizationHolder (e.g., AuthorizationHolder.set(...) or equivalent) prior to
calling instance.logout(), then call instance.logout() and
assertNull(AuthorizationHolder.get()) to ensure logout() clears the holder;
reference LoginServiceImpl.logout() and AuthorizationHolder.get()/set() when
making the change.
Motivation
RequestHandlerabstraction with a richer request/response model to support proxying and deserialization of HTTP responses.LoginServiceImplconsume the new abstractions so that response bodies and errors can be handled uniformly.LoginServiceImplto cover edge cases and correct authorization behavior.Description
RequestAgent,ResponseProxy, andResponseDeserializerand a domainResponsemodel to represent proxied responses and deserialization behavior.RequestHandlerinterface and updatedLoginServiceImplto useRequestAgentto send requests andResponseDeserializerto convert response bodies intoCredentialsobjects.application.utilto reflect the new interfaces.LoginServiceImplTestto use parameterized tests and helper factories, added success and failure scenarios, and added assertions thatAuthorizationHolderis updated and cleared correctly.Testing
LoginServiceImplTestviamvn test; all tests passed successfully.Codex Task
Summary by CodeRabbit
Refactor
Tests
Documentation