Move few more message classes to factory#42
Conversation
c3c664e to
b6983b9
Compare
b6983b9 to
b2cf69a
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR moves several message classes from direct instantiation to factory-based construction, continuing the refactoring effort to centralize message creation. The changes improve code consistency by ensuring all message construction goes through the factory pattern.
- Moves 5 message classes (StyxTReadMessage, StyxTCreateMessage, StyxRWriteMessage, StyxRWalkMessage, StyxRReadMessage) from direct instantiation to factory methods
- Updates message class constructors to protected visibility to enforce factory usage
- Adds corresponding factory methods to support the new construction pattern
Reviewed Changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| StyxSerializerImplTest.java | Updates test cases to use factory methods instead of direct message construction |
| MessageSerializerImplTest.java | Replaces direct StyxRReadMessage instantiation with factory method |
| FactoryImplTests.java | Adds comprehensive test coverage for new factory methods and improves assertion patterns |
| StyxUnbufferedOutputStream.java | Updates import to use moved StyxRWriteMessage from v9p2000 package |
| StyxUnbufferedInputStream.java | Refactors to use factory for TReadMessage construction and adds dependency injection |
| StyxFileBufferedInputStream.java | Updates constructor to accept factory dependency |
| StyxFile.java | Replaces direct TCreateMessage instantiation with factory methods |
| StyxSerializerImpl.java | Removes unused wildcard import |
| StyxDeserializerImpl.java | Updates deserialization to use factory methods for message construction |
| Message classes | Moves classes to v9p2000 package and changes constructors to protected |
| FactoryImpl.java | Implements new factory methods for the moved message types |
| Factory.java | Adds interface methods for new factory constructors |
| TMessagesProcessor.java | Updates message processing to use factory methods |
Comments suppressed due to low confidence (1)
java/v2styx-lib/src/main/java/com/v2soft/styxlib/l6/io/StyxUnbufferedInputStream.java:28
- [nitpick] The field name 'getMessagesFactoryUseCase' uses a verb prefix which is unconventional for field names. Consider renaming to 'messagesFactoryUseCase' or 'factoryUseCase'.
private GetMessagesFactoryUseCase getMessagesFactoryUseCase;
| Assertions.assertNotNull(message); | ||
| Assertions.assertEquals(1, message.getTag()); | ||
| Assertions.assertTrue(message instanceof StyxRErrorMessage); | ||
| Assertions.assertInstanceOf(StyxRErrorMessage.class, message); |
There was a problem hiding this comment.
[nitpick] The assertInstanceOf check is redundant since the cast on line 52 would already fail if the type is incorrect. Consider removing this assertion or the cast.
| Assertions.assertInstanceOf(StyxRErrorMessage.class, message); |
| Assertions.assertNotNull(message); | ||
| Assertions.assertEquals(1, message.getTag()); | ||
| Assertions.assertTrue(message instanceof StyxRAttachMessage); | ||
| Assertions.assertInstanceOf(StyxRAttachMessage.class, message); |
There was a problem hiding this comment.
[nitpick] The assertInstanceOf check is redundant since the cast on line 69 would already fail if the type is incorrect. Consider removing this assertion or the cast.
| Assertions.assertInstanceOf(StyxRAttachMessage.class, message); |
| Assertions.assertNotNull(message); | ||
| Assertions.assertEquals(1, message.getTag()); | ||
| Assertions.assertTrue(message instanceof StyxRAuthMessage); | ||
| Assertions.assertInstanceOf(StyxRAuthMessage.class, message); |
There was a problem hiding this comment.
[nitpick] The assertInstanceOf check is redundant since the cast on line 78 would already fail if the type is incorrect. Consider removing this assertion or the cast.
| Assertions.assertInstanceOf(StyxRAuthMessage.class, message); |
No description provided.