You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "He-Pin (via GitHub)" <gi...@apache.org> on 2026/06/18 21:58:52 UTC

[PR] refactor: modernize BlogPostEntity Java test code with Java 17 records [pekko]

He-Pin opened a new pull request, #3085:
URL: https://github.com/apache/pekko/pull/3085

   ### Motivation
   Java 17 introduced records that make Java code more concise by eliminating boilerplate for data carrier classes.
   
   ### Modification
   - Convert command classes (AddPost, AddPostDone, GetPost, ChangeBody, Publish, PostContent) to records in BlogPostEntity
   - Convert event classes (PostAdded, BodyChanged, Published) to records in BlogPostEntity
   - Convert command classes to records in BlogPostEntityDurableState
   - Update all field accesses to use record accessor methods
   
   ### Result
   Test Java code is more concise and idiomatic for Java 17+, reducing boilerplate in two key documentation example files.
   
   ### Tests
   - `sbt javafmtAll` (passes)
   - `sbt "persistence-typed / Test / compile"` (to be verified by CI)
   
   ### References
   None - code modernization


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] refactor: modernize BlogPostEntity Java test code with Java 17 records [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #3085:
URL: https://github.com/apache/pekko/pull/3085#discussion_r3439501143


##########
actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/SyncTestingExampleTest.java:
##########
@@ -321,7 +263,8 @@ public void testSupportContextualAsk() {
 
     // The response adaptation can be tested as many times as you want without completing the ask
     Hello.Command response1 = effect.adaptResponse(new Hello.Answer("No.  Who are you?"));
-    assertEquals("No.  Who are you?", ((Hello.GotAnAnswer) response1).answer);
+    assertTrue(response1 instanceof Hello.GotAnAnswer);
+    assertEquals("No.  Who are you?", ((Hello.GotAnAnswer) response1).answer());
 
     // ... as can the message sent on a timeout
     assertTrue(effect.adaptTimeout() instanceof Hello.NoAnswerFrom);

Review Comment:
   can you change to assertInstanceOf as well?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] refactor: modernize BlogPostEntity Java test code with Java 17 records [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #3085:
URL: https://github.com/apache/pekko/pull/3085#issuecomment-4750172422

   thanks  @pjfanning 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] refactor: modernize BlogPostEntity Java test code with Java 17 records [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #3085:
URL: https://github.com/apache/pekko/pull/3085#discussion_r3439487818


##########
actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/SyncTestingExampleTest.java:
##########
@@ -321,7 +263,8 @@ public void testSupportContextualAsk() {
 
     // The response adaptation can be tested as many times as you want without completing the ask
     Hello.Command response1 = effect.adaptResponse(new Hello.Answer("No.  Who are you?"));
-    assertEquals("No.  Who are you?", ((Hello.GotAnAnswer) response1).answer);
+    assertTrue(response1 instanceof Hello.GotAnAnswer);

Review Comment:
   Junit has `assertInstanceOf` and it returns the instance with the cast done
   
   Something like:
   ```
   Hello.GotAnAnswer gotAnAnswer = assertInstanceOf(Hello.GotAnAnswer.class, response1);
    assertEquals("No.  Who are you?", gotAnAnswer.answer());
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] refactor: modernize BlogPostEntity Java test code with Java 17 records [pekko]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #3085:
URL: https://github.com/apache/pekko/pull/3085#discussion_r3439487818


##########
actor-testkit-typed/src/test/java/jdocs/org/apache/pekko/actor/testkit/typed/javadsl/SyncTestingExampleTest.java:
##########
@@ -321,7 +263,8 @@ public void testSupportContextualAsk() {
 
     // The response adaptation can be tested as many times as you want without completing the ask
     Hello.Command response1 = effect.adaptResponse(new Hello.Answer("No.  Who are you?"));
-    assertEquals("No.  Who are you?", ((Hello.GotAnAnswer) response1).answer);
+    assertTrue(response1 instanceof Hello.GotAnAnswer);

Review Comment:
   Junit has `assertInstanceOf` and it returns the instance with the cast done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] refactor: modernize BlogPostEntity Java test code with Java 17 records [pekko]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin merged PR #3085:
URL: https://github.com/apache/pekko/pull/3085


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org